View Single Post
  #5   (View Single Post)  
Old 7th September 2010
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

You might consider a couple of additional man pages:

From su(1):
Quote:
By default, the environment is unmodified with the exception of LOGNAME,
HOME, SHELL, and USER. HOME and SHELL are set to the target login's
default values. LOGNAME and USER are set to the target login, unless the
target login has a user ID of 0 and the -l flag was not specified, in
which case it is unmodified. The invoked shell is the target login's.
This is the traditional behavior of su.
and a command you may not have considered, sudo(8), which has significantly more capability than su. You can set the environment variables you want carried over, or not, by configuration file. And then, you can even override them, as described here for the -E operand:
Quote:
The -E (preserve environment) option will override the
env_reset option in sudoers(5)). It is only available when
either the matching command has the SETENV tag or the
setenv option is set in sudoers(5).
Of course, you'll want to read sudoers(5) as well.
Reply With Quote