Don't assume that plugin attributes and objectclasses are lowercase

A user wrote their own plugin to add custom attributes which was
failing with an incorrect error that the attribute wasn't allowed.

It wasn't allowed because it wasn't being treated as case-insensitive
so wasn't being found in the schema.

https://pagure.io/freeipa/issue/8415

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Rob Crittenden 2021-07-29 17:55:52 -04:00 committed by Florence Blanc-Renaud
parent e914a59738
commit 4932a9c982

View File

@ -534,14 +534,14 @@ class config_mod(LDAPUpdate):
checked_attrs = checked_attrs + [self.api.Object[obj].uuid_attribute] checked_attrs = checked_attrs + [self.api.Object[obj].uuid_attribute]
for obj_attr in checked_attrs: for obj_attr in checked_attrs:
obj_attr, _unused1, _unused2 = obj_attr.partition(';') obj_attr, _unused1, _unused2 = obj_attr.partition(';')
if obj_attr in OPERATIONAL_ATTRIBUTES: if obj_attr.lower() in OPERATIONAL_ATTRIBUTES:
continue continue
if obj_attr in self.api.Object[obj].params and \ if obj_attr.lower() in self.api.Object[obj].params and \
'virtual_attribute' in \ 'virtual_attribute' in \
self.api.Object[obj].params[obj_attr].flags: self.api.Object[obj].params[obj_attr.lower()].flags:
# skip virtual attributes # skip virtual attributes
continue continue
if obj_attr not in new_allowed_attrs: if obj_attr.lower() not in new_allowed_attrs:
raise errors.ValidationError(name=attr, raise errors.ValidationError(name=attr,
error=_('%(obj)s default attribute %(attr)s would not be allowed!') \ error=_('%(obj)s default attribute %(attr)s would not be allowed!') \
% dict(obj=obj, attr=obj_attr)) % dict(obj=obj, attr=obj_attr))