0

I would like to add a list of commands for a admin user to sudo into by editing the /etc/sudoers file using Cmnd_Alias.

The below is working :

1.Cmnd_Alias CMD_LIST = /user/local/bin/srm, /bin/rm

2.admin ALL = NOPASSWD: CMD_LIST

But I have a list of nearly 20 commands to be added and specifying them by delimiting them by commas in line 1 seems clumsy .

For a cleaner script, I want to give a script (that echo's these commands ) as an input to the CMD_LIST like below but it's NOT working.

Cmnd_Alias CMD_LIST = $(/etc/sudo_command_list.sh)

admin ALL = NOPASSWD: CMD_LIST

The contents of the script is as below:

cat /etc/sudo_command_list.sh

echo "/user/local/bin/srm, /bin/rm"

I tried giving this list using a shell script as well as a file input, but cmnd_Alias didn't seem to take it

  • `cat anyFile` should just emit the contents of the file, so I don't see the need for `echo "` (and closing `"`). But I don't know about the syntax of `sudoers` file. Is `Cmnd_Alias` part of that syntax? Can you insert `echo $CMD_LIST` someplace to see if my theory about `echo "` is jamming things up? .... I'm out of ideas for now. Good luck! – shellter Apr 18 '23 at 21:10

0 Answers0