5 Usage: tombstones-expunge.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 test -x $BINDIR/tdbrestore
;
41 `dirname $0`/..
/..
/source4/selftest
/provisions
/undump.sh
$release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
43 `dirname $0`/..
/..
/source4/selftest
/provisions
/undump.sh
$release_dir $PREFIX_ABS/$RELEASE
47 tombstones_expunge
() {
48 tmpfile
=$PREFIX_ABS/$RELEASE/expected-expunge-output.txt.tmp
49 tmpldif1
=$PREFIX_ABS/$RELEASE/expected-expunge-output2.txt.tmp1
51 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
-s base
-b '' |
grep highestCommittedUSN
> $tmpldif1
53 $PYTHON $BINDIR/samba-tool domain tombstones expunge
-H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
--current-time=2016-07-30 --tombstone-lifetime=4 > $tmpfile
54 if [ "$?" != "0" ]; then
57 diff $tmpfile $release_dir/expected-expunge-output.txt
58 if [ "$?" != "0" ]; then
62 tmpldif2
=$PREFIX_ABS/$RELEASE/expected-expunge-output2.txt.tmp2
63 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
-s base
-b '' |
grep highestCommittedUSN
> $tmpldif2
65 diff $tmpldif1 $tmpldif2
66 if [ "$?" != "0" ]; then
72 ldif
=$release_dir/add-dangling-link.ldif
73 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb.d
/DC
%3DRELEASE-4-5-0-PRE1
,DC
%3DSAMBA
,DC
%3DCORP.ldb
$ldif
74 if [ "$?" != "0" ]; then
79 add_two_more_users
() {
80 ldif
=$release_dir/add-two-more-users.ldif
81 TZ
=UTC
$ldbadd -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
82 if [ "$?" != "0" ]; then
87 add_four_more_links
() {
88 ldif
=$release_dir/add-four-more-links.ldif
89 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
90 if [ "$?" != "0" ]; then
96 ldif
=$release_dir/remove-one-more-link.ldif
97 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
98 if [ "$?" != "0" ]; then
104 ldif
=$release_dir/remove-one-more-user.ldif
105 TZ
=UTC
$ldbmodify -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
$ldif
106 if [ "$?" != "0" ]; then
111 check_match_rule_links
() {
112 tmpldif
=$PREFIX_ABS/$RELEASE/expected-match-rule-links.ldif.tmp
113 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(member:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted no_attrs
> $tmpldif
114 diff $tmpldif $release_dir/expected-match-rule-links.ldif
115 if [ "$?" != "0" ]; then
120 check_match_rule_links_negative
() {
121 $ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(member:1.3.6.1.4.1.7165.4.5.2:=-131139216000000000)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted member
124 check_match_rule_links_overflow
() {
125 $ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(member:1.3.6.1.4.1.7165.4.5.2:=18446744073709551617)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted member
128 check_match_rule_links_null
() {
129 $ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(member:1.3.6.1.4.1.7165.4.5.2:=18446744\073709551617)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted member
132 check_match_rule_links_hex
() {
133 $ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(member:1.3.6.1.4.1.7165.4.5.2:=abcd)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted member
136 check_match_rule_links_hex2
() {
137 $ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(member:1.3.6.1.4.1.7165.4.5.2:=0xabcd)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted member
140 check_match_rule_links_decimal
() {
141 $ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(member:1.3.6.1.4.1.7165.4.5.2:=131139216000000000.00)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted member
144 check_match_rule_links_backlink
() {
145 $ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(memberOf:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted memberOf
148 check_match_rule_links_notlink
() {
149 $ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(samAccountName:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted samAccountName
152 check_expected_after_links
() {
153 tmpldif
=$PREFIX_ABS/$RELEASE/expected-links-after-expunge.ldif.tmp
154 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
155 diff $tmpldif $release_dir/expected-links-after-expunge.ldif
156 if [ "$?" != "0" ]; then
161 check_expected_after_deleted_links
() {
162 tmpldif
=$PREFIX_ABS/$RELEASE/expected-deleted-links-after-expunge.ldif.tmp
163 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
164 diff $tmpldif $release_dir/expected-deleted-links-after-expunge.ldif
165 if [ "$?" != "0" ]; then
170 check_expected_after_objects
() {
171 tmpldif
=$PREFIX_ABS/$RELEASE/expected-objects-after-expunge.ldif.tmp
172 TZ
=UTC
$ldbsearch -H tdb
://$PREFIX_ABS/${RELEASE}/private
/sam.ldb
'(|(samaccountname=fred)(samaccountname=ddg)(samaccountname=usg)(samaccountname=user1)(samaccountname=user2))' -s sub
-b DC
=release-4-5-0-pre1
,DC
=samba
,DC
=corp
--show-deleted --reveal --sorted samAccountName |
grep sAMAccountName
> $tmpldif
173 diff $tmpldif $release_dir/expected-objects-after-expunge.ldif
174 if [ "$?" != "0" ]; then
179 if [ -d $release_dir ]; then
180 testit
$RELEASE undump
181 testit
"add_two_more_users" add_two_more_users
182 testit
"add_four_more_links" add_four_more_links
183 testit
"add_dangling_link" add_dangling_link
184 testit
"remove_one_link" remove_one_link
185 testit
"remove_one_user" remove_one_user
186 testit
"check_match_rule_links" check_match_rule_links
187 testit_expect_failure
"check_match_rule_links_negative" check_match_rule_links_negative
188 testit_expect_failure
"check_match_rule_links_overflow" check_match_rule_links_overflow
189 testit_expect_failure
"check_match_rule_links_null" check_match_rule_links_null
190 testit_expect_failure
"check_match_rule_links_hex" check_match_rule_links_hex
191 testit_expect_failure
"check_match_rule_links_hex2" check_match_rule_links_hex2
192 testit_expect_failure
"check_match_rule_links_decimal" check_match_rule_links_decimal
193 testit_expect_failure
"check_match_rule_links_backlink" check_match_rule_links_backlink
194 testit_expect_failure
"check_match_rule_links_notlink" check_match_rule_links_notlink
195 testit
"tombstones_expunge" tombstones_expunge
196 testit
"check_expected_after_deleted_links" check_expected_after_deleted_links
197 testit
"check_expected_after_links" check_expected_after_links
198 testit
"check_expected_after_objects" check_expected_after_objects
200 subunit_start_test
$RELEASE
201 subunit_skip_test
$RELEASE <<EOF
205 subunit_start_test
"tombstones_expunge"
206 subunit_skip_test
"tombstones_expunge" <<EOF
211 if [ -d $PREFIX_ABS/${RELEASE} ]; then
212 rm -fr $PREFIX_ABS/${RELEASE}