mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2018.3' into 2018.3-sharedsecret
This commit is contained in:
commit
20db8f03f7
3 changed files with 23 additions and 5 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
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -172,9 +172,9 @@ def fire_args(opts, jid, tag_data, prefix=''):
|
|||
except NameError:
|
||||
pass
|
||||
else:
|
||||
tag = tagify(tag_suffix, prefix)
|
||||
try:
|
||||
_event = get_master_event(opts, opts['sock_dir'], listen=False)
|
||||
tag = tagify(tag_suffix, prefix)
|
||||
_event.fire_event(tag_data, tag=tag)
|
||||
except Exception as exc:
|
||||
# Don't let a problem here hold up the rest of the orchestration
|
||||
|
@ -201,6 +201,12 @@ def tagify(suffix='', prefix='', base=SALT):
|
|||
parts.extend(suffix)
|
||||
else: # string so append
|
||||
parts.append(suffix)
|
||||
|
||||
for index, _ in enumerate(parts):
|
||||
try:
|
||||
parts[index] = salt.utils.stringutils.to_str(parts[index])
|
||||
except TypeError:
|
||||
parts[index] = str(parts[index])
|
||||
return TAGPARTER.join([part for part in parts if part])
|
||||
|
||||
|
||||
|
|
|
@ -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