Leopard, sudo, proxies and environment variables
April 3rd, 2009 by robg
Wow, just ran into this problem. The sudoers file on leopard has some new settings as default, which means that if you have environment variables set, they will not be inherited as superuser unless they are explicitly set.
# Defaults specification
Defaults env_reset
Defaults env_keep += "BLOCKSIZE"
Defaults env_keep += "COLORFGBG COLORTERM"
Defaults env_keep += "__CF_USER_TEXT_ENCODING"
Defaults env_keep += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE"
Defaults env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"
Defaults env_keep += "LINES COLUMNS"
Defaults env_keep += "LSCOLORS"
Defaults env_keep += "SSH_AUTH_SOCK"
Defaults env_keep += "TZ"
Defaults env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"
Defaults env_keep += "EDITOR VISUAL"
At work I am behind a proxy, commands run as root from the terimnal are not inheriting my terminals proxy settings. MacPorts was failing.
There are 2 solutions.
Explicitly state the environment variable in the command line:
$ sudo env http_proxy=http://proxy.url:port/ command
or, add the environmant variable "http_proxy" to the list in /etc/sudoers.
Posted in Uncategorized