[geeklog-users] Backups failing - crosspost

Douglas S. Keester dkeester at earthlink.net
Wed Oct 8 13:15:13 EDT 2003


Hello Everyone,

I am new to these lists. I apologize if I spam anyone with this cross post.

I took a quick look through the list archives for anything relating to this 
topic, but didn't see anything. I apologize if this has been covered before.

I recently found a small bug(?) in GL 1.3.8 and 1.3.8-1 in the way that 
passwords are handled in database.php. My problem is that I have 
non-alphanumeric characters in my MySQL password (an '&' to be exact). I have 
always been able login to the DB correctly and GL has always rendered 
correctly. I just couldn't get the Backup feature of GL to work. (I am not 
sure if it makes a difference, but magic quotes are  currently on.)

I finally realized that my problem was in the way that GL was building the 
'mysqldump' command. By default the string would be sent to the OS as:
"/usr/bin/mysqldump -hlocalhost -uuser -pmy&pass gl_db > backup_file.sql"

The problem here is that the ampersand (&) is bare. When the OS (Linux) 
encounters this, it assumes that is the end of a command to run a process in 
the background. Thus the dump would fail every time since the command was 
incomplete. The string should be sent as:
"/usr/bin/mysqldump -hlocalhost -uuser -p\"my&pass\" gl_db > backup_file.sql"

This sends the password as a double-quoted string to the OS and therefore 
sends it intact to MySQL. This allows me to have non-alphanumeric characters 
in my password. I am a bit of a newbie when it comes to PHP, so again I am 
not sure what effect the magic quotes being on has on this.

The code from database.php in question (starting on line 67) is:
        if (!empty ($_DB_pass)) {
            $command .= " -p$_DB_pass";
        }

I changed the code to:
        if (!empty ($_DB_pass)) {
            $command .= " -p\"$_DB_pass\"";
        }

Once I made this change the backups started working for me.

I hope this is of use to someone besides me. :-)

Cheers,
-- 
Douglas S. Keester
dkeester at earthlink.net
	or
dougkeester at hotmail.com



More information about the geeklog-users mailing list