Solved

Change UNIX-Password with a CGI-Script

Posted on 1999-01-22
1
229 Views
Last Modified: 2008-02-01
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
Thomy
0
Comment
Question by:Thomy
1 Comment
 

Accepted Solution

by:
robert_mann earned 150 total points
Comment Utility
You can do this with perl and expect.  Expect if you are not familiar with it is a program that basically will allow you to send commands based on responses.  For instance you could execute expect from within perl and have expect spawn sh and wait for the response such as # then it could su and wait for a password response then send the password and wait for the shell to respond with another # (or whatever) then execute passwd username and wait for a password response and then enter the password and wait for the reenter password response then renter it and then exit exit to exit the shell and return control back to your perl script.  Expect is available as a seperate program or you can get a perl module that allows you to do expect like commands from within perl.  The expect language is easy to understand and may be your best bet but either way it would solve your problem.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now