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 authored and James Valleroy committed 2019-08-25 15:52:08 -04:00
1 parent e1e654554e
commit caa266e348
1 file changed
+7 -3
+7 -3
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: