users: Don't fail badly when admin group does not exist

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-08-19 19:38:30 -07:00 committed by James Valleroy
parent e1e654554e
commit caa266e348
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -355,9 +355,13 @@ def subcommand_remove_user_from_group(arguments):
def subcommand_get_group_users(arguments):
""" Get the list of users of an LDAP group."""
process = _run(['ldapgid', '-P', arguments.groupname],
stdout=subprocess.PIPE)
"""Get the list of users of an LDAP group."""
try:
process = _run(['ldapgid', '-P', arguments.groupname],
stdout=subprocess.PIPE)
except subprocess.CalledProcessError:
return # Group does not exist, return empty list
output = process.stdout.decode()
users = output.rsplit(':')[-1]
if users: