Page 1 of 1

PHP linux user setup form

Posted: Thu Nov 06, 2003 5:19 am
by Jim_cliff11
Hi all

Im having a problem tryin 2 setup linux user accounts on my linux server.
What i want to do is create a form that creates a new user account on my linux box, with the username that they specify, then ill email them with the password. For example:-

First Name : Joe
last name : Bloggs
Email Address : joe_bloggs@domain.com
Username : Joe_bloggs

Those are just the basic fields i would use.

But once the user clicks submit, i need the linux server to execute the following commands:-

adduser joe_bloggs
chmod 777 /home/joe_bloggs
mkdir /home/joe_bloggs/public_html
chmod 777 /home/joe_bloggs/public_html

Then when that has created the account the user is displayed the message:-

"Thankyou for using briskfire.com your account has been created and your password will be emailed to you within 24 hours"

Then when i have made the changes i need to their account set password, permissions ect then i will email them with the password.

I need it to be secure as well, i dont want my server to be hacked.

Thanks i appriciate it.

Posted: Thu Nov 06, 2003 8:01 am
by Johnm
So,
What is it exactly that you are looking for? The code to do this or some help writng the code to do this?

John M

Posted: Thu Nov 06, 2003 11:05 am
by itbegary
Are you tying to do this from a web page? Creating the user from the web page with PHP is almost impossible without writing another process in the background that does most of the work for you.

If this statement is wrong please provide some code for doing it as I had the same question earlier this year.

Gary

web form

Posted: Thu Nov 06, 2003 2:33 pm
by Jim_cliff11
Yeh im tryin 2 create it on a webform. So that users just fill in the required info and their account is created.

What do u mean by some sort of background process?

Couldnt i just use the exec() command built into a php code?

Yes im looking for some coding help, to accomplish this

Thanks ppl

Jim

Posted: Thu Nov 06, 2003 4:57 pm
by itbegary
The problem is that using exec() you are running under the user that apache is running under. Because of this you can run the exec() and run a script but it won't be able to add a user (no enough permissions).

You could also go down a more dangerous path that won't work. You could set the sticky bit on a special copy of the PHP binary under the root user context and use this in a secondary script (which in theory would then execute as root) but we also tried this. No go.

Finally, you could compile apache with the "BIG_SECURITY_HOLE" or something like that parameter then have apache itself run as root. Please note, by doing so every script that everyone creates can execute any root command (including changing the root password). If you go this route please let us know the IP address so the group can have fun... :lol:

On a more serious note. We have had much lunch with creating a daemon that pulls records from a database. We discovered this while writing an accouting application. The daemon on each server reads a central database. This daemon runs under the root context and CAN add users. You use the web page to add the things to do to the database then your daemon picks up this and low and behold the user is added.

Hope this helps,

Gary Smith

Add linux user from PHP

Posted: Wed Dec 17, 2003 4:52 pm
by xavigonzalvo

Posted: Wed Dec 17, 2003 5:20 pm
by Weirdan
Why not use root cron job instead of writing daemon?

It's another way to do that

Posted: Fri Jan 02, 2004 6:44 am
by xavigonzalvo
I have a question.
How many times the cron should act to add a new user?
How long between actions?

I thought about it, and I preferred to do an action every time a user adds himself.

Posted: Fri Jan 02, 2004 7:15 am
by m3mn0n
I'd say a good number is once an hour, or maybe every half-hour.