Praveen's Blog

An Eternal Quest for Incremental Improvement

Environment variable issues with "sudo" & "apt-get" duo

My debian laptop is connected to Internet directly at home and through a HTTP proxy at office. For handling apt-get, I was having a shell script which sets the HTTP_PROXY, http_proxy, FTP_PROXY, ftp_proxy environment variables to the approrpriate proxy server on demand and then I do sudo apt-get <whatever>. All were working fine till last upgrade. I think the recent upgrade of sudo or apt-get broke the way things were working. Now sudo apt-get <whatever> is not able to see the proxy and fails to resolve the debian repository host names. Doing a su and then running apt-get passes fine. This is really painful.

Update: After looking into the changelog for sudo, I have found that a env_reset which removes all enviroment variables (expect basic ones) to propogate. This is to address a recent vulneribilty announced in sudo. Now, I am overridding the defaults by adding this line to my sudoers.

Defaults:praveen    env_keep+="HTTP_PROXY http_proxy FTP_PROXY ftp_proxy"