mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #47647 from rallytime/bp-47601-and-47643-2018.3.1
Back-port #47601 and #47643 to 2018.3.1
This commit is contained in:
commit
9039fee104
1 changed files with 23 additions and 0 deletions
|
@ -41,6 +41,7 @@ import salt.utils.platform
|
|||
import salt.utils.versions
|
||||
import salt.utils.win_dacl
|
||||
import salt.utils.win_functions
|
||||
import salt.utils.win_runas
|
||||
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
|
@ -48,6 +49,26 @@ from salt.exceptions import CommandExecutionError
|
|||
from salt.ext import six
|
||||
|
||||
|
||||
def can_runas():
|
||||
'''
|
||||
Detect if we are running in a limited shell (winrm) and are un-able to use
|
||||
the runas utility method.
|
||||
'''
|
||||
if salt.utils.is_windows():
|
||||
try:
|
||||
salt.utils.win_runas.runas(
|
||||
'cmd.exe /c echo 1', 'noexistuser', 'n0existp4ss',
|
||||
)
|
||||
except WindowsError as exc: # pylint: disable=undefined-variable
|
||||
if exc.winerror == 5:
|
||||
# Access Denied
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
CAN_RUNAS = can_runas()
|
||||
|
||||
|
||||
class VirtualEnv(object):
|
||||
def __init__(self, test, venv_dir):
|
||||
self.venv_dir = venv_dir
|
||||
|
@ -274,6 +295,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
|
||||
@destructiveTest
|
||||
@skip_if_not_root
|
||||
@skipIf(not CAN_RUNAS, 'Runas support required')
|
||||
@with_system_user('issue-6912', on_existing='delete', delete=True,
|
||||
password='PassWord1!')
|
||||
@with_tempdir()
|
||||
|
@ -317,6 +339,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
|
||||
@destructiveTest
|
||||
@skip_if_not_root
|
||||
@skipIf(not CAN_RUNAS, 'Runas support required')
|
||||
@with_system_user('issue-6912', on_existing='delete', delete=True,
|
||||
password='PassWord1!')
|
||||
@with_tempdir()
|
||||
|
|
Loading…
Add table
Reference in a new issue