Jump to content

PHP and Linux


dsartain

Recommended Posts

hey guys, I'm working on a php registration page that will update a DB with a users info...that part is easy

 

what is annoying is that the password they provide will also be used to access FTP.  Which means that I have to get php to modify the /etc/passwd file....or run system(passwd user)...any ideas on how to go about this??

Link to comment
Share on other sites

Spent a while looking into this....

 

For security it is odviously a bad idea to have your standard web user alter anything 'system critical'.  And edditing the /passwd file direct would definatly not be a good idea!

 

I have done it through the use of cron.  I have a root cron job (solves the privilages problem) which runs a php script as root.  This script looks for value in a database and used it to change the password.  This be it does using the shell_exec() function. 

 

Importantly for secutity, the part in the database in only a little bit of the comand run inside the shell_exec().  The rest is generic say:

 

$value = "passwd ".$oh;

shell_exex($value);

 

this meens that someone gets access to the database, they cannot insert direct comands for the server to run as root.

 

The biggest problem with the method shown above is that the server will ask for the password value twice, which this function cannot cope with.  This can be solved by sending an incripted password to the useradd linux comand.  This however requires something like a c scrip.  Long story short there is know easy way to do this.

 

 

Hope this helps..  Shout if i have explaind it in to much of a jumble!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.