LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-10-2005, 11:04 AM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 668
Blog Entries: 7

Rep: Reputation: 31
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 ";
else
$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);
echo $function_call
//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......
 
Old 11-11-2005, 05:23 AM   #2
destuxor
Member
 
Registered: Oct 2005
Posts: 51

Rep: Reputation: 16
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.
 
Old 11-11-2005, 03:25 PM   #3
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 668
Blog Entries: 7

Original Poster
Rep: Reputation: 31
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......
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c++ md5 develinux Programming 2 02-28-2009 10:38 AM
Md5 hlinux Fedora 2 06-28-2005 10:21 PM
md5 RDove Programming 3 03-07-2005 10:22 AM
PHP md5 oddity gk_ Programming 0 01-10-2005 08:23 PM
using iso.md5 and iso.md5.asc Tyir Linux - Newbie 3 07-10-2004 11:45 PM


All times are GMT -5. The time now is 03:50 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration