summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2012-10-29 10:32:39 +0100
committerMartin Kosek <mkosek@redhat.com>2012-11-01 15:32:23 +0100
commit1f1918f97147a9c63b4e8110aa404acc6f7d0324 (patch)
tree4365e6bc6a0dbe1a20454b51e786ba8127e03b1a
parent5ff40254d8b12044522942532ca26b7a9fa40ef3 (diff)
downloadfreeipa.git-1f1918f97147a9c63b4e8110aa404acc6f7d0324.tar.gz
freeipa.git-1f1918f97147a9c63b4e8110aa404acc6f7d0324.tar.xz
freeipa.git-1f1918f97147a9c63b4e8110aa404acc6f7d0324.zip
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
-rw-r--r--ipaserver/plugins/ldap2.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py
index caf35096..519f4613 100644
--- a/ipaserver/plugins/ldap2.py
+++ b/ipaserver/plugins/ldap2.py
@@ -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))