Bug 403

Summary: Sudo initial login feature taints cwd
Product: Sudo Reporter: Matt Conway <wr0ngway>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED INVALID    
Severity: normal    
Priority: low    
Version: 1.7.0   
Hardware: Other   
OS: Linux   

Description Matt Conway 2010-04-08 22:42:58 MDT
At first I thought this was something to do with someone overriding the shell builtins, but below I use "builtin" to force use of shell builtin.

This prints "/" as expected:

~# sudo bash -c "builtin cd / && builtin pwd"
/

This should print "/", but doesn't:

~# sudo -i bash -c "builtin cd / && builtin pwd"
/root

This also prints "/", and works if I run any command other than "cd" as the first command:

~# sudo -i bash -c "builtin pwd && builtin cd / && builtin pwd"
/


This happens both on Ubuntu Linux 9.10 and Mac OS X, both running sudo v1.7.0
Comment 1 Todd C. Miller 2010-05-07 13:06:49 MDT
Sudo's -i flag changes the cwd to the target user's home directory, which appears to match the behavior you are seeing.