是否有一种方法可以让sudoers条目只允许执行特定的命令,而不需要任何额外的参数?我似乎找不到描述命令匹配如何与sudoers一起工作的资源。
假设我想为/path/to/executable arg授予sudo。
是否有如下所示的条目:
user ALL=(ALL) /path/to/executable arg
严格地允许sudo访问与此完全匹配的命令?也就是说,它不为/path/to/executable arg arg2授予用户sudo特权?
发布于 2012-10-18 06:59:56
在man sudoers中,我发现了下面的Cmnd_List定义:
A simple filename allows the user to run the command with any arguments
he/she wishes. However, you may also specify command line arguments
(including wildcards). Alternately, you can specify "" to indicate
that the command may only be run without command line arguments.这似乎意味着特别允许"arg“将不允许"arg arg2”。另一方面,我在不同的OSes (例如,Linux)上处理sudoers文件的方式上看到了一些不一致的地方。所以你应该测试你自己的环境。
其中一种方法有点难看:创建一个单独的可执行脚本,它只使用所需的参数运行指定的命令,并授予sudo对该脚本的访问权,而不是对原始命令的访问。
#!/bin/bash
/path/to/executable arghttps://serverfault.com/questions/439695
复制相似问题