须藤E选项不起作用? [英] sudo E option does not work?

查看:176
本文介绍了须藤E选项不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,如果我写在 $ HOME /路径/到/脚本/的MyScript 出口PATH = $ PATH的shell脚本:$ HOME /路径/到/脚本/ 然后须藤-E的MyScript 要运行脚本的权

Seems to me that if I write a shell script in $HOME/path/to/script/myscript, and export PATH=$PATH:$HOME/path/to/script/ then sudo -E myscript should run the script right?

从sudo的手册页:

-E
  该-E(preserve环境)选项表示该用户希望preserve他们现有的环境变量的安全策略。如果指定了-E选项,并且用户没有权限preserve环境的安全策略可能会返回一个错误。

‑E The ‑E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the ‑E option is specified and the user does not have permission to preserve the environment.

须藤-E脚本找不到命令。我知道我可以再补充 /绝对/路径/到/脚本/ 来确定的 PATH 变量文件须藤ENV ,但是这不是我要采取的做法。

But sudo -E script can't find the command. I know I can just add /absolute/path/to/script/ to the files that determine the PATH variable for sudo env, but that's not the approach I want to take.

为了解决意见:结果
@ H2CO3 :我看到 sudo的须藤左右浮动净,它的错误我极大,它的字面意思说:给我超级用户的权限运行超级用户。我不知道这是否会解决这个问题,但它似乎是一个根本性的缺陷的方法。再然后,我开始使用Linux / BSD系统早在90年代中期,所以我拿的问题只用须藤命令本身。结果
@rici :脚本确实有可执行权限,但肯定的东西来检查时的东西并不在* nix系统运行=)

To address the comments:
@H2CO3: I have seen sudo sudo floating around the net, and it bugs me tremendously, it's literally saying "Give me superuser permissions to run superuser". I don't know if it would solve the problem, but it seems like a fundamentally flawed approach. Then again I started using linux/bsd systems back in the mid 90's so I take issue with just the sudo command itself.
@rici: The script does have executable permissions, but that's definitely something to check whenever something doesn't run in *nix systems =)

推荐答案

在/ etc /默认sudoers中有一个设置重置环境。并且还定义了一个默认secure_path这实际上当你执行sudo -E [CMD]。

/etc/sudoers by default has a setting to reset the environment. And also defines a default secure_path which is in effect when you run sudo -E [cmd].

您将需要编辑/ etc / sudoers文件,并添加env_keep,并提到你想要的变量preserve。

You will need to edit the /etc/sudoers file and add 'env_keep' and mention the variables you want to preserve.

默认env_keep + =PATH

Default env_keep += "PATH"

但出了secure_path行此评论前。然后通过sudo -E试试你的命令。

but before this comment out the secure_path line. Then try your command via sudo -E.

这篇关于须藤E选项不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