LinuxQuestions.org
Visit Jeremy's Blog.
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 08-17-2004, 09:04 PM   #1
da_tibmeister
Member
 
Registered: Oct 2003
Distribution: SLES 9.3
Posts: 40

Rep: Reputation: 15
PHP adduser


Okay, here's the script I have at the moment:

if (isset($HTTP_POST_VARS["submit"]))
{
for ($i = 0; $i < 9; $i++)
{
$tmp_rand = rand(48,90);
$salt_temp .= chr($tmp_rand);
}
$salt_2 = "$1$".substr($salt_temp,0,8)."$";
$salt .= "$1$".$salt_temp."$";
echo $salt."<br>".$salt_2."<br>";

$passwd = crypt($HTTP_POST_VARS["dpasswd"],$salt);
echo $passwd."<br>";
//

$cmd = "sudo /usr/sbin/adduser"; // Base Command
$cmd .= " -g pppusers"; // Group Setting
//$cmd .= " -p ".chr(34).$HTTP_POST_VARS["dpasswd"].chr(34); // Password
$cmd .= " -p ".chr(34).$passwd.chr(34);
$cmd .=" -c ".chr(34).$HTTP_POST_VARS["realname"].chr(34); // Comment section, IE Realname
$cmd .= " -s /sbin/nologin"; // Shell
$cmd .= " -d /home/pppusers/".$HTTP_POST_VARS["dusername"]; // Home Directory
$cmd .=" ".$HTTP_POST_VARS["dusername"]; // Username
$oput;
echo $cmd."<br>";
// $args = array("/usr/sbin/adduser","-g pppusers","-p ".$passwd,$HTTP_POST_VARS["dusername"],"-c ".$HTTP_POST_VARS["realname"]);

exec($cmd,$oput,$stdout);
if ($stdout == 0)
{
echo "Success";
}
else
{
foreach ($oput as $op)
{
echo $op."<br>";
}
echo $cmd;
}
}

As you can tell, I'm trying to add a user to the system, well, this works, all except the password portion. I can't get that to work quite right. This is a redhat 7.3 system (Why upgrade when things work nicely). Any ideas from the guru's?

Thanks,
Tibby
 
  


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
php adduser thru system() chetshot Linux - Software 1 05-02-2005 05:00 PM
php adduser chetshot Linux - Networking 1 05-02-2005 12:00 PM
sendmail adduser sbin/nologin using php mhatre kedar Linux - Networking 0 04-18-2005 01:12 AM
adduser bally Linux - General 7 08-09-2004 01:28 PM
Adduser... Chijtska Linux - General 5 02-15-2002 07:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:07 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration