summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2018-01-24 20:01:27 +0100
committerKarolin Seeger <kseeger@samba.org>2018-02-09 09:30:22 +0100
commit84519065f0a1f45b5e69c7fa06ade389d8ce32a9 (patch)
tree1526e59d3c9638c0c24831cd1066b89b50d7937f /python
parent65642396e956bfd03696106f3ea2bdf1372c7c18 (diff)
downloadsamba-84519065f0a1f45b5e69c7fa06ade389d8ce32a9.tar.gz
dbcheck: split out check_duplicate_links from check_dn
Refactoring, no change in behaviour. 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> (cherry picked from commit 44a8782d71676517f0991f279f2472391ecede3b)
Diffstat (limited to 'python')
-rw-r--r--python/samba/dbchecker.py45
1 files changed, 29 insertions, 16 deletions
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index 722184faa0d..9185a1d1bed 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -889,27 +889,23 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
return dsdb_dn
return None
- def check_dn(self, obj, attrname, syntax_oid):
- '''check a DN attribute for correctness'''
+ def check_duplicate_links(self, obj, forward_attr, forward_syntax, forward_linkID, backlink_attr):
+ '''check a linked values for duplicate forward links'''
error_count = 0
- obj_guid = obj['objectGUID'][0]
-
- linkID, reverse_link_name = self.get_attr_linkID_and_reverse_name(attrname)
- if reverse_link_name is not None:
- reverse_syntax_oid = self.samdb_schema.get_syntax_oid_from_lDAPDisplayName(reverse_link_name)
- else:
- reverse_syntax_oid = None
duplicate_dict = dict()
unique_dict = dict()
- for val in obj[attrname]:
- if linkID & 1:
- #
- # Only cleanup forward links here,
- # back links are handled below.
- break
- dsdb_dn = dsdb_Dn(self.samdb, val, syntax_oid)
+ # Only forward links can have this problem
+ if forward_linkID & 1:
+ # If we got the reverse, skip it
+ return (error_count, duplicate_dict, unique_dict)
+
+ if backlink_attr is None:
+ return (error_count, duplicate_dict, unique_dict)
+
+ for val in obj[forward_attr]:
+ dsdb_dn = dsdb_Dn(self.samdb, val, forward_syntax)
# all DNs should have a GUID component
guid = dsdb_dn.dn.get_extended_component("GUID")
@@ -949,6 +945,23 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
duplicate_dict[keystr]["delete"].append(unique_dict[keystr])
unique_dict[keystr] = dsdb_dn
+
+ return (error_count, duplicate_dict, unique_dict)
+
+ def check_dn(self, obj, attrname, syntax_oid):
+ '''check a DN attribute for correctness'''
+ error_count = 0
+ obj_guid = obj['objectGUID'][0]
+
+ linkID, reverse_link_name = self.get_attr_linkID_and_reverse_name(attrname)
+ if reverse_link_name is not None:
+ reverse_syntax_oid = self.samdb_schema.get_syntax_oid_from_lDAPDisplayName(reverse_link_name)
+ else:
+ reverse_syntax_oid = None
+
+ error_count, duplicate_dict, unique_dict = \
+ self.check_duplicate_links(obj, attrname, syntax_oid, linkID, reverse_link_name)
+
if len(duplicate_dict) != 0:
self.report("ERROR: Duplicate forward link values for attribute '%s' in '%s'" % (attrname, obj.dn))
for keystr in duplicate_dict.keys():