看起来这个bug已经存在了很长时间!以下是一些有用的bug参考资料(您可能希望订阅/投票,提示,提示...):
Debian bug #85123(“sudo:SECURE_PATH仍然无法被覆盖”)(来自2001年!)
似乎Bug#20996仍然存在于此版本的sudo中。更改日志说它可以在运行时被覆盖,但我还没有发现如何做到。
他们提到在sudoers文件中放置类似于这样的内容:
Defaults secure_path="/bin:/usr/bin:/usr/local/bin"
但至少在Ubuntu 8.10中,当我这样做时,会出现以下错误:
visudo: unknown defaults entry `secure_path' referenced near line 10
Ubuntu bug #50797 ("使用--with-secure-path编译的sudo存在问题")
Worse still, as far as I can tell, it
is impossible to respecify secure_path
in the sudoers file. So if, for
example, you want to offer your users
easy access to something under /opt,
you must recompile sudo.
Yes. There needs to be a way to
override this "feature" without having
to recompile. Nothing worse then
security bigots telling you what's
best for your environment and then not
giving you a way to turn it off.
This is really annoying. It might be
wise to keep current behavior by
default for security reasons, but
there should be a way of overriding it
other than recompiling from source
code! Many people ARE in need of PATH
inheritance. I wonder why no
maintainers look into it, which seems
easy to come up with an acceptable
solution.
I worked around it like this:
mv /usr/bin/sudo /usr/bin/sudo.orig
then create a file /usr/bin/sudo containing the following:
#!/bin/bash
/usr/bin/sudo.orig env PATH=$PATH "$@"
then your regular sudo works just like the non secure-path sudo
Ubuntu bug #192651 ("sudo path is always reset")
鉴于这个 Bug 的副本最初是在 2006 年 7 月提交的,我不清楚无用的 env_keep 已经运行了多久。无论强制用户使用上述技巧的优点是什么,sudo 和 sudoers 的手册应反映修改 PATH 的选项事实上是多余的。
将文档修改以反映实际执行非破坏性而且非常有帮助。
Ubuntu bug #226595 ("impossible to retain/specify PATH")
我需要能够在 PATH 中运行其他非标准二进制文件夹的 sudo。当我已经将要求添加到 /etc/environment,并在 sudo 下运行时出现缺少命令的错误时,我感到非常惊讶.....
我尝试以下方法来解决此问题却没有成功:
使用“sudo -E
”选项-没有起作用。我的现有 PATH 仍然被 sudo 重置
将“Defaults env_reset
”更改为“Defaults !env_reset
”在 /etc/sudoers 中--也不起作用(即使与 sudo -E 结合使用)
取消注释 /etc/sudoers 中的 env_reset(例如,“#Defaults env_reset
”)--也不起作用。
将“Defaults env_keep += "PATH"
”添加到 /etc/sudoers -- 也不起作用。
显然,尽管手册如此说明,但 sudo 在 PATH 方面完全是硬编码的,不允许保留用户自己设置的 PATH。这非常令人恼火,因为我不能使用 sudo 以 root 权限运行非默认软件。