From c0216fb23531d8ad9d4298cb6a51e2baacba16d9 Mon Sep 17 00:00:00 2001 From: Antonio Torres Date: Tue, 2 Mar 2021 18:26:43 +0100 Subject: [PATCH] Enhance error message when adding non-posix group with a GID Enhance error message when adding non-posix group with a GID so the user knows that a GID should not be passed when adding a group with the --nonposix option. Fixes: https://pagure.io/freeipa/issue/8155 Signed-off-by: Antonio Torres Reviewed-By: Rob Crittenden --- ipaserver/plugins/group.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ipaserver/plugins/group.py b/ipaserver/plugins/group.py index 5f463fb56..afdad93c1 100644 --- a/ipaserver/plugins/group.py +++ b/ipaserver/plugins/group.py @@ -387,6 +387,15 @@ class group_add(LDAPCreate): entry_attrs['gidnumber'] = baseldap.DNA_MAGIC return dn + def exc_callback(self, keys, options, exc, call_func, + *call_args, **call_kwargs): + if isinstance(exc, errors.ObjectclassViolation): + if options['nonposix'] and 'gidnumber' in options: + raise errors.ObjectclassViolation( + info=_('attribute "gidNumber" not allowed with --nonposix') + ) + raise exc + @register() class group_del(LDAPDelete):