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
https://forums.phpfreaks.com/topic/37376-php-and-linux/
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
https://forums.phpfreaks.com/topic/37376-php-and-linux/#findComment-180921
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.