dbcheck: add a dict where we remember attributes with duplicate links
authorRalph Boehme <slow@samba.org>
Thu, 25 Jan 2018 09:34:29 +0000 (10:34 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 5 Feb 2018 12:49:13 +0000 (13:49 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
python/samba/dbchecker.py

index 9185a1d1bed0518b5e3e83c838a52af7820ed486..787cea2de48bd618747b68b3e16a4b8eebf0f095 100644 (file)
@@ -65,6 +65,7 @@ class dbcheck(object):
         self.fix_undead_linked_attributes = False
         self.fix_all_missing_backlinks = False
         self.fix_all_orphaned_backlinks = False
+        self.duplicate_link_cache = dict()
         self.recover_all_forward_links = False
         self.fix_rmd_flags = False
         self.fix_ntsecuritydescriptor = False
@@ -904,6 +905,10 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
         if backlink_attr is None:
             return (error_count, duplicate_dict, unique_dict)
 
+        duplicate_cache_key = "%s:%s" % (str(obj.dn), forward_attr)
+        if duplicate_cache_key not in self.duplicate_link_cache:
+            self.duplicate_link_cache[duplicate_cache_key] = False
+
         for val in obj[forward_attr]:
             dsdb_dn = dsdb_Dn(self.samdb, val, forward_syntax)
 
@@ -945,6 +950,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
             duplicate_dict[keystr]["delete"].append(unique_dict[keystr])
             unique_dict[keystr] = dsdb_dn
 
+        if error_count != 0:
+            self.duplicate_link_cache[duplicate_cache_key] = True
 
         return (error_count, duplicate_dict, unique_dict)