mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Use common encoding in modlist generation
ldap2 server plugin generates a modlist for every IPA command entry modification. However, encoding of attributes entry_attrs generated by our framework still does not match entry read from LDAP (until ticket #2265 is addressed), convert compared values to common ground so that the comparison does not report false positives when encoding do not match (e.g. 'int' and 'unicode'). https://fedorahosted.org/freeipa/ticket/3220
This commit is contained in:
parent
e7c99e7d21
commit
d180d3c101
@ -1341,6 +1341,22 @@ class ldap2(CrudBackend):
|
||||
v = set(filter(lambda value: value is not None, v))
|
||||
old_v = set(entry_attrs_old.get(k.lower(), []))
|
||||
|
||||
# FIXME: Convert all values to either unicode, DN or str
|
||||
# before detecting value changes (see IPASimpleLDAPObject for
|
||||
# supported types).
|
||||
# This conversion will set a common ground for the comparison.
|
||||
#
|
||||
# This fix can be removed when ticket 2265 is fixed and our
|
||||
# encoded entry_attrs' types will match get_entry result
|
||||
try:
|
||||
v = set(unicode_from_utf8(self.conn.encode(value))
|
||||
if not isinstance(value, (DN, str, unicode))
|
||||
else value for value in v)
|
||||
except Exception, e:
|
||||
# Rather let the value slip in modlist than let ldap2 crash
|
||||
self.error("Cannot convert attribute '%s' for modlist "
|
||||
"for modlist comparison: %s", k, e)
|
||||
|
||||
adds = list(v.difference(old_v))
|
||||
rems = list(old_v.difference(v))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user