selftest: Add more corruption cases for runtime and dbcheck
authorAndrew Bartlett <abartlet@samba.org>
Tue, 31 Oct 2017 20:02:01 +0000 (09:02 +1300)
committerStefan Metzmacher <metze@samba.org>
Fri, 24 Nov 2017 14:50:16 +0000 (15:50 +0100)
These tests now confirm we can handle these issues at runtime
as well as at dbcheck

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail.d/delete_member_of_deleted_group [new file with mode: 0644]
selftest/knownfail.d/runtime-links [new file with mode: 0644]
selftest/tests.py
source4/selftest/provisions/release-4-5-0-pre1/expected-dbcheck-link-output.txt
source4/selftest/provisions/release-4-5-0-pre1/revive-backlink-on-deleted-group.ldif [moved from source4/selftest/provisions/release-4-5-0-pre1/add-deleted-source-backlink.ldif with 62% similarity]
source4/selftest/provisions/release-4-5-0-pre1/revive-links-on-deleted-group.ldif [new file with mode: 0644]
testprogs/blackbox/common-links.sh
testprogs/blackbox/dbcheck-links.sh
testprogs/blackbox/runtime-links.sh [new file with mode: 0755]

diff --git a/selftest/knownfail.d/delete_member_of_deleted_group b/selftest/knownfail.d/delete_member_of_deleted_group
new file mode 100644 (file)
index 0000000..f399d33
--- /dev/null
@@ -0,0 +1 @@
+^samba4\.blackbox\.runtime-links\.release-4-5-0-pre1\.delete_member_of_deleted_group
\ No newline at end of file
diff --git a/selftest/knownfail.d/runtime-links b/selftest/knownfail.d/runtime-links
new file mode 100644 (file)
index 0000000..70de8be
--- /dev/null
@@ -0,0 +1,2 @@
+^samba4\.blackbox\.runtime-links\.release-4-5-0-pre1\.delete_backlink_memberof_deleted_group
+^samba4\.blackbox\.runtime-links\.release-4-5-0-pre1\.delete_dangling_backlink_memberof_group
\ No newline at end of file
index 181313e..209800c 100644 (file)
@@ -125,6 +125,11 @@ plantestsuite(
     ["PYTHON=%s" % python,
      os.path.join(bbdir, "dbcheck-links.sh"),
      '$PREFIX_ABS/provision', 'release-4-5-0-pre1', configuration])
+plantestsuite(
+    "samba4.blackbox.runtime-links.release-4-5-0-pre1", "none",
+    ["PYTHON=%s" % python,
+     os.path.join(bbdir, "runtime-links.sh"),
+     '$PREFIX_ABS/provision', 'release-4-5-0-pre1', configuration])
 planpythontestsuite("none", "samba.tests.upgradeprovision")
 planpythontestsuite("none", "samba.tests.xattr", py3_compatible=True)
 planpythontestsuite("none", "samba.tests.ntacls")
index 6f0d2fc..5a083f7 100644 (file)
@@ -7,6 +7,9 @@ ERROR: target DN is deleted for member in object CN=Allowed RODC Password Replic
 Target GUID points at deleted DN 'CN=fred\\0ADEL:2301a64c-5b42-4ca8-851e-12d4a711cfb4,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp'
 Remove DN link? [YES]
 Removed deleted DN on attribute member
+ERROR: orphaned backlink attribute 'memberOf' in CN=dangling-back,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp for link member in CN=Allowed RODC Password Replication Group,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+Remove orphaned backlink memberOf [YES]
+Fixed orphaned backlink memberOf
 ERROR: linked attribute 'member' to '<GUID=118943ce-41c2-48cb-a511-b68c6feaa8aa>;<RMD_ADDTIME=131116484670000000>;<RMD_CHANGETIME=131116484700000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3728>;<RMD_ORIGINATING_USN=3728>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1103>;CN=User UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=dsg\0ADEL:6d66d0ef-cad7-4e5d-b1b6-4a233a21c269,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
 Remove linked attribute member [YES]
 Fixed undead forward link member
@@ -19,7 +22,7 @@ Fixed undead forward link memberOf
 ERROR: linked attribute 'member' to '<GUID=118943ce-41c2-48cb-a511-b68c6feaa8aa>;<RMD_ADDTIME=131116484690000000>;<RMD_CHANGETIME=131116484720000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3733>;<RMD_ORIGINATING_USN=3733>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1103>;CN=User UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=udg\0ADEL:7cff5537-51b1-4d26-a295-0225dbea8525,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
 Remove linked attribute member [YES]
 Fixed undead forward link member
