Bug 440

Summary: changes in 1.7.4 make sudo -H not usable
Product: Sudo Reporter: Elan Ruusamäe <glen>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: normal    
Priority: high    
Version: 1.7.4   
Hardware: PC   
OS: Other   
Attachments: Interoperability fix for HOME in env_keep and -H flag

Description Elan Ruusamäe 2010-09-14 16:16:19 MDT
the play that was started with 1.7.4 makes sudo unusable for me, i can no longer have two kind of shells, one where $HOME is preserved and other where $HOME is reset for target user.

seems -H is not functioning at all.

see also this mailing list post for problem report:
http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2010-August/021777.html

probably i could "detect" the situation on $SUDO_USER variable, and act on it, 
it wouldnt be so horrible, if it was just $HOME, but all kinds of user shell vars init depend on $HOME var, meaning these all needs to be overridden:

with:
Defaults env_keep += HOME

glen$ sudo -H -u builder bash -l
builder$ env | grep glen
TMPDIR=/home/glen/tmp
SUDO_USER=glen
SCREENDIR=/home/glen/.screen
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/home/glen/bin:/usr/games
PWD=/home/glen
HOME=/home/glen
TMP=/home/glen/tmp
HISTFILE=/home/glen/.history
Comment 1 Todd C. Miller 2010-09-14 16:36:42 MDT
Created attachment 293 [details]
Interoperability fix for HOME in env_keep and -H flag
Comment 2 Todd C. Miller 2010-09-14 16:37:40 MDT
I've attached a patch that is currently scheduled for sudo 1.7.5 that should address this.
Comment 3 Elan Ruusamäe 2010-09-14 16:43:05 MDT
that's a quick one! i'll test it right away! :)
Comment 4 Elan Ruusamäe 2010-09-14 17:08:42 MDT
great, seems work again!

with "Defaults env_keep += HOME" :

$ sudo env | grep HOME
HOME=/home/glen

$ sudo -H env | grep HOME
HOME=/root

$ sudo -i -H env | grep HOME
JAVA_HOME=/usr/lib/jvm/java
HOME=/root

$ sudo -V
Sudo version 1.7.4p4
(with the patch from this bug)
Comment 5 Todd C. Miller 2011-03-03 09:53:39 MST
Fixed in sudo 1.7.5 and 1.8.0.