CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • cron jobs stopped authenticating
Pages: [1] 2

Author Topic: cron jobs stopped authenticating  (Read 3903 times)

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
cron jobs stopped authenticating
June 25, 2009, 07:06:22 am
I configured CiviMail in April and have successfully sent half a dozen email blast to our members over the past two months.  Yesterday another blast simply sat at "Scheduled" even though the cron job runs every 10 minutes.  Running the curl request from the command line produces
Code: [Select]
ERROR: Invalid username and/or password
However, I can login to the Joomla backend using the username and password specified in the command.  The site key is correct.  

Also,  the "Send a Test" feature in the wizard sent a test mailing just fine, so the mail set up is correct.  There seems to be an authentication problem with the cronjob and Mailprocessor scripts.

Suggestions about where to look and why it would have stopped working?
« Last Edit: August 20, 2009, 08:23:41 am by FatherShawn »
Lead Developer, C3 Design.
Twitter: @FatherShawn

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: cron jobs stopped authenticating
July 04, 2009, 07:26:24 am
I updated to 2.2.6 and Joomla to 1.5.11 just in case there was a bug fix - didn't help though.
Lead Developer, C3 Design.
Twitter: @FatherShawn

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: cron jobs stopped authenticating
July 04, 2009, 09:10:11 am

does the user name or password contain some non-alphanumeric characters?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: cron jobs stopped authenticating
July 04, 2009, 09:17:51 am
No.  Both are only letters and/or numbers.  ???
Lead Developer, C3 Design.
Twitter: @FatherShawn

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: cron jobs stopped authenticating
July 04, 2009, 03:48:50 pm

your best bet would be to debug the code at:

CRM/Utils/System/Joomla.php, line 242 onwards (in function authenticate)

thanx

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: cron jobs stopped authenticating
July 04, 2009, 05:33:51 pm
Thanks for the heads up on where to debug.

I'm off to a two week national legislative convention Monday, so I might not have a look until I get back - unless php sounds like a good break from legislation and such!
Lead Developer, C3 Design.
Twitter: @FatherShawn

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: cron jobs stopped authenticating
July 04, 2009, 05:40:10 pm

make sure u put in a good word for civicrm to the delegates at the convention :)

have fun legislating

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: cron jobs stopped authenticating
August 06, 2009, 12:52:03 pm
Quote from: Donald Lobo on July 04, 2009, 03:48:50 pm

your best bet would be to debug the code at:

CRM/Utils/System/Joomla.php, line 242 onwards (in function authenticate)

thanx

lobo



OK, added some debug output to try to see what's going on.  Added
Code: [Select]
// debug code begins
$f = fopen("...Joomal_web_root/administrator/debug.txt", "a");
if (!$row) {
  fwrite($f, "row empty");
} else {
  fwrite($f, $row);
fclose($f);}
// debug code ends
at line 248 after
Code: [Select]
require_once 'CRM/Core/BAO/UFMatch.php';
I got 'row empty' in the debug file.  Why would the row be empty?  The member name exists.
Lead Developer, C3 Design.
Twitter: @FatherShawn

Piotr Szotkowski

  • Moderator
  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: cron jobs stopped authenticating
August 12, 2009, 02:57:22 am
Quote from: FatherShawn on August 06, 2009, 12:52:03 pm
I got 'row empty' in the debug file.  Why would the row be empty?  The member name exists.

Can you check what’s the query in the $sql variable and try to run it against your database?

(My gut feeling is that there might be something with lowercasing and/or escaping the username.)
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: cron jobs stopped authenticating
August 12, 2009, 06:45:57 pm
OK, I know my php is still coming up to speed, but this should be too simple!  What am I missing:
Code: [Select]
<?php  //this line added to this posting to force proper formatting for the forum posting
        
$sql = 'SELECT u.* FROM ' . $config->userFrameworkUsersTableName .
            
" u WHERE LOWER(u.username) = '$name' AND u.block = 0";
        
