5 Usage: dbcheck-links.sh PREFIX RELEASE
14 .
`dirname $0`/subunit.sh
16 release_dir
=`dirname $0`/..
/..
/source4/selftest
/provisions
/$RELEASE
19 if [ -x "$BINDIR/ldbadd" ]; then
20 ldbadd
="$BINDIR/ldbadd"
24 if [ -x "$BINDIR/ldbmodify" ]; then
25 ldbmodify
="$BINDIR/ldbmodify"
29 if [ -x "$BINDIR/ldbdel" ]; then
30 ldbdel
="$BINDIR/ldbdel"
34 if [ -x "$BINDIR/ldbsearch" ]; then
35 ldbsearch
="$BINDIR/ldbsearch"
39 if [ -x "$BINDIR/ldbrename" ]; then
40 ldbrename
="$BINDIR/ldbrename"
44 if test -x $BINDIR/tdbrestore
;
46 `dirname $0`/..
/..
/source4/selftest
/provisions
/undump.sh
$release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
48 `dirname $0`/..
/..
/source4/selftest
/provisions
/undump.sh
$release_dir $PREFIX_ABS/$RELEASE
53 tmpfile
=$PREFIX_ABS/$RELEASE/expected-dbcheck-link-output.txt.tmp
54 tmpldif1
=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp1
56 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
-s base
-b '' |
grep highestCommittedUSN
> $tmpldif1
58 $PYTHON $BINDIR/samba-tool dbcheck
-H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
--fix --yes > $tmpfile
59 if [ "$?" != "1" ]; then
62 sort $tmpfile > $tmpfile.sorted
63 sort $release_dir/expected-dbcheck-link-output.txt
> $tmpfile.expected
64 diff -u $tmpfile.sorted
$tmpfile.expected
65 if [ "$?" != "0" ]; then
69 tmpldif2
=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp2
70 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
-s base
-b '' |
grep highestCommittedUSN
> $tmpldif2
72 diff $tmpldif1 $tmpldif2
73 if [ "$?" != "0" ]; then
79 tmpldif1
=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp1
81 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
-s base
-b '' |
grep highestCommittedUSN
> $tmpldif1
83 $PYTHON $BINDIR/samba-tool dbcheck
-H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
84 if [ "$?" != "0" ]; then
87 tmpldif2
=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp2
88 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
-s base
-b '' |
grep highestCommittedUSN
> $tmpldif2
90 diff $tmpldif1 $tmpldif2
91 if [ "$?" != "0" ]; then
97 ldif
=$release_dir/add-dangling-forwardlink-user.ldif
98 TZ
=UTC
$ldbadd -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
99 if [ "$?" != "0" ]; then
103 ldif
=$release_dir/add-initially-normal-link.ldif
104 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
105 if [ "$?" != "0" ]; then
109 ldif
=$release_dir/delete-only-backlink.ldif
110 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb.d
/DC
%3DRELEASE-4-5-0-PRE1
,DC
%3DSAMBA
,DC
%3DCORP.ldb
$ldif
111 if [ "$?" != "0" ]; then
116 add_dangling_backlink
() {
117 ldif
=$release_dir/add-dangling-backlink-user.ldif
118 TZ
=UTC
$ldbadd -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
119 if [ "$?" != "0" ]; then
123 ldif
=$release_dir/add-dangling-backlink.ldif
124 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb.d
/DC
%3DRELEASE-4-5-0-PRE1
,DC
%3DSAMBA
,DC
%3DCORP.ldb
$ldif
125 if [ "$?" != "0" ]; then
130 add_two_more_users
() {
131 ldif
=$release_dir/add-two-more-users.ldif
132 TZ
=UTC
$ldbadd -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
133 if [ "$?" != "0" ]; then
138 add_four_more_links
() {
139 ldif
=$release_dir/add-four-more-links.ldif
140 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
141 if [ "$?" != "0" ]; then
147 ldif
=$release_dir/remove-one-more-link.ldif
148 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
149 if [ "$?" != "0" ]; then
155 ldif
=$release_dir/remove-one-more-user.ldif
156 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
157 if [ "$?" != "0" ]; then
163 TZ
=UTC
$ldbrename -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'cn=user1,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp' 'cn=user1x,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
164 if [ "$?" != "0" ]; then
169 check_expected_after_links
() {
170 tmpldif
=$PREFIX_ABS/$RELEASE/expected-links-after-link-dbcheck.ldif.tmp
171 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(|(cn=swimmers)(cn=leaders)(cn=helpers))' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --sorted member
> $tmpldif
172 diff $tmpldif $release_dir/expected-links-after-link-dbcheck.ldif
173 if [ "$?" != "0" ]; then
178 check_expected_after_deleted_links
() {
179 tmpldif
=$PREFIX_ABS/$RELEASE/expected-deleted-links-after-link-dbcheck.ldif.tmp
180 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(|(cn=swimmers)(cn=leaders)(cn=helpers))' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted member
> $tmpldif
181 diff $tmpldif $release_dir/expected-deleted-links-after-link-dbcheck.ldif
182 if [ "$?" != "0" ]; then
187 check_expected_after_objects
() {
188 tmpldif
=$PREFIX_ABS/$RELEASE/expected-objects-after-link-dbcheck.ldif.tmp
189 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(|(samaccountname=fred)(samaccountname=ddg)(samaccountname=usg)(samaccountname=user1)(samaccountname=user1x)(samaccountname=user2))' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted samAccountName |
grep sAMAccountName
> $tmpldif
190 diff $tmpldif $release_dir/expected-objects-after-link-dbcheck.ldif
191 if [ "$?" != "0" ]; then
197 ldif
=$release_dir/dangling-one-way-link.ldif
198 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
199 if [ "$?" != "0" ]; then
204 dangling_multi_valued
() {
205 # multi1 - All 4 backlinks
206 # multi2 - Missing all 4 backlinks
207 # multi3 - Missing 2 backlinks
208 # Administrator - Has 2 too many backlinks
209 # multi5 - Has 2 backlinks but no forward links
210 ldif
=$release_dir/add-dangling-multilink-users.ldif
211 TZ
=UTC
$ldbadd -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
212 if [ "$?" != "0" ]; then
216 ldif
=$release_dir/add-initially-normal-multilink.ldif
217 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
218 if [ "$?" != "0" ]; then
222 ldif
=$release_dir/delete-only-multi-backlink.ldif
223 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb.d
/DC
%3DRELEASE-4-5-0-PRE1
,DC
%3DSAMBA
,DC
%3DCORP.ldb
$ldif
224 if [ "$?" != "0" ]; then
228 ldif
=$release_dir/add-dangling-multi-backlink.ldif
229 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb.d
/DC
%3DRELEASE-4-5-0-PRE1
,DC
%3DSAMBA
,DC
%3DCORP.ldb
$ldif
230 if [ "$?" != "0" ]; then
234 $PYTHON $BINDIR/samba-tool dbcheck
-H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
--fix --yes
235 if [ "$?" != "1" ]; then
240 dangling_multi_valued_check_missing
() {
241 WORDS
=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi2)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
242 if [ $WORDS -ne 4 ]; then
243 echo Got only
$WORDS links
for dangling-multi2
246 WORDS
=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi3)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
247 if [ $WORDS -ne 4 ]; then
248 echo Got only
$WORDS links
for dangling-multi3
253 dangling_multi_valued_check_equal_or_too_many
() {
254 WORDS
=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi1)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
255 if [ $WORDS -ne 4 ]; then
256 echo Got
$WORDS links
for dangling-multi1
260 WORDS
=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi5)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
262 if [ $WORDS -ne 0 ]; then
263 echo Got
$WORDS links
for dangling-multi5
267 WORDS
=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=Administrator)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
269 if [ $WORDS -ne 2 ]; then
270 echo Got
$WORDS links
for Administrator
276 if [ -d $release_dir ]; then
277 testit
$RELEASE undump
278 testit
"add_two_more_users" add_two_more_users
279 testit
"add_four_more_links" add_four_more_links
280 testit
"remove_one_link" remove_one_link
281 testit
"remove_one_user" remove_one_user
282 testit
"move_one_user" move_one_user
283 testit
"add_dangling_link" add_dangling_link
284 testit
"add_dangling_backlink" add_dangling_backlink
285 testit
"dbcheck" dbcheck
286 testit
"dbcheck_clean" dbcheck_clean
287 testit
"check_expected_after_deleted_links" check_expected_after_deleted_links
288 testit
"check_expected_after_links" check_expected_after_links
289 testit
"check_expected_after_objects" check_expected_after_objects
290 testit
"dangling_one_way" dangling_one_way
291 testit
"dbcheck_clean" dbcheck_clean
292 testit
"dangling_multi_valued" dangling_multi_valued
293 testit
"dangling_multi_valued_check_missing" dangling_multi_valued_check_missing
294 testit
"dangling_multi_valued_check_equal_or_too_many" dangling_multi_valued_check_equal_or_too_many
295 # Currently this cannot pass
296 testit
"dangling_multi_valued_dbcheck" dbcheck_clean
298 subunit_start_test
$RELEASE
299 subunit_skip_test
$RELEASE <<EOF
303 subunit_start_test
"tombstones_expunge"
304 subunit_skip_test
"tombstones_expunge" <<EOF
309 if [ -d $PREFIX_ABS/${RELEASE} ]; then
310 rm -fr $PREFIX_ABS/${RELEASE}