Linux sudo 未读取 /etc/sudoers.d 文件中的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21640770/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:58:32  来源:igfitidea点击:

File in /etc/sudoers.d file not being read by sudo

linuxfilenamessudoers

提问by Rick

I want to add a user in the sudoers file and I don't want to touch the original /etc/sudoersfile, so I added a new file under directory /etc/sudoers.d.

我想在sudoers文件中添加一个用户,又不想碰原/etc/sudoers文件,所以在目录下添加了一个新文件/etc/sudoers.d

The interesting thing is about the name of the newly added file. Initially, I named the file as sudoers.local, the file never got effective; then I renamed the file as customize, it got effective immediate. The file name sudoers.customizedoesn't work either. It seems any file name containing sudoersdoesn't work. Someone know the reason? In all three cases, the file has the proper permission -r--r-----.

有趣的是关于新添加文件的名称。最初,我将文件命名为sudoers.local,该文件从未生效;然后我将文件重命名为customize,它立即生效。文件名sudoers.customize也不起作用。似乎任何包含的文件名sudoers都不起作用。有人知道原因吗?在所有三种情况下,文件都具有适当的权限-r--r-----

The OS is 64 bits CentOS 6.5.

操作系统是 64 位 CentOS 6.5。

采纳答案by Jim Garrison

From the sudoers man page:

sudoers 手册页

The #includedir directive can be used to create a sudo.d directory that the system package manager can drop sudoers rules into as part of package installation. For example, given:

#includedir 指令可用于创建 sudo.d 目录,系统包管理器可以将 sudoers 规则作为包安装的一部分放入该目录。例如,给定:

#includedir /etc/sudoers.d

sudo will read each file in /etc/sudoers.d, skipping file names that end in ‘~' or contain a ‘.' characterto avoid causing problems with package manager or editor temporary/backup files.

sudo 将读取 /etc/sudoers.d 中的每个文件,跳过以“~”结尾或包含“.”的文件名。字符以避免导致包管理器或编辑器临时/备份文件出现问题。