Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to develop a PHP script to control some functions in my server. The server has VPS and I want to create a simple script which allows the root user of the VPS to reboot it, from a graphical interface instead of from shell access.
What I need is to compare the password the user enters in the PHP form, with the root passowrd from the /etc/shadow file he has in his VPS. Is there any method of converting a plain password to the shadow format so I can compare it to the one contained in the /etc/shadow file?
Is there any other (maybe more efective) way of doing this, without having to for example, create a table in mysql with users and passwords and check the login form against that information?
thank you wjevans for your reply. I had read some of the man pages, but not all of the three you mentioned. It doesn't help much about PHP, bue it does provide some necessary info.
Thank you Matir for your post, I had already found some info about the PHP needed to test the passwords, and although your solution provides correct result, it seems that the crypt function from PHP only needs the first 2 characters from the encrypted shadow password as salt to provide the correct encrypted pass.
Besides that, I figured out that I need suexec installed with apache and PHP in order to be able to read the /etc/shadow file.
It all seems to work now.
Yes, the VPSs have encrypted passwords that only use the 2 first characters. They run on Debian Sarge. I don't really know how to update that...
But now I'm having another problem...I can get the script to work if I type "php myscript.php" in the shell, bue if I go to the browser, I only get a 403 forbidden error...Any guess on why this is happening? Is my apache not working well with suexec?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.