Help Writing Sudoers Command Alias Complex Command
by danmartinj from LinuxQuestions.org on (#52C3J)
Hello All,
I have been trying to figure out how to get a complex command to work in the sudoers file over the past couple days using visudo but have failed and I do not know what else to try.
Basically, the command I want to work is this:
Code:lsmod | grep -q _conntrack_ipv4 && iptables -L -n -v -t natAnd a couple others but I figure if I can get at least one to work the others will not be so hard.
I have a test user created and can get some other commands to work with sudo such as:
Code:testuser ALL = (root) NOPASSWD: /usr/bin/cat /sys/kernel/debug/x86/pti_enabled, /usr/sbin/dmidecodeHowever, for the more complex commands I need to get to work it does not. I have tried using things like wild cards (*), played around with using quotes (" commandline args ..."), and etc but looking in the log files it looks like it is only seeing just the initial command before the pipe and nothing else:
Code:sudo: testuser : TTY=pts/1 ; PWD=/home/testuser ; USER=root ; COMMAND=/sbin/lsmodSo, perhaps someone else can provide me some advise or help as it would be greatly appreciated right now.
Thanks,
Joe


I have been trying to figure out how to get a complex command to work in the sudoers file over the past couple days using visudo but have failed and I do not know what else to try.
Basically, the command I want to work is this:
Code:lsmod | grep -q _conntrack_ipv4 && iptables -L -n -v -t natAnd a couple others but I figure if I can get at least one to work the others will not be so hard.
I have a test user created and can get some other commands to work with sudo such as:
Code:testuser ALL = (root) NOPASSWD: /usr/bin/cat /sys/kernel/debug/x86/pti_enabled, /usr/sbin/dmidecodeHowever, for the more complex commands I need to get to work it does not. I have tried using things like wild cards (*), played around with using quotes (" commandline args ..."), and etc but looking in the log files it looks like it is only seeing just the initial command before the pipe and nothing else:
Code:sudo: testuser : TTY=pts/1 ; PWD=/home/testuser ; USER=root ; COMMAND=/sbin/lsmodSo, perhaps someone else can provide me some advise or help as it would be greatly appreciated right now.
Thanks,
Joe