Help passing argument to the command line 
Author Message
 Help passing argument to the command line

Hello,

I am writing a script that will allow a user to shut down and restart
a database automaticly via a perl script. However, in order to do
that, the user has to su to another user. I do not want to add the
users who need to shut down the databases to the dba group because
then they can do other dba admin stuff I don't want them to touch!!

I firstly rhought having the script su automaticly

system ("su $dbuser -c /path/shutdownscript");

but unless you are root, it will prompt me with a password. And like I
said, I don't want to give that password out.

Then I thought perhaps I could automaticly pass the password to su
from within the script (since su will not allow the password to be
entered as an argument), shut down the database and exit without the
common user ever having to know the dba password. But all attempts
have failed at that.

I need to know if what I am trying is possible... basicly to have perl
automaticly interact with a commands STDIN prompts. Any help is
appreciated!

SD



Mon, 24 Jul 2000 03:00:00 GMT  
 Help passing argument to the command line

[posted and mailed]

Quote:

> I am writing a script that will allow a user to shut down and restart
> a database automaticly via a perl script. However, in order to do
> that, the user has to su to another user. I do not want to add the
> users who need to shut down the databases to the dba group because
> then they can do other dba admin stuff I don't want them to touch!!

> [...ponderings about passing a password to su...]

> I need to know if what I am trying is possible... basicly to have perl
> automaticly interact with a commands STDIN prompts. Any help is
> appreciated!

Yes, by opening a pipe to the command.

But it's not what you want to do in this case.  What you want to do is
make a setuid script that will run as the more privileged user.

Read the perlsec manpage to find out about taint checking (done automatically
in setuid scripts).
Make the privileged user the owner of the script:   chown user script.pl
Set the setuid bit of the script:                   chmod u+s script.pl

Now, when someone runs your script, it will have the privileges of the owner,
instead of the person executing it.

Hope that helps!

Chipmunk



Wed, 26 Jul 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing form values back to a script as command line arguments

2. passing arguments on the command line to the script

3. passing command-line arguments to script !

4. Passing command line arguments to script

5. command line argument passing?

6. Help! with command line arguments

7. help w/command line argument

8. Need help with command line arguments

9. Command line argument help please

10. passing argument to system command

11. running perl at command line with arguments: script.cgi?text=text

12. Command line arguments.

 

 
Powered by phpBB® Forum Software