iSteve Posted January 18, 2021 Posted January 18, 2021 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?
interele Posted February 9, 2021 Posted February 9, 2021 Can I ask, what are you trying to delete ? Mal
iSteve Posted February 10, 2021 Author Posted February 10, 2021 The script basically deletes previous users' settings on log out. It needs root privs to be able to do this.
interele Posted February 10, 2021 Posted February 10, 2021 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 1
iSteve Posted March 9, 2021 Author Posted March 9, 2021 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now