1#!/bin/sh 2 3# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4# 5# SPDX-License-Identifier: MPL-2.0 6# 7# This Source Code Form is subject to the terms of the Mozilla Public 8# License, v. 2.0. If a copy of the MPL was not distributed with this 9# file, you can obtain one at https://mozilla.org/MPL/2.0/. 10# 11# See the COPYRIGHT file distributed with this work for additional 12# information regarding copyright ownership. 13 14SYSTEMTESTTOP=.. 15. $SYSTEMTESTTOP/conf.sh 16 17status=0 18n=1 19 20for db in zones/good*.db 21do 22 echo_i "checking $db ($n)" 23 ret=0 24 case $db in 25 zones/good-gc-msdcs.db|zones/good-spf-exception.db) 26 $CHECKZONE -k fail -i local example $db > test.out.$n 2>&1 || ret=1 27 ;; 28 zones/good-dns-sd-reverse.db) 29 $CHECKZONE -k fail -i local 0.0.0.0.in-addr.arpa $db > test.out.$n 2>&1 || ret=1 30 ;; 31 *) 32 $CHECKZONE -i local example $db > test.out.$n 2>&1 || ret=1 33 ;; 34 esac 35 n=$((n+1)) 36 if [ $ret != 0 ]; then echo_i "failed"; fi 37 status=$((status+ret)) 38done 39 40for db in zones/bad*.db 41do 42 echo_i "checking $db ($n)" 43 ret=0 v=0 44 case $db in 45 zones/bad-dns-sd-reverse.db|zones/bad-svcb-servername.db) 46 $CHECKZONE -k fail -i local 0.0.0.0.in-addr.arpa $db > test.out.$n 2>&1 || v=$? 47 ;; 48 *) 49 $CHECKZONE -i local example $db > test.out.$n 2>&1 || v=$? 50 ;; 51 esac 52 test $v = 1 || ret=1 53 n=$((n+1)) 54 if [ $ret != 0 ]; then echo_i "failed"; fi 55 status=$((status+ret)) 56done 57 58echo_i "checking with journal file ($n)" 59ret=0 60$CHECKZONE -D -o test.orig.db test zones/test1.db > /dev/null 2>&1 || ret=1 61$CHECKZONE -D -o test.changed.db test zones/test2.db > /dev/null 2>&1 || ret=1 62$MAKEJOURNAL test test.orig.db test.changed.db test.orig.db.jnl 2>&1 || ret=1 63jlines=$($JOURNALPRINT test.orig.db.jnl | wc -l) 64[ $jlines = 3 ] || ret=1 65$CHECKZONE -D -j -o test.out1.db test test.orig.db > /dev/null 2>&1 || ret=1 66cmp -s test.changed.db test.out1.db || ret=1 67mv -f test.orig.db.jnl test.journal 68$CHECKZONE -D -J test.journal -o test.out2.db test test.orig.db > /dev/null 2>&1 || ret=1 69cmp -s test.changed.db test.out2.db || ret=1 70n=$((n+1)) 71if [ $ret != 0 ]; then echo_i "failed"; fi 72status=$((status+ret)) 73 74echo_i "checking with spf warnings ($n)" 75ret=0 76$CHECKZONE example zones/spf.db > test.out1.$n 2>&1 || ret=1 77$CHECKZONE -T ignore example zones/spf.db > test.out2.$n 2>&1 || ret=1 78grep "'x.example' found type SPF" test.out1.$n > /dev/null && ret=1 79grep "'y.example' found type SPF" test.out1.$n > /dev/null || ret=1 80grep "'example' found type SPF" test.out1.$n > /dev/null && ret=1 81grep "'x.example' found type SPF" test.out2.$n > /dev/null && ret=1 82grep "'y.example' found type SPF" test.out2.$n > /dev/null && ret=1 83grep "'example' found type SPF" test.out2.$n > /dev/null && ret=1 84n=$((n+1)) 85if [ $ret != 0 ]; then echo_i "failed"; fi 86status=$((status+ret)) 87 88echo_i "checking with max ttl (text) ($n)" 89ret=0 90$CHECKZONE -l 300 example zones/good1.db > test.out1.$n 2>&1 && ret=1 91$CHECKZONE -l 600 example zones/good1.db > test.out2.$n 2>&1 || ret=1 92n=$((n+1)) 93if [ $ret != 0 ]; then echo_i "failed"; fi 94status=$((status+ret)) 95 96echo_i "checking with max ttl (raw) ($n)" 97ret=0 98$CHECKZONE -f raw -l 300 example good1.db.raw > test.out1.$n 2>&1 && ret=1 99$CHECKZONE -f raw -l 600 example good1.db.raw > test.out2.$n 2>&1 || ret=1 100n=$((n+1)) 101if [ $ret != 0 ]; then echo_i "failed"; fi 102status=$((status+ret)) 103 104echo_i "checking with max ttl (map) ($n)" 105ret=0 106$CHECKZONE -f map -l 300 example good1.db.map > test.out1.$n 2>&1 && ret=1 107$CHECKZONE -f map -l 600 example good1.db.map > test.out2.$n 2>&1 || ret=1 108n=`expr $n + 1` 109if [ $ret != 0 ]; then echo_i "failed"; fi 110status=`expr $status + $ret` 111 112echo_i "checking for no 'inherited owner' warning on '\$INCLUDE file' with no new \$ORIGIN ($n)" 113ret=0 114$CHECKZONE example zones/nowarn.inherited.owner.db > test.out1.$n 2>&1 || ret=1 115grep "inherited.owner" test.out1.$n > /dev/null && ret=1 116n=$((n+1)) 117if [ $ret != 0 ]; then echo_i "failed"; fi 118status=$((status+ret)) 119 120echo_i "checking for 'inherited owner' warning on '\$ORIGIN + \$INCLUDE file' ($n)" 121ret=0 122$CHECKZONE example zones/warn.inherit.origin.db > test.out1.$n 2>&1 || ret=1 123grep "inherited.owner" test.out1.$n > /dev/null || ret=1 124n=$((n+1)) 125if [ $ret != 0 ]; then echo_i "failed"; fi 126status=$((status+ret)) 127 128echo_i "checking for 'inherited owner' warning on '\$INCLUDE file origin' ($n)" 129ret=0 130$CHECKZONE example zones/warn.inherited.owner.db > test.out1.$n 2>&1 || ret=1 131grep "inherited.owner" test.out1.$n > /dev/null || ret=1 132n=$((n+1)) 133if [ $ret != 0 ]; then echo_i "failed"; fi 134status=$((status+ret)) 135 136echo_i "checking that raw zone with bad class is handled ($n)" 137ret=0 138$CHECKZONE -f raw example zones/bad-badclass.raw > test.out.$n 2>&1 && ret=1 139grep "failed: bad class" test.out.$n >/dev/null || ret=1 140n=$((n+1)) 141if [ $ret != 0 ]; then echo_i "failed"; fi 142status=$((status+ret)) 143 144echo_i "checking that expirations that loop using serial arithmetic are handled ($n)" 145ret=0 146q=-q 147test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 148test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 149test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 150test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 151test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 152test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 153test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 154test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 155test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 156test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 157test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 158test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 159test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 160test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 161test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 162test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 163test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 164test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 165test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 166test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 167test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 168test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1 169n=$((n+1)) 170if [ $ret != 0 ]; then echo_i "failed"; fi 171status=$((status+ret)) 172 173echo_i "checking that nameserver below DNAME is reported even with occulted address record present ($n)" 174ret=0 175$CHECKZONE example.com zones/ns-address-below-dname.db > test.out.$n 2>&1 && ret=1 176grep "is below a DNAME" test.out.$n >/dev/null || ret=1 177n=$((n+1)) 178if [ $ret != 0 ]; then echo_i "failed"; fi 179status=$((status+ret)) 180 181echo_i "checking that delegating nameserver below DNAME is reported even with occulted address record present ($n)" 182ret=0 183$CHECKZONE example.com zones/delegating-ns-address-below-dname.db > test.out.$n 2>&1 || ret=1 184grep "is below a DNAME" test.out.$n >/dev/null || ret=1 185n=$((n+1)) 186if [ $ret != 0 ]; then echo_i "failed"; fi 187status=$((status+ret)) 188 189n=$((n+1)) 190ret=0 191echo_i "checking integer overflow is prevented in \$GENERATE ($n)" 192$CHECKZONE -D example.com zones/generate-overflow.db > test.out.$n 2>&1 || ret=1 193lines=$(grep -c CNAME test.out.$n) 194echo $lines 195[ "$lines" -eq 1 ] || ret=1 196if [ $ret != 0 ]; then echo_i "failed"; fi 197status=$((status+ret)) 198 199echo_i "exit status: $status" 200[ $status -eq 0 ] || exit 1 201