Alright, I almost have this working, was wondering if anyone could shed some light on this - I have a php script where new system users can be added from a webpage. They don't need shell access, just POP3 email. The problem is entering a password. I can call the 'useradd' program no problem, and it works, but of course no password gets installed. So, I wrote the script so that it creates a temp file, and calls the newusers program instead. However it doesn't work. I use 'sudo' to do this, and have set up the sudoers file correctly. The temp text file is created correctly, I verified this by going into the directory where it is placed and running 'newusers' manually - no problem.
For some reason the script will run useradd (if I replace '/usr/sbin/newusers /holddir/$usrname' with '/usr/bin/useradd $usrname') no problem, but not newusers - any ideas? Here's the script:
<?php
$newuserdata = ("$usrname:$usrpass::::/home/users/$usrname:\n");
$newuser = ("/holddir/$usrname");
$fw = fopen($newuser,"w");
fwrite($fw,$newuserdata);
exec("/usr/bin/sudo /usr/sbin/newusers /holddir/$usrname\n");
?>