mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #43301 from twangboy/win_fix_unit_test_spm
Fix `unit.test_spm` for Windows
This commit is contained in:
commit
612c6a8756
1 changed files with 18 additions and 7 deletions
|
@ -14,9 +14,12 @@ import shutil
|
|||
import msgpack
|
||||
import hashlib
|
||||
import logging
|
||||
import pwd
|
||||
import grp
|
||||
import sys
|
||||
try:
|
||||
import pwd
|
||||
import grp
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Import Salt libs
|
||||
import salt.client
|
||||
|
@ -491,10 +494,18 @@ class SPMClient(object):
|
|||
|
||||
# No defaults for this in config.py; default to the current running
|
||||
# user and group
|
||||
uid = self.opts.get('spm_uid', os.getuid())
|
||||
gid = self.opts.get('spm_gid', os.getgid())
|
||||
uname = pwd.getpwuid(uid)[0]
|
||||
gname = grp.getgrgid(gid)[0]
|
||||
import salt.utils
|
||||
if salt.utils.is_windows():
|
||||
import salt.utils.win_functions
|
||||
uname = gname = salt.utils.win_functions.get_current_user()
|
||||
uname_sid = salt.utils.win_functions.get_sid_from_name(uname)
|
||||
uid = self.opts.get('spm_uid', uname_sid)
|
||||
gid = self.opts.get('spm_gid', uname_sid)
|
||||
else:
|
||||
uid = self.opts.get('spm_uid', os.getuid())
|
||||
gid = self.opts.get('spm_gid', os.getgid())
|
||||
uname = pwd.getpwuid(uid)[0]
|
||||
gname = grp.getgrgid(gid)[0]
|
||||
|
||||
# Second pass: install the files
|
||||
for member in pkg_files:
|
||||
|
@ -710,7 +721,7 @@ class SPMClient(object):
|
|||
raise SPMInvocationError('A path to a directory must be specified')
|
||||
|
||||
if args[1] == '.':
|
||||
repo_path = os.environ['PWD']
|
||||
repo_path = os.getcwdu()
|
||||
else:
|
||||
repo_path = args[1]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue