Fix pdbedit module on samba 4.9 (Fixes #50538)

This commit is contained in:
Jorge Schrauwen 2018-11-16 14:54:16 +01:00 committed by Ch3LL
parent 12901c394f
commit 3f61e77c45
No known key found for this signature in database
GPG Key ID: 132B55A7C13EFA73

View File

@ -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