I'm creating a system that allow me to create users automatically after an inscription. In this way, i've made a Perl script that generate a random password, crypt it with "mkpasswd" and then create an user with "useradd", after that user-infos are sended to a database.
I've search documentation, and i've try to use the php exec function to call the Perl program.
$command = "/server/backoffice/scripts/usercreation.pl $username";
exec($command, $result);
print_r($result);
The usercreation.pl script work fine in a terminal, but for a unknown reason, it just not work from php, nothing happen, i know that the problem come from the useradd syntax or if not it come from the useradd command. The error value returned is 255 <=> 0xff <=> -1 .
I think the problem come from the --password option of useradd, in fact, this option use mkpasswd and maybe it could disturb the shell or something else like that :p
The complete useradd command used by the Perl program:
system("/usr/sbin/useradd $username -m -d $home --expiredate $expire --shell $shell --gid $gid --password $c_password");
EDIT: The usercreation.pl file on pastebin (has been truncated to the part we are investigate): http://pastebin.com/DgFdndXf
The php one : http://pastebin.com/pQhADNzg
The web server used is nginx/0.7.65.
The version of php used is PHP 5.3.3-1.
uname -a
Linux openco 2.6.35-32-generic #67-Ubuntu SMP Mon Mar 5 19:35:26 UTC 2012 i686 GNU/Linux
Thanks for all!