You are not logged in.
Pages: 1
I have been trying to solve what ought to be a fairly easy problem for a while now, but research both on google and here on the Arch forums/wiki has yet to turn up a solution.
I am trying to disable sudo prompts for all the scripts in a given directory. This is my /etc/sudoers file:
## Aliases
Cmnd_Alias RCHIPMANSCRIPTS = /home/rchipman/scripts/*
## User Privilege Specification
root ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
rchipman ALL=(ALL) NOPASSWD: RCHIPMANSCRIPTS But for some reason, it still prompts for a password when I try to run a script in that directory. Trying to specify a particular script is similarly unsuccessful:
## Aliases
Cmnd_Alias RCHIPMANSCRIPTS = /home/rchipman/scripts/backlight.sh
## User Privilege Specification
root ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
rchipman ALL=(ALL) NOPASSWD: RCHIPMANSCRIPTS However, disabling all sudo prompts for my account does work:
## Aliases
Cmnd_Alias RCHIPMANSCRIPTS = /home/rchipman/scripts/*
## User Privilege Specification
root ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
rchipman ALL=(ALL) NOPASSWD: ALLCan anyone spot an error here? Thanks in advance for the help!
Last edited by rchipman (2014-07-14 19:12:23)
Offline
Is that the entire contents of your sudoers file?
If not can you post the exact file when it's not working (I have an idea but need to see your sudoers file).
Offline
That is the entirety of my sudoers file -- nothing else in there to muck it up yet
Offline
Based on my limited understanding of the sudoers syntax, it seems like that should work. But try commenting out the wheel entry and doing all privileges by your username eg.
## Aliases
Cmnd_Alias RCHIPMANSCRIPTS = /home/rchipman/scripts/*
## User Privilege Specification
root ALL=(ALL) ALL
#%wheel ALL=(ALL) ALL
rchipman ALL=(ALL) ALL, NOPASSWD: RCHIPMANSCRIPTSBut whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
Sorry, no help from me then.
Just FYI the sudoers file is very specific about the order of its entries, I wanted to check that yours were in the correct order but as your rchipman entry is already at the bottom then it's correct.
Last edited by Slithery (2014-07-14 18:10:51)
Offline
Could there be some issue with the alias or the format of the filepath? As far as I can tell that is correct as well, but I just don't understand why NOPASSWD: ALL works while nopasswd for a given folder or script will not.
Offline
Offline
@slithery
Just opening a new session (new vterm or tab) should be all that's necessary.
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
Try this...
rchipman ALL=(ALL) NOPASSWD: /home/rchipman/scripts/Last edited by Slithery (2014-07-14 18:31:14)
Offline
I'm not sure if it will make a difference, but your use fits much better to the description of a Cmnd_List than Cmnd_Alias from the man page.
But more on point, do these scripts take parameters? Do scripts that do not require parameters work?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Nope, removing the * doesn't seem to change anything... neither does skipping the alias and writing the path right after the NOPASSWD
Last edited by rchipman (2014-07-14 18:34:22)
Offline
I tested something similar to OP's example and it worked:
## Aliases
Cmnd_Alias FOOBAR = /home/testing/bin/test.sh
## User Privilege Specification
root ALL=(ALL) ALL
%users ALL=(ALL) ALL
testing ALL=(ALL) NOPASSWD: FOOBARI used users group because I'm not in wheel.
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
Cmnd_List seems to have no effect here.
The scripts I have been using do take options. However, I wrote a quick one with no options, and was still prompted for as password.
For reference, the script I used to test this:
#!/bin/bash
sudo pacman -Ss testOffline
You are actually running 'sudo ./myscript.sh' and not just './myscript.sh' aren't you?
Last edited by Slithery (2014-07-14 18:57:50)
Offline
There should be no "sudo" in that script - I think slithery might have nailed the problem.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
No....and that was the problem! First of all, thanks for all the help, and sorry that this was apparently a very simple mistake on my part.
But I would like to better understand why exactly sudo is necessary when executing the script. I realize now that the sudoers file is disabling password prompts for sudo calls to /home/rchipman/scripts/* as opposed to from scripts in that directory. But if sudo (as I understand it) is executing that script as root, why is sudo still necessary within the script itself? These kinds of nuances trip me up from time to time, and I would like to learn exactly why this is so so that I do not make the same mistakes going forward.
Offline
But if sudo (as I understand it) is executing that script as root, why is sudo still necessary within the script itself?
As Trilby said, it isn't.
Offline
if sudo (as I understand it) is executing that script as root, why is sudo still necessary within the script itself
It shouldn't be - hence my previous post. It really shouldn't do any harm either - but it can lead to confusion.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks!
Offline
Pages: 1