The General Case
I'm trying to enable a user to run a sudo command (with arguments) without a password. I can get the NOPASSWD
directive to work, but only when the arguments don't contain quotation marks.
For example, this works:
# /etc/sudoers.d/sample
%sudo ALL=(ALL) NOPASSWD: /bin/echo foo
$ sudo echo foo
foo
But this doesn't, because quotation marks are interpreted literally:
# /etc/sudoers.d/sample
%sudo ALL=(ALL) NOPASSWD: /bin/echo "foo"
$ sudo echo "foo"
[sudo] password for rlue:
$ sudo echo \"foo\"
"foo"
My Specific Case
This is the command I'm trying to allow:
$ sudo sh -c 'echo XHCI > /proc/acpi/wakeup'
I actually got it to work with the following unquoted command:
%sudo ALL=(ALL) NOPASSWD: /bin/sh -c echo XHCI > /proc/acpi/wakeup
But since it calls out to sh -c
, and since I clearly don't understand precisely what's going on, I'd like to be extra explicit about what I'm allowing.
How can I specify quoting for command arguments in the sudoers file?
mv this that the other
is different frommv this that 'the other'
, and the unquoted syntax permits both. How can I be sure I haven't missed any edge cases?