Solved

Change UNIX-Password with a CGI-Script

Posted on 1999-01-22
1
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…

756 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