#!/bin/sh if [ $# -lt 1 ]; then cat < $tmpldif diff $tmpldif $release_dir/expected-replpropertymetadata-before-dbcheck.ldif if [ "$?" != "0" ]; then return 1 fi TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything2 -s one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary | grep -v originating_change_time| grep -v whenChanged > $tmpldif # Here we remove originating_change_time and whenChanged as # these are time-dependent, caused by the ldbmodify above. diff $tmpldif $release_dir/expected-replpropertymetadata-before-dbcheck2.ldif if [ "$?" != "0" ]; then return 1 fi TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything3 -s one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary > $tmpldif diff $tmpldif $release_dir/expected-replpropertymetadata-before-dbcheck3.ldif if [ "$?" != "0" ]; then return 1 fi elif [ x$RELEASE = x"release-4-5-0-pre1" ]; then tmpldif=$PREFIX_ABS/$RELEASE/rootdse-version.initial.txt.tmp TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif diff $tmpldif $release_dir/rootdse-version.initial.txt if [ "$?" != "0" ]; then return 1 fi fi 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 $@ } check_expected_after_values() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then tmpldif=$PREFIX_ABS/$RELEASE/expected-replpropertymetadata-after-dbcheck.ldif.tmp TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything -s one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary > $tmpldif diff $tmpldif $release_dir/expected-replpropertymetadata-after-dbcheck.ldif if [ "$?" != "0" ]; then return 1 fi TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything2 -s one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary | grep -v originating_change_time| grep -v whenChanged > $tmpldif diff $tmpldif $release_dir/expected-replpropertymetadata-after-dbcheck2.ldif if [ "$?" != "0" ]; then return 1 fi TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything3 -s one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary > $tmpldif diff $tmpldif $release_dir/expected-replpropertymetadata-after-dbcheck3.ldif if [ "$?" != "0" ]; then return 1 fi # Check DomainDNS partition for replica locations tmpldif=$PREFIX_ABS/$RELEASE/expected-replica-locations-after-dbcheck.ldif.tmp $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=49a69498-9a85-48af-9be4-aa0b3e0054f9 -s one -b CN=Partitions,CN=Configuration,DC=release-4-1-0rc3,DC=samba,DC=corp msDS-NC-Replica-Locations > $tmpldif diff $tmpldif $release_dir/expected-replica-locations-after-dbcheck.ldif if [ "$?" != "0" ]; then return 1 fi # Check ForestDNS partition for replica locations $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=7d2a15af-c0d4-487c-847e-e036292bcc65 -s one -b CN=Partitions,CN=Configuration,DC=release-4-1-0rc3,DC=samba,DC=corp msDS-NC-Replica-Locations > $tmpldif diff $tmpldif $release_dir/expected-replica-locations-after-dbcheck2.ldif if [ "$?" != "0" ]; then return 1 fi elif [ x$RELEASE = x"release-4-5-0-pre1" ]; then echo $RELEASE checking after values tmpldif=$PREFIX_ABS/$RELEASE/expected-links-after-dbcheck.ldif.tmp $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --show-recycled --show-deleted --show-deactivated-link --reveal member memberOf lastKnownParent objectCategory lastKnownParent wellKnownObjects legacyExchangeDN sAMAccountType uSNChanged --sorted > $tmpldif diff $tmpldif $release_dir/expected-links-after-dbcheck.ldif if [ "$?" != "0" ]; then return 1 fi # If in the future dbcheck has to make a change recorded in replPropertyMetadata, # this test will fail and can be removed. tmpversion=$PREFIX_ABS/$RELEASE/rootdse-version.final.txt.tmp TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpversion diff $tmpversion $release_dir/rootdse-version.final.txt if [ "$?" != "0" ]; then return 1 fi fi return 0 } check_forced_duplicate_values() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then ldif=$release_dir/forced-duplicate-value-for-dbcheck.ldif TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb $ldif if [ "$?" != "0" ]; then return 1 fi else return 0 fi } # This should 'fail', because it returns the number of modified records dbcheck_after_dup() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then $PYTHON $BINDIR/samba-tool dbcheck --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=administrator,cn=users,DC=release-4-1-0rc3,DC=samba,DC=corp $@ else return 1 fi } check_expected_after_dup_values() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then tmpldif=$PREFIX_ABS/$RELEASE/expected-otherphone-after-dbcheck.ldif.tmp TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=administrator -s base -b cn=administrator,cn=users,DC=release-4-1-0rc3,DC=samba,DC=corp otherHomePhone --sorted --show-binary | grep -v \# | sort > $tmpldif diff $tmpldif $release_dir/expected-otherphone-after-dbcheck.ldif if [ "$?" != "0" ]; then return 1 fi fi return 0 } # But having fixed it all up, this should pass dbcheck_clean() { $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@ } # This should 'fail', because it returns the number of modified records. # We don't need to run this against 4.1 releases dbcheck_acl_reset() { if [ x$RELEASE = x"release-4-0-0" -o x$RELEASE = x"alpha13" ]; then $PYTHON $BINDIR/samba-tool dbcheck --reset-well-known-acls --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@ else return 1 fi } # But having fixed it all up, this should pass. # We don't need to run this against 4.1.0rc3 dbcheck_acl_reset_clean() { if [ x$RELEASE != x"release-4-1-0rc3" ]; then $PYTHON $BINDIR/samba-tool dbcheck --reset-well-known-acls --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@ fi } # This should 'fail', because it returns the number of modified records dbcheck2() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@ else exit 1 fi } # But having fixed it all up, this should pass dbcheck_clean2() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@ fi } rm_deleted_objects() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb 'CN=Deleted Objects,DC=RELEASE-4-1-0RC3,DC=SAMBA,DC=CORP' if [ "$?" != "0" ]; then return 1 fi else return 0 fi } # This should 'fail', because it returns the number of modified records dbcheck3() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@ else exit 1 fi } # But having fixed it all up, this should pass dbcheck_clean3() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@ fi } check_expected_after_deleted_objects() { if [ x$RELEASE = x"release-4-1-0rc3" ]; then tmpldif=$PREFIX_ABS/$RELEASE/expected-deleted_objects-after-dbcheck.ldif.tmp TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=deleted\ objects -s base -b cn=deleted\ objects,DC=release-4-1-0rc3,DC=samba,DC=corp objectClass description isDeleted isCriticalSystemObject objectGUID showInAdvancedViewOnly systemFlags --sorted --show-binary --show-deleted | grep -v \# | sort > $tmpldif diff $tmpldif $release_dir/expected-deleted_objects-after-dbcheck.ldif if [ "$?" != "0" ]; then return 1 fi fi return 0 } referenceprovision() { if [ x$RELEASE = x"release-4-0-0" ]; then $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=SAMBA --host-name=ares --realm=${RELEASE}.samba.corp --targetdir=$PREFIX_ABS/${RELEASE}_reference --use-ntvfs --host-ip=127.0.0.1 --host-ip6=::1 --function-level=2003 --base-schema=2008_R2_old # on top of this, also apply 2008R2 changes we accidentally missed in the past $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --ldf-file=samba-4.7-missing-for-schema45.ldif,fix-forest-rev.ldf fi } ldapcmp() { if [ x$RELEASE = x"release-4-0-0" ]; then $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --two --skip-missing-dn --filter=dnsRecord,displayName fi } ldapcmp_sd() { if [ x$RELEASE = x"release-4-0-0" ]; then $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --two --sd --skip-missing-dn fi } if [ -d $release_dir ]; then testit $RELEASE undump testit "reindex" reindex testit "current_version_mod" do_current_version_mod 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 "check_forced_duplicate_values" check_forced_duplicate_values testit_expect_failure "dbcheck_after_dup" dbcheck_after_dup testit "check_expected_after_dup_values" check_expected_after_dup_values testit "dbcheck_clean" dbcheck_clean testit_expect_failure "dbcheck_acl_reset" dbcheck_acl_reset testit "dbcheck_acl_reset_clean" dbcheck_acl_reset_clean testit "add_userparameters0" add_userparameters1 testit "add_userparameters1" add_userparameters1 testit "add_userparameters2" add_userparameters2 testit "add_userparameters3" add_userparameters3 testit_expect_failure "dbcheck2" dbcheck2 testit "dbcheck_clean2" dbcheck_clean2 testit "rm_deleted_objects" rm_deleted_objects # We must re-index again because rm_deleted_objects went behind # the back of the main sam.ldb. testit "reindex2" reindex testit_expect_failure "dbcheck3" dbcheck3 testit "dbcheck_clean3" dbcheck_clean3 testit "check_expected_after_deleted_objects" check_expected_after_deleted_objects testit "referenceprovision" referenceprovision testit "ldapcmp" ldapcmp testit "ldapcmp_sd" ldapcmp_sd else subunit_start_test $RELEASE subunit_skip_test $RELEASE <