-ERROR: linked attribute 'member' to '<GUID=50d78122-17c8-4352-acf0-8f549b5b5b3c>;<RMD_ADDTIME=131116484690000000>;<RMD_CHANGETIME=131116484720000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3733>;<RMD_ORIGINATING_USN=3733>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1104>;CN=User1 UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=udg\0ADEL:7cff5537-51b1-4d26-a295-0225dbea8525,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
+ERROR: linked attribute 'member' to '<GUID=50d78122-17c8-4352-acf0-8f549b5b5b3c>;<RMD_ADDTIME=131116484690000000>;<RMD_CHANGETIME=131116484720000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3733>;<RMD_ORIGINATING_USN=3733>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1104>;CN=User1 UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=udg\0ADEL:7cff5537-51b1-4d26-a295-0225dbea8525,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
 Remove linked attribute member [YES]
 Fixed undead forward link member
 ERROR: linked attribute 'member' to '<GUID=118943ce-41c2-48cb-a511-b68c6feaa8aa>;<RMD_ADDTIME=131116484680000000>;<RMD_CHANGETIME=131116484700000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3730>;<RMD_ORIGINATING_USN=3730>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1103>;CN=User UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=usg\0ADEL:d012e8f5-a4bd-40ea-a2a1-68ff2508847d,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
@@ -28,10 +31,6 @@ Fixed undead forward link member
 ERROR: linked attribute 'member' to '<GUID=50d78122-17c8-4352-acf0-8f549b5b5b3c>;<RMD_ADDTIME=131116484680000000>;<RMD_CHANGETIME=131116484700000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3730>;<RMD_ORIGINATING_USN=3730>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1104>;CN=User1 UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=usg\0ADEL:d012e8f5-a4bd-40ea-a2a1-68ff2508847d,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
 Remove linked attribute member [YES]
 Fixed undead forward link member
-ERROR: target DN is deleted for memberOf in object CN=deleted-target-back,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp - <GUID=e0f581e7-14ee-4fc2-839c-8f46f581c72a>;<SID=S-1-5-21-4177067393-1453636373-93818738-1109>;CN=gdg\0ADEL:e0f581e7-14ee-4fc2-839c-8f46f581c72a,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
-Target GUID points at deleted DN 'CN=gdg\\0ADEL:e0f581e7-14ee-4fc2-839c-8f46f581c72a,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp'
-Remove DN link? [YES]
-Removed deleted DN on attribute memberOf
 ERROR: linked attribute 'member' to '<GUID=118943ce-41c2-48cb-a511-b68c6feaa8aa>;<RMD_ADDTIME=131116484680000000>;<RMD_CHANGETIME=131116484710000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3731>;<RMD_ORIGINATING_USN=3731>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1103>;CN=User UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=ddg\0ADEL:fb8c2fe3-5448-43de-99f9-e1d3b9357cfc,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
 Remove linked attribute member [YES]
 Fixed undead forward link member
@@ -48,9 +47,10 @@ Fixed undead forward link member
 ERROR: linked attribute 'member' to '<GUID=50d78122-17c8-4352-acf0-8f549b5b5b3c>;<RMD_ADDTIME=131116484670000000>;<RMD_CHANGETIME=131116484700000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3729>;<RMD_ORIGINATING_USN=3729>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1104>;CN=User1 UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=gsg\0ADEL:91aa85cc-fc19-4b8c-9fc7-aaba425439c7,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
 Remove linked attribute member [YES]
 Fixed undead forward link member
-ERROR: orphaned backlink attribute 'memberOf' in CN=dangling-back,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp for link member in CN=Allowed RODC Password Replication Group,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
-Remove orphaned backlink memberOf [YES]
-Fixed orphaned backlink memberOf
+ERROR: target DN is deleted for memberOf in object CN=deleted-target-back,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp - <GUID=e0f581e7-14ee-4fc2-839c-8f46f581c72a>;<SID=S-1-5-21-4177067393-1453636373-93818738-1109>;CN=gdg\0ADEL:e0f581e7-14ee-4fc2-839c-8f46f581c72a,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
+Target GUID points at deleted DN 'CN=gdg\\0ADEL:e0f581e7-14ee-4fc2-839c-8f46f581c72a,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+Remove DN link? [YES]
+Removed deleted DN on attribute memberOf
 ERROR: linked attribute 'member' to '<GUID=118943ce-41c2-48cb-a511-b68c6feaa8aa>;<RMD_ADDTIME=131116484690000000>;<RMD_CHANGETIME=131116484710000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3732>;<RMD_ORIGINATING_USN=3732>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1103>;CN=User UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp' is present on deleted object CN=gdg\0ADEL:e0f581e7-14ee-4fc2-839c-8f46f581c72a,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
 Remove linked attribute member [YES]
 Fixed undead forward link member
@@ -1,6 +1,5 @@
-dn: CN=User1 UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+dn: CN=User UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
 changetype: modify
 add: memberOf
 memberOf: <GUID=7cff5537-51b1-4d26-a295-0225dbea8525>;<SID=S-1-5-21-4177067393-1453636373-93818738-1110>;CN=udg\0ADEL:7cff5537-51b1-4d26-a295-0225dbea8525,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
 -
