July 25th, 2000, 04:50 AM
HI, does anybody know how to create a new Linux user account by PHP, so that only that user could go to his won account? I tried system("useradd xxx") but didn't work...did I forget anything? or are there any other ways to do that? Thanks!!
July 25th, 2000, 06:55 AM
Well, as you may know 'adduser' or 'useradd' require a touch more i/o than just 'useradd username'. For instance, it asks which type of shell you want, what you want for a password, and some other stuff (I usually run windows, so i'm unsure of what it asks specifically), and then asks to confirm the addition. I'm not sure exactly how to go about it, but if you know specifically what it asks, you can try to do something like this:
(P.S.: Remember n stands for new line, and r stands for carriage return (the push of the Enter key to confirm the choices made).)
To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson
July 25th, 2000, 02:33 PM
No easy way. Use man useradd to inform yourself about the various switches that useradd accepts and you will be able to use system() to call it.
But...as always with UNIX there is one huge BUT...You probably cannot even run it, because PHP runs under privileges same as Apache, and that is the user "nobody". You probably need yo run useradd as root, meaning you will have to write a small suid program to do this. I don't know how to do this in PHP...
And don't and I mean DON'T setup PHP to run as root, or useradd to be accessible by "nobody"...