Merge pull request #22126 from s0undt3ch/2014.7

Update environment variables.
This commit is contained in:
Thomas S Hatch 2015-04-01 10:41:10 -06:00
commit 3001b727ef

View File

@ -303,6 +303,18 @@ def check_user(user):
os.setgid(pwuser.pw_gid) os.setgid(pwuser.pw_gid)
os.setuid(pwuser.pw_uid) os.setuid(pwuser.pw_uid)
# We could just reset the whole environment but let's just override
# the variables we can get from pwuser
if 'HOME' in os.environ:
os.environ['HOME'] = pwuser.pw_dir
if 'SHELL' in os.environ:
os.environ['SHELL'] = pwuser.pw_shell
for envvar in ('USER', 'LOGNAME'):
if envvar in os.environ:
os.environ[envvar] = pwuser.pw_name
except OSError: except OSError:
msg = 'Salt configured to run as user "{0}" but unable to switch.' msg = 'Salt configured to run as user "{0}" but unable to switch.'
msg = msg.format(user) msg = msg.format(user)