-# in group udg, the link is deleted, so this is sort of a dangling backlink too
\ No newline at end of file
diff --git a/source4/selftest/provisions/release-4-5-0-pre1/revive-links-on-deleted-group.ldif b/source4/selftest/provisions/release-4-5-0-pre1/revive-links-on-deleted-group.ldif
new file mode 100644 (file)
index 0000000..a4301a0
--- /dev/null
@@ -0,0 +1,20 @@
+dn: CN=User1 UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: modify
+add: memberOf
+memberOf: <GUID=7cff5537-51b1-4d26-a295-0225dbea8525>;<SID=S-1-5-21-4177067393-1453636373-93818738-1110>;CN=udg\0ADEL:7cff5537-51b1-4d26-a295-0225dbea8525,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
+-
+
+dn: CN=udg\0ADEL:7cff5537-51b1-4d26-a295-0225dbea8525,CN=Deleted Objects,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: modify
+delete: member
+member: <GUID=50d78122-17c8-4352-acf0-8f549b5b5b3c>;<RMD_ADDTIME=1311164846900
+ 00000>;<RMD_CHANGETIME=131116484720000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a
+ 3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3733>;<RMD_ORIGINATING_USN=3733
+ >;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1104>;CN=User1
+  UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+add: member
+member: <GUID=50d78122-17c8-4352-acf0-8f549b5b5b3c>;<RMD_ADDTIME=1311164846900
+ 00000>;<RMD_CHANGETIME=131116484720000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a
+ 3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3733>;<RMD_ORIGINATING_USN=3733
+ >;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1104>;CN=User1
+  UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
\ No newline at end of file
index e36cb0b..ee7310b 100644 (file)
@@ -96,8 +96,16 @@ add_deleted_target_backlink() {
     fi
 }
 
-add_deleted_source_backlink() {
-    ldif=$release_dir/add-deleted-source-backlink.ldif
+revive_links_on_deleted_group() {
+    ldif=$release_dir/revive-links-on-deleted-group.ldif
+    TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+}
+
+revive_backlink_on_deleted_group() {
+    ldif=$release_dir/revive-backlink-on-deleted-group.ldif
     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
     if [ "$?" != "0" ]; then
        return 1
index 074b601..0aeada0 100755 (executable)
@@ -185,7 +185,8 @@ if [ -d $release_dir ]; then
     testit "add_dangling_link" add_dangling_link
     testit "add_dangling_backlink" add_dangling_backlink
     testit "add_deleted_dangling_backlink" add_deleted_dangling_backlink
-    testit "add_deleted_source_backlink" add_deleted_source_backlink
+    testit "revive_links_on_deleted_group" revive_links_on_deleted_group
+    testit "revive_backlink_on_deleted_group" revive_backlink_on_deleted_group
     testit "add_deleted_target_link" add_deleted_target_link
     testit "add_deleted_target_backlink" add_deleted_target_backlink
     testit "dbcheck_dangling" dbcheck_dangling
diff --git a/testprogs/blackbox/runtime-links.sh b/testprogs/blackbox/runtime-links.sh
new file mode 100755 (executable)
index 0000000..344b822
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+cat <<EOF
+Usage: dbcheck-links.sh PREFIX RELEASE
+EOF
+exit 1;
+fi
+
+PREFIX_ABS="$1"
+RELEASE="$2"
+shift 2
+
+. `dirname $0`/subunit.sh
+
+. `dirname $0`/common-links.sh
+
+delete_member_of_deleted_group() {
+    TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'CN=User1 UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+}
+
+delete_backlink_memberof_deleted_group() {
+    TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'CN=User UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+}
+
+delete_dangling_backlink_memberof_group() {
+    TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'CN=dangling-back,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+}
+
+
+if [ -d $release_dir ]; then
+    testit $RELEASE undump
+    testit "add_dangling_link" add_dangling_link
+    testit "add_dangling_backlink" add_dangling_backlink
+    testit "add_deleted_dangling_backlink" add_deleted_dangling_backlink
+    testit "revive_links_on_deleted_group" revive_links_on_deleted_group
+    testit "revive_backlink_on_deleted_group" revive_backlink_on_deleted_group
+    testit "add_deleted_target_link" add_deleted_target_link
+    testit "add_deleted_target_backlink" add_deleted_target_backlink
+    testit "dangling_one_way_link" dangling_one_way_link
+    testit "dangling_one_way_dn" dangling_one_way_dn
+    testit "deleted_one_way_dn" deleted_one_way_dn
+    testit "add_dangling_multi_valued" add_dangling_multi_valued
+
+#Now things are set up, work with the DB
+    testit "delete_member_of_deleted_group" delete_member_of_deleted_group
+    testit "delete_backlink_memberof_deleted_group" delete_backlink_memberof_deleted_group
+    testit "delete_dangling_backlink_memberof_group" delete_dangling_backlink_memberof_group
+else
+    subunit_start_test $RELEASE
+    subunit_skip_test $RELEASE <<EOF
+no test provision
+EOF
+
+    subunit_start_test "tombstones_expunge"
+    subunit_skip_test "tombstones_expunge" <<EOF
+no test provision
+EOF
+fi
+
+if [ -d $PREFIX_ABS/${RELEASE} ]; then
+    rm -fr $PREFIX_ABS/${RELEASE}
+fi
+
+exit $failed