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 <antorres@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Antonio Torres authored and Alexander Bokovoy committed 2021-03-29 14:00:53 +03:00
1 parent cfff1f6710
commit 28d310d5b0
1 file changed
+9
+9
View File
@@ -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):