]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dbcheck: Abandon dbcheck if we get an error during a transaction
authorAndrew Bartlett <abartlet@samba.org>
Fri, 26 Aug 2016 03:53:19 +0000 (15:53 +1200)
committerKarolin Seeger <kseeger@samba.org>
Fri, 16 Sep 2016 10:05:33 +0000 (12:05 +0200)
Otherwise, anything that the transaction has already done to the DB will be left in the DB
even despite the failure.  For example, if a fix wrote to the DB, but then failed a post-write
check, then the fix will not be unrolled.

This is because we do not have nested transactions in TDB.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12178

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Aug 29 12:46:21 CEST 2016 on sn-devel-144

(cherry picked from commit db32a0e5ea8f652857e45480cc31ecb1ef884c1a)

python/samba/dbchecker.py
testprogs/blackbox/dbcheck-oldrelease.sh

index 69b4c61e42ec1c87966affdb9bf669d491ba592f..295033fbd9d14ff08fc379bc55b2362d08e63512 100644 (file)
@@ -31,6 +31,7 @@ from samba.common import dsdb_Dn
 from samba.dcerpc import security
 from samba.descriptor import get_wellknown_sds, get_diff_sds
 from samba.auth import system_session, admin_session
+from samba.netcmd import CommandError
 
 
 class dbcheck(object):
@@ -192,6 +193,8 @@ class dbcheck(object):
             controls = controls + ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK]
             self.samdb.delete(dn, controls=controls)
         except Exception, err:
+            if self.in_transaction:
+                raise CommandError("%s : %s" % (msg, err))
             self.report("%s : %s" % (msg, err))
             return False
         return True
@@ -204,6 +207,8 @@ class dbcheck(object):
             controls = controls + ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK]
             self.samdb.modify(m, controls=controls, validate=validate)
         except Exception, err:
+            if self.in_transaction:
+                raise CommandError("%s : %s" % (msg, err))
             self.report("%s : %s" % (msg, err))
             return False
         return True
@@ -221,6 +226,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
             controls = controls + ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK]
             self.samdb.rename(from_dn, to_dn, controls=controls)
         except Exception, err:
+            if self.in_transaction:
+                raise CommandError("%s : %s" % (msg, err))
             self.report("%s : %s" % (msg, err))
             return False
         return True
index 22942dd2b1037f2ed14849bc2b9fef7c04dddf0a..1927fac78ad1d92092353a610a7d6b29adca155a 100755 (executable)
@@ -153,6 +153,15 @@ check_expected_before_values() {
     return 0
 }
 
+# This should 'fail', because it returns the number of modified records
+dbcheck_objectclass() {
+    if [ x$RELEASE = x"release-4-1-6-partial-object" ]; then
+       $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --attrs=objectclass $@
+    else
+       return 1
+    fi
+}
+
 # This should 'fail', because it returns the number of modified records
 dbcheck() {
        $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@
@@ -229,6 +238,7 @@ if [ -d $release_dir ]; then
     testit $RELEASE undump
     testit "reindex" reindex
     testit "check_expected_before_values" check_expected_before_values
+    testit_expect_failure "dbcheck_objectclass" dbcheck_objectclass
     testit_expect_failure "dbcheck" dbcheck
     testit "check_expected_after_values" check_expected_after_values
     testit "dbcheck_clean" dbcheck_clean