Bugzilla – Bug 109
"sudo su -p" does not preserve the environment
Last modified: 2004-01-18 00:38:43 MST
According to the documentation for su, the "-p" option should preserve the environment variables `HOME', `USER', `LOGNAME',or `SHELL'. When executed from the login shell, these variables are preserved. When executed using sudo, 'HOME' is preserved, but 'USER' and 'LOGNAME' are set to 'root'.
Sudo sets USER and LOGNAME to the target user. If you don't want this, you can use a line like this in sudoers: Defaults !set_logname