Bug 328

Summary: PATH not preserved in 1.6.9p19
Product: Sudo Reporter: Ben Lentz <ben.lentz>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED INVALID    
Severity: normal    
Priority: normal    
Version: 1.6.9   
Hardware: PC   
OS: AIX   

Description Ben Lentz 2009-01-26 09:20:45 MST
Platform: AIX 5.3.0 TL8 SP2
Version: sudo-1.6.9p19

The PATH variable should be preserved according to the output of "sudo sudo -V", but is not when any env_keep entry is present.

Everything looks good with the configuration and the -V output:

$ grep env_keep /etc/sudoers
Defaults                env_keep = "ODMDIR"
$ sudo sudo -V
Sudo version 1.6.9p19
--SNIP--
Environment variables to preserve:
--SNIP--
        PATH
--SNIP--

However, it does not appear to actually work:

$ echo $PATH; sudo sh -c "echo \$PATH"
/home/blentz/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/opt/pware/bin:/opt/local/bin
/usr/bin:/bin

But, if I remove env_keep for the unrelated ODMDIR variable (and, assuming env_reset is active, according to the documentation), PATH is properly preserved:

$ grep env_keep /etc/sudoers
#Defaults               env_keep = "ODMDIR"
$ echo $PATH; sudo sh -c "echo \$PATH"
/home/blentz/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/opt/pware/bin:/opt/local/bin
/home/blentz/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/opt/pware/bin:/opt/local/bin
Comment 1 Todd C. Miller 2009-01-26 10:31:11 MST
You are overriding the default set of variables to preserve.  What you want is:

Defaults                env_keep += "ODMDIR"

since you want to add ODMDIR to the list of things to preserve.
Comment 2 Ben Lentz 2009-01-26 11:41:33 MST
Ugh. You're right, my fault. I assumed that the sudo -V preserve list was a dynamically generated result set of the existing rules in the sudoers file.