I'm creating a web-based free e-mail. One issue i'm considering very seriously is on how to add a user into the LInUX system. PHP can't call /usr/sbin/useradd because its the root that has an access to this command. So I wrote a PERL script. All it does is to read the mysql database and get some necessary info on the table. The table contains
username
password
shell
group
processed
When the user completed the signup, the php script inserts the users' record to the newsignup table and set the processed field to "N" which means its has not yet been processed by the perl script. The perl scripts
1. reads the records which are not yet processed (processed="N") and gets the fields;
executes the useradd with params username,password,shell, group..
update the record where username="username" setting processed ="Y" which means this record has been processed and added to the system.
delete the processed record from the table periodically. (processed="Y")
Now the problem is when the perl script upon executing a useradd command encounters an error like
user already exists
group not found.
etc.
I can't tell the php script that something is wrong... its possible not to update the record by not settign processed="Y". If this is the solution, my script will have to wait by iterating and executing sql to the table until processed = "Y" so that the user who just signup may know that the signup is successful. But, what if there are more than 100 person signed up all at the same time. The 100th person will have to wait... for some minutes.. before his record can be added to the system...
IS there any other suggestion on how i can accomplish the same job more effeciently ... ?
Jun