Jump to content

Current user running a script as root (NOPASSWD)


Recommended Posts

Posted

Hello,

 

I need a general user to be able to run a script which requires root privileges. The script executes on log out, and deletes some folders. The deletion part is what requires root privs.

 

I have edited my sudoers file using visudo, and added a line at the end

ALL ALL=NOPASSWD: /path/to/script

...which I believe should allow all users to execute the specific script without it prompting for a password to be entered, however, when I test the script in a terminal window as the current user, the prompt asks for a password to be entered. It seems like the line I have entered in visudo/sudoers is being ignored.

 

How can I resolve this?

  • 4 weeks later...
Posted

Hmm.. but if you did is as the user then the previous user would have deleted their own settings when they logged out anyway.

 

I'm a bit old fashoined. I think allowing someone to delete someone elses stuff is fundamentally wrong. I know if my settings

were deleted by someone else I'd be really miffed.

 

I know I might sound a bit picky but this seems to be an accident waiting to happen.

 

If you really want to do it, I thought it's like this:-

 

ALL ALL=(root) NOPASSWD: /path/to/your/script.sh

 

YMMV having never done it - test with care :-)

 

Mal

  • Thanks 1
  • 4 weeks later...
Posted

Thanks Mal. This is in a school environment where there is a requirement to remove temporary settings on logout, so it's perfectly fine.

 

For the visudo command if the line for my NOPASSWD is for the current user, or ALL, the line is ignored. It's at the end of the file so that it is run last. Running my script always results in a Permission Denied message. Manually su'ing to root, the script runs. I don't understand why the lines in the file are being ignored.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...