HOME environmental variable no long preserved with sudo by default

Bug #760140 reported by Brian Murray
38
This bug affects 6 people
Affects Status Importance Assigned to Milestone
sudo (Ubuntu)
Fix Released
Medium
Steve Langasek
Natty
Fix Released
Medium
Steve Langasek

Bug Description

Binary package hint: sudo

As discussed on ubuntu-devel in February https://lists.ubuntu.com/archives/ubuntu-devel/2011-February/032490.html:

sudo sh -c 'echo $HOME'

no longer returns the current users home directory rather it returns /root. This is a change in behavior from Maverick which kept $HOME.

The following debian bug contains information about why this is happening now - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=596847. " The HOME and MAIL environment variables are now reset based on the target user's password database entry when the env_reset sudoers option is enabled (which is the case in the default configuration)."

Something should be done to ensure there isn't a regression and that $HOME is preserved by default.

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: sudo 1.7.4p4-5ubuntu5
ProcVersionSignature: Ubuntu 2.6.38-8.41-server 2.6.38.2
Uname: Linux 2.6.38-8-server x86_64
NonfreeKernelModules: btrfs zlib_deflate libcrc32c ufs qnx4 hfsplus hfs minix ntfs vfat msdos fat jfs xfs exportfs reiserfs nls_utf8 isofs nfs lockd fscache nfs_acl auth_rpcgss sunrpc snd_hrtimer binfmt_misc usblp autofs4 dm_crypt snd_emu10k1_synth snd_emux_synth snd_seq_virmidi snd_seq_midi_emul snd_emu10k1 snd_hda_codec_hdmi snd_hda_codec_idt snd_hda_intel snd_ac97_codec snd_hda_codec ac97_bus snd_pcm snd_util_mem snd_hwdep snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer snd_seq_device snd soundcore snd_page_alloc netconsole configfs firewire_sbp2 emu10k1_gp lp gameport parport psmouse serio_raw joydev dcdbas raid10 raid456 async_pq async_xor async_memcpy async_raid6_recov raid6_pq async_tx raid0 multipath linear dm_raid45 xor raid1 hid_logitech ff_memless hid_microsoft usbhid hid usb_storage uas firewire_ohci firewire_core crc_itu_t radeon ahci libahci ttm drm_kms_helper e1000e drm i2c_algo_bit
Architecture: amd64
CheckboxSubmission: fee5e196cb921cbd36888f428b38b488
CheckboxSystem: 2a6f54df59af338184485e85cbcf0d32
Date: Wed Apr 13 11:23:27 2011
ProcEnviron:
 LANGUAGE=en_US:en
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/zsh
SourcePackage: sudo
UpgradeStatus: Upgraded to natty on 2011-04-10 (2 days ago)

Revision history for this message
Brian Murray (brian-murray) wrote :
tags: added: regression-release
Revision history for this message
Steve Langasek (vorlon) wrote :

Regression in behavior vs. maverick; the Debian maintainer already tried to fix this once but it appears the fix was incomplete.

Changed in sudo (Ubuntu):
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → Steve Langasek (vorlon)
Revision history for this message
Brian Murray (brian-murray) wrote :

Testing sudo 1.7.4p4-5ubuntu5 I observed the following which seems correct to me as it matches the behavior on Maverick.

13:01:31 - flash:[/scratch] sudo sh -c 'echo $HOME'
[sudo] password for bdmurray:
/home/bdmurray
13:01:40 - flash:[/scratch] sudo -E sh -c 'echo $HOME'
/home/bdmurray
13:03:14 - flash:[/scratch] sudo -H sh -c 'echo $HOME'
/root
13:03:20 - flash:[/scratch] sudo -i
root@flash:~# echo $HOME
/root

Revision history for this message
Brian Murray (brian-murray) wrote :

I seem to have mispasted the version I tested with:

13:08:28 - flash:[/tmp] apt-cache policy sudo
sudo:
  Installed: 1.7.4p4-5ubuntu6
  Candidate: 1.7.4p4-5ubuntu6
  Version table:
 *** 1.7.4p4-5ubuntu6 0
        100 /var/lib/dpkg/status
     1.7.4p4-5ubuntu5 0
        500 http://archive.ubuntu.com/ubuntu/ natty/main amd64 Packages

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package sudo - 1.7.4p4-5ubuntu6

---------------
sudo (1.7.4p4-5ubuntu6) natty; urgency=low

  * debian/patches/keep_home_by_default.patch: Set HOME in
    initial_keepenv_table. LP: #760140
 -- Steve Langasek <email address hidden> Wed, 13 Apr 2011 12:32:25 -0700

Changed in sudo (Ubuntu Natty):
status: Fix Committed → Fix Released
joopbraak (joopbraak)
summary: - HOME enviornmental variable no long preserved with sudo by default
+ HOME environmental variable no long preserved with sudo by default
Revision history for this message
V字龍(Vdragon) (vdragon) wrote :

I personally believe that the decision of adding this patch is wrong, please refer Bug #1373495.

Revision history for this message
Zhang Youfu (zhangyoufu) wrote :

I'm expecting the documented behavior. Please refer Bug #889936

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.