Bug 403 - Sudo initial login feature taints cwd
Sudo initial login feature taints cwd
Status: RESOLVED INVALID
Product: Sudo
Classification: Unclassified
Component: Sudo
1.7.0
Other Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-08 22:42 MDT by Matt Conway
Modified: 2010-05-07 13:06 MDT (History)
0 users

See Also:


Attachments

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