sudoers和默认值


12

我需要允许用户在没有tty的情况下运行无密码的sudo。

我有一个/etc/sudoers.d/带有我所需的特殊命令和设置的文件,因为我不想直接编辑该sudoers文件。在该文件中,我具有以下内容:

# My list of commands that the user can run passwordless
myUser ALL=(ALL) NOPASSWD:SETENV: /foo/bar /foo/zaz
# My new defaults.
Defaults exempt_group = myUser
Defaults !env_reset,env_delete-=PATH
Defaults: myUser !requiretty

但是,当我su向用户运行时,sudo -l我得到的是默认值:

 Matching Defaults entries for myUseron this host:
    requiretty, !visiblepw, always_set_home, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION
    LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY", secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin, exempt_group=myUser,
    !env_reset, env_delete-=PATH, !requiretty

我可以看到的地方首先requiretty是my !requiretty,最后没有用。我认为发生这种情况是因为首先解析了普通sudoers文件,然后解析了我的自定义文件/etc/sudoers.d/

有没有一种方法可以在不编辑原始文件的情况下进行这项工作/etc/sudoers

Answers:


5

默认值的语法是这样(请参见man sudoers):

Default_Type ::= 'Defaults' |
                 'Defaults' '@' Host_List |
                 'Defaults' ':' User_List |
                 'Defaults' '!' Cmnd_List |
                 'Defaults' '>' Runas_List

User_List ::= User |
              User ',' User_List

所以在线

Defaults: myUser !requiretty

删除之间的空间Defaults:myUser

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.