On Nov 8, 2010, at 9:51 AM, Ryan May wrote:

> On Mon, Nov 8, 2010 at 8:34 AM, Philip Semanchuk <phi...@semanchuk.com> wrote:
>> Hi Ryan,
>> Thanks. I don't know why sudo behaves the way it does with regard to $HOME, 
>> but the behavior of sudo is not under my control (nor matplotlib's). Also, I 
>> expect that *lots* of software depends on this behavior of sudo so changing 
>> it is probably not an option.
>> 
> 
> Sounds like you've found your solution (which is great), but to set
> the record straight, you *can* control the behavior of sudo. In
> /etc/sudoers, you can set env_reset to reset the environment, so none
> of your variables (like $HOME). You can also just specify certain
> variables to be reset. There is also an option always_set_home which
> seems to do the right thing. In fact, on my machine, sudo works just
> fine:
> 
> ~> sudo python -c 'import os;print os.environ["HOME"]'
> /root
> 
> So, so long as you can edit /etc/sudoers, you are *very much* in
> control of how sudo works in this regard.


Thanks for the education, Ryan. 

I checked my Ubuntu 9.04 virtual install where I first saw this problem, and 
the contents of /etc/sudoers  are as described here:
https://help.ubuntu.com/community/Sudoers#The%20Default%20Ubuntu%20Sudoers%20File

Sure enough, $HOME isn't altered by sudo:
~$ sudo python -c 'import os;print os.environ["HOME"]'
/home/philip

I observe the same under OS X, so this configuration of /etc/sudoers might not 
be ideal, but it's popular.


Thanks
P


------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to