mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #22126 from s0undt3ch/2014.7
Update environment variables.
This commit is contained in:
commit
3001b727ef
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user