mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix win_useradd.chgroups return when cmd.run_all retcode != 0
Fixes #34841 When calling user.chgroups on a windows system, we were not checking for the retcode of the `cmd.run_all` call when the localgroup call failed. This adds a check to make sure the retcode is 0. If it isn't 0, then we should be returning False, not True.
This commit is contained in:
parent
1a4833b3a1
commit
c70492a1fe
1 changed files with 4 additions and 1 deletions
|
@ -666,7 +666,10 @@ def chgroups(name, groups, append=True):
|
|||
continue
|
||||
group = _cmd_quote(group).lstrip('\'').rstrip('\'')
|
||||
cmd = 'net localgroup "{0}" {1} /add'.format(group, name)
|
||||
__salt__['cmd.run_all'](cmd, python_shell=True)
|
||||
out = __salt__['cmd.run_all'](cmd, python_shell=True)
|
||||
if out['retcode'] != 0:
|
||||
log.error(out['stdout'])
|
||||
return False
|
||||
|
||||
agrps = set(list_groups(name))
|
||||
return len(ugrps - agrps) == 0
|
||||
|
|
Loading…
Add table
Reference in a new issue