/etc/environment 并不适用于 Debian Jessie 上的所有用户

/etc/environment 并不适用于 Debian Jessie 上的所有用户

我刚刚安装了 Debian 8.6。我想为所有用户设置 http 代理环境变量,所以我/etc/environment按照以下指南进行编辑Debian 的维基。但是,重新启动后,仅设置 root 用户的环境变量。

这是我的/etc/environment内容:

http_proxy=http://localhost:8123/
https_proxy=http://localhost:8123/
ftp_proxy=http://localhost:8123/
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
HTTP_PROXY=http://localhost:8123/
HTTPS_PROXY=http://localhost:8123/
FTP_PROXY=http://localhost:8123/
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"

我通过以下方式检查结果:

echo $http_proxy

当使用 root 以 root 身份登录时sudo su,它会给出正确的结果(http://localhost:8123/),但是当使用普通用户时,不会设置变量。我还使用 . 检查所有环境变量env

更新:

更多的测试来了。

我添加SET_BY_ETC_ENVIRONMENT="hello"/etc/environmentexport SET_BY_ETC_PROFILE="hello"/etc/profileexport SET_BY_HOME_PROFILE="hello"/home/perqin/.profile

结果如下:

user   | login via                    | SET_BY_ETC_ENVIRONMENT | SET_BY_ETC_PROFILE | SET_BY_HOME_PROFILE
-------|------------------------------|------------------------|--------------------|--------------------
perqin | GUI                          | no                     | no                 | no
root   | GUI                          | no                     | no                 | no
perqin | sudo su in terminal from GUI | yes                    | no                 | no
root   | su in terminal from GUI      | yes                    | no                 | no
perqin | ssh                          | yes                    | yes                | yes
root   | ssh                          | yes                    | yes                | no

所以profile只是在ssh登录时执行。而且它们都没有在 GUI 中应用!我正在使用 Debian 8.6 和 LXDE 桌面环境。

更新12.14

的输出grep pam_env /etc/pam.conf /etc/pam.d/*如下:

/etc/pam.d/atd:auth required    pam_env.so
/etc/pam.d/cron:# Read environment variables from pam_env's default files, /etc/environment
/etc/pam.d/cron:# and /etc/security/pam_env.conf.
/etc/pam.d/cron:session       required   pam_env.so
/etc/pam.d/cron:session       required   pam_env.so envfile=/etc/default/locale
/etc/pam.d/lightdm:# Load environment from /etc/environment and ~/.pam_environment
/etc/pam.d/lightdm:auth      required pam_env.so envfile=/etc/default/locale
/etc/pam.d/lightdm-autologin:# Load environment from /etc/environment and ~/.pam_environment
/etc/pam.d/lightdm-autologin:auth      required pam_env.so envfile=/etc/default/locale
/etc/pam.d/lightdm-greeter:# Load environment from /etc/environment and ~/.pam_environment
/etc/pam.d/lightdm-greeter:auth      required pam_env.so envfile=/etc/default/locale
/etc/pam.d/login:# file /etc/security/pam_env.conf.
/etc/pam.d/login:session       required   pam_env.so readenv=1
/etc/pam.d/login:session       required   pam_env.so readenv=1 envfile=/etc/default/locale
/etc/pam.d/polkit-1:session       required   pam_env.so readenv=1 user_readenv=0
/etc/pam.d/polkit-1:session       required   pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
/etc/pam.d/sshd:# /etc/security/pam_env.conf.
/etc/pam.d/sshd:session    required     pam_env.so # [1]
/etc/pam.d/sshd:session    required     pam_env.so user_readenv=1 envfile=/etc/default/locale
/etc/pam.d/su:# file /etc/security/pam_env.conf.
/etc/pam.d/su:session       required   pam_env.so readenv=1
/etc/pam.d/su:session       required   pam_env.so readenv=1 envfile=/etc/default/locale

相关内容