Solved

Change UNIX-Password with a CGI-Script

Posted on 1999-01-22
1
236 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
ID: 1210242
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Uploading Binary Data using Perl 5 90
Perl script to parse log and delete the file 17 173
Which version of C should I use when Perl is too slow? 13 181
syslog unix file 20 73
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
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…

821 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