Skip to content

Commit a5ba11b

Browse files
committed
Merge pull request #8498 from UtahDave/0.17
Fix Windows User state
2 parents 0a5e0a5 + 193c2ce commit a5ba11b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

salt/modules/win_file.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def gid_to_group(gid):
8181
8282
salt '*' file.gid_to_group S-1-5-21-626487655-2533044672-482107328-1010
8383
'''
84+
if not gid:
85+
return False
8486
sid = win32security.GetBinarySid(gid)
8587
name, domain, account_type = win32security.LookupAccountSid(None, sid)
8688
return name

salt/states/user.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import logging
2929
import sys
3030

31+
# Import salt libs
32+
import salt.utils
33+
3134
log = logging.getLogger(__name__)
3235

3336

@@ -96,7 +99,7 @@ def _changes(name,
9699
if shell:
97100
if lusr['shell'] != shell:
98101
change['shell'] = shell
99-
if 'shadow.info' in __salt__:
102+
if 'shadow.info' in __salt__ and 'shadow.default_hash' in __salt__:
100103
if password:
101104
default_hash = __salt__['shadow.default_hash']()
102105
if lshad['passwd'] == default_hash \
@@ -369,7 +372,7 @@ def present(name,
369372
if all((password, 'shadow.info' in __salt__)):
370373
__salt__['shadow.set_password'](name, password)
371374
spost = __salt__['shadow.info'](name)
372-
if spost['passwd'] != password:
375+
if spost['passwd'] != password and not salt.utils.is_windows():
373376
ret['comment'] = 'User {0} created but failed to set' \
374377
' password to {1}'.format(name, password)
375378
ret['result'] = False

0 commit comments

Comments
 (0)