diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-06-17 11:34:19 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-06-17 12:32:55 +1000 |
commit | a8269792aa7c75b82b5ccab0e3b819601f7a4ef4 (patch) | |
tree | c45f549b545bae1dbcb8f52c589babe9a5784896 | |
parent | 08dc1aa4cc1a697dd72db6a09a32d1929421fc09 (diff) | |
download | samba-a8269792aa7c75b82b5ccab0e3b819601f7a4ef4.tar.gz samba-a8269792aa7c75b82b5ccab0e3b819601f7a4ef4.tar.bz2 samba-a8269792aa7c75b82b5ccab0e3b819601f7a4ef4.zip |
samba-tool: report total error count and suggest --fix if needed
-rw-r--r-- | source4/scripting/python/samba/netcmd/dbcheck.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source4/scripting/python/samba/netcmd/dbcheck.py b/source4/scripting/python/samba/netcmd/dbcheck.py index 4eebca3503..9f12136de8 100644 --- a/source4/scripting/python/samba/netcmd/dbcheck.py +++ b/source4/scripting/python/samba/netcmd/dbcheck.py @@ -100,8 +100,9 @@ def check_object(self, dn): res = self.samdb.search(base=dn, scope=ldb.SCOPE_BASE, controls=["extended_dn:1:1"], attrs=['*', 'ntSecurityDescriptor']) if len(res) != 1: print("Object %s disappeared during check" % dn) - return + return 1 obj = res[0] + error_count = 0 for attrname in obj: if attrname == 'dn': continue @@ -110,6 +111,7 @@ def check_object(self, dn): for val in obj[attrname]: if val == '': empty_attribute(self, dn, attrname) + error_count += 1 continue # check for incorrectly normalised attributes @@ -117,7 +119,9 @@ def check_object(self, dn): normalised = self.samdb.dsdb_normalise_attributes(self.samdb, attrname, [val]) if len(normalised) != 1 or normalised[0] != val: normalise_mismatch(self, dn, attrname, obj[attrname]) + error_count += 1 break + return error_count class cmd_dbcheck(Command): @@ -168,6 +172,9 @@ class cmd_dbcheck(Command): res = self.samdb.search(base=DN, scope=self.search_scope, attrs=['dn'], controls=controls) print('Checking %u objects' % len(res)) + error_count = 0 for object in res: - check_object(self, object.dn) - print('Checked %u objects' % len(res)) + error_count += check_object(self, object.dn) + if error_count != 0 and not self.fix: + print("Please use --fix to fix these errors") + print('Checked %u objects (%u errors)' % (len(res), error_count)) |