Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


A root script that others can run

A root script that others can run

A root script that others can run

I have a script owned by root which does various things including running 'rmuser -p' and 'su - <another user>'. I can run this script as root and it works fine. I thought that to be able to let others run it I could set the permissions using an ACL file and specifying the userid's I need to be able to run it. The permissions on the file are as follows:
 -r-s--x--x   1 root     system    rmuser_pms.sh

But on testing it out running it as one of the ACL userid's, rmuser won't execute and when running su it prompts for a password.

Any ideas on how to get this working or is it even possible ?

RE: A root script that others can run

It would probably benefit you to install 'sudo'. This is highly configurable and allows users to run scripts 'as root'. You can define who is allowed to run what.



RE: A root script that others can run

you cannot make a script suided. To deal with this , you need to have an executable which is suided to call the script. You could write a fairly simple C program which calls this script and put the s bit on the compiled program


RE: A root script that others can run

Dave, I think you are correct. I remember seeing that before. By writing a C program, compiling it and then attaching the ACL rights to this script which calls my shell script it will run. I'll have to look up the old C books. Thanks !

RE: A root script that others can run

Ok, I've written a c program which has compiled and it runs the script successfully. 'rmuser' within the script runs grand but the 'su - <other userid>' doesn't. It's still prompting for a password. Any ideas ?

RE: A root script that others can run


main() {
       char user_name[20];
       char cmd[40];

       printf("Enter user to su or remove: ");
       sprintf(cmd,"/usr/bin/rmuser %s", user_name);

Your compile may balk that gets is unsafe, but this is a quick and dirty c program to do what you want. It could be further enhanced to check the user to see if they are allowed to execute it and could/should include error checking.

RE: A root script that others can run

I just added setuid(0) to my existing script and that did the trick. Many thanks to all !

RE: A root script that others can run

I would agree with alexhu, sudo is an easy and highly configurable solution to this problem.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close