mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #46796 from terminalmage/issue46779
Fix regression introduced in merge-forward
This commit is contained in:
commit
4f31c1062d
2 changed files with 16 additions and 4 deletions
|
@ -443,7 +443,7 @@ def _run(cmd,
|
|||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE
|
||||
).communicate(salt.utils.stringutils.to_bytes(py_code))[0]
|
||||
).communicate(salt.utils.stringutils.to_bytes(py_code))
|
||||
marker_count = env_bytes.count(marker_b)
|
||||
if marker_count == 0:
|
||||
# Possibly PAM prevented the login
|
||||
|
@ -482,10 +482,11 @@ def _run(cmd,
|
|||
if env_runas.get('USER') != runas:
|
||||
env_runas['USER'] = runas
|
||||
env = env_runas
|
||||
except ValueError:
|
||||
except ValueError as exc:
|
||||
log.exception('Error raised retrieving environment for user %s', runas)
|
||||
raise CommandExecutionError(
|
||||
'Environment could not be retrieved for User \'{0}\''.format(
|
||||
runas
|
||||
'Environment could not be retrieved for user \'{0}\': {1}'.format(
|
||||
runas, exc
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -15,9 +15,11 @@ from tests.support.helpers import (
|
|||
skip_if_not_root
|
||||
)
|
||||
from tests.support.paths import TMP
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
|
@ -266,6 +268,15 @@ class CMDModuleTest(ModuleCase):
|
|||
runas=runas).strip()
|
||||
self.assertEqual(result, expected_result)
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'minion is windows')
|
||||
@skip_if_not_root
|
||||
def test_runas(self):
|
||||
'''
|
||||
Ensure that the env is the runas user's
|
||||
'''
|
||||
out = self.run_function('cmd.run', ['env'], runas='nobody').splitlines()
|
||||
self.assertIn('USER=nobody', out)
|
||||
|
||||
def test_timeout(self):
|
||||
'''
|
||||
cmd.run trigger timeout
|
||||
|
|
Loading…
Add table
Reference in a new issue