?
Solved

Change UNIX-Password with a CGI-Script

Posted on 1999-01-22
1
Medium Priority
?
242 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 450 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Six Sigma Control Plans

765 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