符号链接和 sudo 可执行文件

Ϲοδ*_*διϲ 4 linux centos sudo symbolic-link command-line

如果我有以下 sudoers 条目

usera ALL=(userb) NOPASSWD: /home/userc/bin/executable-file
usera ALL=(userb) NOPASSWD: /home/userc/bin/link-to-another-executable-file
Run Code Online (Sandbox Code Playgroud)

当我以 usera 身份登录并尝试运行以下命令时,它可以工作

sudo -u userb /home/userc/bin/executable-file
Run Code Online (Sandbox Code Playgroud)

不是下面的那个。

sudo -u userb /home/userc/bin/link-to-another-executable-file

Sorry, user usera is not allowed to execute '/home/userc/bin/link-to-another-executable-file' as userb on hostname.
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

msw*_*msw 5

当你说link-to-another-executable-file我假设你的意思是一个符号链接(否则它只是一个可执行文件)。

我怀疑 sudo 正在对符号链接的目标应用权限并且失败但将其报告为符号链接。它报告符号链接,因为这是您尝试执行的内容,因此该消息并不神秘。

如果是这种情况,则 sudo 正在做完全正确的事情:保护您免受谁知道符号链接另一端是什么的影响。您可以尝试在sudoers.