From 431286a0f61e7bc61d05a6da172cad07801652c2 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 1 Feb 2012 13:10:09 -0500 Subject: 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 --- ipaserver/ipaldap.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ipaserver/ipaldap.py') 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 -- cgit