diff options
author | Rob Crittenden <rcritten@redhat.com> | 2012-02-01 13:10:09 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-02-13 22:22:58 -0500 |
commit | 431286a0f61e7bc61d05a6da172cad07801652c2 (patch) | |
tree | 4c4d272872e57fbdfeed362384a6018b83123a6e | |
parent | 64883787645cc972e1b6f905a235e0f4df8fcf2a (diff) | |
download | freeipa.git-431286a0f61e7bc61d05a6da172cad07801652c2.tar.gz freeipa.git-431286a0f61e7bc61d05a6da172cad07801652c2.tar.xz freeipa.git-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.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py index f9d70258..745bb777 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 |