Bug 328 - PATH not preserved in 1.6.9p19
PATH not preserved in 1.6.9p19
Status: RESOLVED INVALID
Product: Sudo
Classification: Unclassified
Component: Sudo
1.6.9
PC AIX
: normal normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-01-26 09:20 MST by Ben Lentz
Modified: 2009-01-26 11:41 MST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.