PHP linux user setup form

Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...

Moderator: General Moderators

Post Reply
Jim_cliff11
Forum Newbie
Posts: 7
Joined: Mon Nov 03, 2003 7:05 am

PHP linux user setup form

Post 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.
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post 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
itbegary
Forum Commoner
Posts: 34
Joined: Sun Jan 05, 2003 2:50 am

Post 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
Jim_cliff11
Forum Newbie
Posts: 7
Joined: Mon Nov 03, 2003 7:05 am

web form

Post 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
itbegary
Forum Commoner
Posts: 34
Joined: Sun Jan 05, 2003 2:50 am

Post 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
xavigonzalvo
Forum Newbie
Posts: 2
Joined: Wed Dec 17, 2003 4:52 pm

Add linux user from PHP

Post by xavigonzalvo »

User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Why not use root cron job instead of writing daemon?
xavigonzalvo
Forum Newbie
Posts: 2
Joined: Wed Dec 17, 2003 4:52 pm

It's another way to do that

Post 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.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I'd say a good number is once an hour, or maybe every half-hour.
Post Reply