$query = $dbJoomla->query( $sql );
// debug code begins
$f = fopen('/joomlaroot/administrator/debug.txt', 'a');
  
fwrite($f, '$sql = ', $sql);
fclose($f);
// debug code ends

debug.txt is created but is empty.
Lead Developer, C3 Design.
Twitter: @FatherShawn

Piotr Szotkowski

  • Moderator
  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: cron jobs stopped authenticating
August 13, 2009, 02:49:25 am
First, are you sure the file gets created (as opposed to being there from previous runs)? Please try deleting it and then check whether it gets recreated (otherwise it might be that the user running the script cannot write to the file – I’m not sure whether by ‘empty’ you mean there’s ‘$sql =’ in it or not).

Second, you can try writing the $sql variable right after it gets created, in case the query() call munges the string or exits the application:

Code: [Select]
<?php
# ...
        
$sql = 'SELECT u.* FROM ' . $config->userFrameworkUsersTableName .
            
" u WHERE LOWER(u.username) = '$name' AND u.block = 0";
        
file_put_contents('/joomlaroot/administrator/debug.txt', "\$sql = $sql");
        
$query = $dbJoomla->query( $sql );
# ...
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: cron jobs stopped authenticating
August 13, 2009, 03:29:18 am
Thanks Piotr!  Something was clearly amiss in my code and I learned a new function, file_put_contents:
Quote
mysql> USE joomladb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT u.* FROM jos_users u WHERE LOWER(u.username) = 'membermail' AND u.block = 0
resulted in the correct row.  I'll use the  simpler file_put_contents to see what's happening further down the script and repost.
Lead Developer, C3 Design.
Twitter: @FatherShawn

Piotr Szotkowski

  • Moderator
  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: cron jobs stopped authenticating
August 13, 2009, 05:50:43 am
Now that I look at it, your fwrite() call was wrong (you passed $sql as a third param, instead of concatenating it to the second). But file_put_contents() is simpler and it wraps the open/write/calls nicely.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: cron jobs stopped authenticating
August 18, 2009, 07:13:46 am
OK - password check variables match, so why is the script returning an error message?

I added the following at line
Code: [Select]
<?php

       
if ( $row = $query->fetchRow( DB_FETCHMODE_ASSOC ) ) {
            
// now check password
            
if ( strpos( $row['password'], ':' ) === false ) {
// begin debug code
$row_pass = $row['password'];
$emd5 = md5( $password);
file_put_contents('/public/www/htdocs/administrator/debug.txt', "row-pass = $row_pass \n EmDe5 = $emd5");
                if ( 
$row['password'] != md5( $password ) ) {
file_put_contents('/public/www/htdocs/administrator/debug.txt', "\n row_pass to md5 returned false");
                    return 
false;
                }
            } else {
                list( 
$hash, $salt ) = explode( ':', $row['password'] );
                
$cryptpass           = md5( $password . $salt );
file_put_contents('/public/www/htdocs/administrator/debug.txt', "hash = $hash \n cryptpass = $cryptpass");
                if ( 
$hash != $cryptpass ) {
file_put_contents('/public/www/htdocs/administrator/debug.txt', "\n hash to cryptpass returned false");
                    return 
false;
                }
            }

debug.txt contains:
Quote
hash = a hash string
cryptpass = exact same string
Lead Developer, C3 Design.
Twitter: @FatherShawn

Piotr Szotkowski

  • Moderator
  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: cron jobs stopped authenticating
August 19, 2009, 05:31:13 am
Quote from: FatherShawn on August 18, 2009, 07:13:46 am
OK - password check variables match, so why is the script returning an error message?

[…]

debug.txt contains:
Quote
hash = a hash string
cryptpass = exact same string

Does it also contain ‘hash to cryptpass returned false’? If not, then the function returns false somewhere below, not in the $hash != $cryptpass condition. (The next condition checks whether the associated CiviCRM contact actually exists, and most probably this is where the method returns false if the hashes match.)
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • cron jobs stopped authenticating

This forum was archived on 2017-11-26.