Solved

Change UNIX-Password with a CGI-Script

Posted on 1999-01-22
1
239 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

734 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