php + MD5 ==> gone crazy..!!!
Hi guys Ive been working on this one for a couple of hours and I still havent figured it out........Ive got a script to add users it worked fine but the problem was that I needed to hash the password in the useradd -p argument to make the whole process valid.......when I hash the password nothing happens the script does not give me any output.....ex: if I try to add the same users twice the system would have presented me with the output of the useradd command "users exists" but now it just swallows my input without further notic
//create the user with the supplied args
$command = "sudo useradd $username ";
if($group != "")
$command = $command. "-g $group ";
$command = $command. "-d $home_dir ";
if($shell == "")
$command = $command. "-s /bin/bash ";
$command = $command. "-s shell ";
$command = $command. "-c $comment ";
//the line below is used to hash the password
$encrypted_pwd = "sudo openssl passwd -crypt $password";
//asign password to the output of the encrypt function
$password = shell_exec($encrypted_pwd);
$command = $command. "-p $password ";
$command = $command.' 2>&1';
$function_call = shell_exec($command);
//The problem is that echo $function_call is not sending anything even if I try to send the same username more than once........that does not happen when I remove the hashed password and jsut supply a usertyped password......
I am no expert, but I just saw this thread on forums.gentoo.org that may be a result of the same problem you're having: http://forums.gentoo.org/viewtopic-t-399371.html
Apparently MySQL 4.1 handles passwords somewhat differently than 4.0.
Ok for all those guys who might need an answer to this question .........use the crypt() function in PHP, it takes to arguments one is the word to be hashed and the second is the hash salt..........actually the second argument determines what kind of hashing you want ot use.......md5 standard des blowfish etc..........when you get the output give it to useradd -p $output and it will work just fine......
|All times are GMT -5. The time now is 05:43 PM.|