summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2012-02-01 13:10:09 -0500
committerRob Crittenden <rcritten@redhat.com>2012-02-13 22:22:58 -0500
commit431286a0f61e7bc61d05a6da172cad07801652c2 (patch)
tree4c4d272872e57fbdfeed362384a6018b83123a6e
parent64883787645cc972e1b6f905a235e0f4df8fcf2a (diff)
downloadfreeipa-431286a0f61e7bc61d05a6da172cad07801652c2.tar.gz
freeipa-431286a0f61e7bc61d05a6da172cad07801652c2.tar.xz
freeipa-431286a0f61e7bc61d05a6da172cad07801652c2.zip
Don't use sets when calculating the modlist so order is preserved.
This is for the LDAP updater in particular. When adding new schema order can be important when one objectclass depends on another via SUP. This calculation will preserve the order of changes in the update file. Discovered trying to add SSH schema. https://fedorahosted.org/freeipa/ticket/754
-rw-r--r--ipaserver/ipaldap.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index f9d70258e..745bb777e 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -554,16 +554,17 @@ class IPAdmin(IPAEntryLDAPObject):
if not(isinstance(new_values,list) or isinstance(new_values,tuple)):
new_values = [new_values]
new_values = filter(lambda value:value!=None, new_values)
- new_values = set(new_values)
old_values = old_entry.get(key, [])
if not(isinstance(old_values,list) or isinstance(old_values,tuple)):
old_values = [old_values]
old_values = filter(lambda value:value!=None, old_values)
- old_values = set(old_values)
- adds = list(new_values.difference(old_values))
- removes = list(old_values.difference(new_values))
+ # We used to convert to sets and use difference to calculate
+ # the changes but this did not preserve order which is important
+ # particularly for schema
+ adds = [x for x in new_values if x not in old_values]
+ removes = [x for x in old_values if x not in new_values]
if len(adds) == 0 and len(removes) == 0:
continue