Change UNIX-Password with a CGI-Script
Posted on 1999-01-22
I would like to use a Perlscript to change a userpassword in the passwordfile. It is no problem to do that as root but the user wwwrun (Apache) has of course no access to that file. Needed is a CGI-Script that makes the usual checks before doing anything and if everything is ok, sets the new password into the systempasswordfile.
I have got a such script but it must be executed by root. It would be nessesary to change the userid to root during execution of this script.
I tried several things: setting the suid-bit to the script doesn't work, calling an other programm in the script with suid-bit set but nothing works.
It must be possible to change to an other userid. Every user can change his own password using passwd. This program also needs root permission to have access to the systempasswordfile.
It would be very helpful if somebody can give me a hint how to do this. In the script I have a UserID, his old password an a new password.
I'm using a Linux-Box with Apache 1.3.3