mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Fix pdbedit module on samba 4.9 (Fixes #50538)
This commit is contained in:
parent
12901c394f
commit
3f61e77c45
@ -92,29 +92,34 @@ def list_users(verbose=True, hashes=False):
|
||||
|
||||
if res['retcode'] > 0:
|
||||
log.error(res['stderr'] if 'stderr' in res else res['stdout'])
|
||||
else:
|
||||
user_data = {}
|
||||
for user in res['stdout'].splitlines():
|
||||
if user.startswith('-'):
|
||||
if len(user_data) > 0:
|
||||
users[user_data['unix username']] = user_data
|
||||
user_data = {}
|
||||
else:
|
||||
label = user[:user.index(':')].strip().lower()
|
||||
data = user[(user.index(':')+1):].strip()
|
||||
user_data[label] = data
|
||||
return users
|
||||
|
||||
if len(user_data) > 0:
|
||||
users[user_data['unix username']] = user_data
|
||||
user_data = {}
|
||||
for user in res['stdout'].splitlines():
|
||||
if user.startswith('-'):
|
||||
if 'unix username' in user_data:
|
||||
users[user_data['unix username']] = user_data
|
||||
user_data = {}
|
||||
elif ':' in user:
|
||||
label = user[:user.index(':')].strip().lower()
|
||||
data = user[(user.index(':')+1):].strip()
|
||||
user_data[label] = data
|
||||
|
||||
if user_data:
|
||||
users[user_data['unix username']] = user_data
|
||||
else:
|
||||
# list users
|
||||
res = __salt__['cmd.run_all']('pdbedit --list')
|
||||
|
||||
if res['retcode'] > 0:
|
||||
return {'Error': res['stderr'] if 'stderr' in res else res['stdout']}
|
||||
else:
|
||||
for user in res['stdout'].splitlines():
|
||||
users.append(user.split(':')[0])
|
||||
|
||||
for user in res['stdout'].splitlines():
|
||||
if ':' not in user:
|
||||
continue
|
||||
user_data = user.split(':')
|
||||
if len(user_data) >= 3:
|
||||
users.append(user_data[0])
|
||||
|
||||
return users
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user