mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
cmdmod.py: runas workaround for platforms that don't set a USER env var
Solaris doesn't set a USER env var in its default environment, that is if you run `su - someuser -c env` you get a HOME, PWD, LOGNAME, etc. env var, but not a USER. This commit makes sure that the USER env var is set to the runas user.
This commit is contained in:
parent
30fb8f7be0
commit
13cdb52690
@ -465,6 +465,10 @@ def _run(cmd,
|
||||
else:
|
||||
run_env = os.environ.copy()
|
||||
run_env.update(env)
|
||||
# Fix platforms like Solaris that don't set a USER env var in the
|
||||
# user's default environment as obtained above.
|
||||
if runas is not None and run_env.get('USER') != runas:
|
||||
run_env['USER'] = runas
|
||||
|
||||
if python_shell is None:
|
||||
python_shell = False
|
||||
|
Loading…
Reference in New Issue
Block a user