Linux – How to set both NOPASSWD and SETENV on the same line in sudoers

linuxsudo

In the sudoers file, how can I use multiple Tag_Specs on the same line.

Normally if I don't want to ask for a password I will do something like this:

who  where = (aswhom) NOPASSWD: commands

I want to use the SETENV tag so that users can preserve environment variables. This works fine like this:

who  where = (aswhom) SETENV: commands

From the sudoers(5) man page:

    Tag_Spec ::= ('NOPASSWD:' | 'PASSWD:' | 'NOEXEC:' | 'EXEC:' |
                  'SETENV:' | 'NOSETENV:' | 'LOG_INPUT:' | 'NOLOG_INPUT:' |
                  'LOG_OUTPUT:' | 'NOLOG_OUTPUT:')

I can't see how I can use multiple tags on the same entry. I would both like to use NOPASSWD and SETENV on the same line.

Best Answer

The same commands:

who  where = (aswhom) NOPASSWD:SETENV: commands

The different commands:

who  where = (aswhom) NOPASSWD: command1, SETENV: command2