diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:37:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:37:14 +0000 |
commit | ea648e70a989cca190cd7403fe892fd2dcc290b4 (patch) | |
tree | e2b6b1c647da68b0d4d66082835e256eb30970e8 /bin/tests/system/metadata | |
parent | Initial commit. (diff) | |
download | bind9-ea648e70a989cca190cd7403fe892fd2dcc290b4.tar.xz bind9-ea648e70a989cca190cd7403fe892fd2dcc290b4.zip |
Adding upstream version 1:9.11.5.P4+dfsg.upstream/1%9.11.5.P4+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | bin/tests/system/metadata/child.db | 22 | ||||
-rw-r--r-- | bin/tests/system/metadata/clean.sh | 19 | ||||
-rw-r--r-- | bin/tests/system/metadata/parent.db | 29 | ||||
-rw-r--r-- | bin/tests/system/metadata/prereq.sh | 15 | ||||
-rw-r--r-- | bin/tests/system/metadata/setup.sh | 63 | ||||
-rw-r--r-- | bin/tests/system/metadata/tests.sh | 211 |
6 files changed, 359 insertions, 0 deletions
diff --git a/bin/tests/system/metadata/child.db b/bin/tests/system/metadata/child.db new file mode 100644 index 0000000..2905a56 --- /dev/null +++ b/bin/tests/system/metadata/child.db @@ -0,0 +1,22 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; This Source Code Form is subject to the terms of the Mozilla Public +; License, v. 2.0. If a copy of the MPL was not distributed with this +; file, You can obtain one at http://mozilla.org/MPL/2.0/. +; +; See the COPYRIGHT file distributed with this work for additional +; information regarding copyright ownership. + +$ORIGIN . +$TTL 20 +child.parent.nil IN SOA ns.child.parent.nil. hostmaster.parent.nil. ( + 1 ; serial + 2000 ; refresh (33 minutes 20 seconds) + 2000 ; retry (33 minutes 20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) + NS ns.child.parent.nil. +$ORIGIN child.parent.nil. +$TTL 300 ; 5 minutes +ns A 10.53.0.3 diff --git a/bin/tests/system/metadata/clean.sh b/bin/tests/system/metadata/clean.sh new file mode 100644 index 0000000..af83095 --- /dev/null +++ b/bin/tests/system/metadata/clean.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +rm -f K* dsset-* *.signed *.new +rm -f zsk.key ksk.key parent.ksk.key parent.zsk.key +rm -f pending.key rolling.key standby.key inact.key +rm -f prerev.key postrev.key oldstyle.key +rm -f keys sigs +rm -f tmp.out +rm -f settime1.test* settime2.test* +rm -f ns*/named.lock diff --git a/bin/tests/system/metadata/parent.db b/bin/tests/system/metadata/parent.db new file mode 100644 index 0000000..6c6567f --- /dev/null +++ b/bin/tests/system/metadata/parent.db @@ -0,0 +1,29 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; This Source Code Form is subject to the terms of the Mozilla Public +; License, v. 2.0. If a copy of the MPL was not distributed with this +; file, You can obtain one at http://mozilla.org/MPL/2.0/. +; +; See the COPYRIGHT file distributed with this work for additional +; information regarding copyright ownership. + +$ORIGIN . +$TTL 300 ; 5 minutes +parent.nil IN SOA ns1.parent.nil. hostmaster.parent.nil. ( + 1 ; serial + 2000 ; refresh (33 minutes 20 seconds) + 2000 ; retry (33 minutes 20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) + NS ns1.parent.nil. + NS ns2.parent.nil. +$ORIGIN parent.nil. +$TTL 3600 ; 1 hour +a A 1.1.1.1 +$TTL 300 ; 5 minutes +ns1 A 10.53.0.1 +ns2 A 10.53.0.2 + +child NS ns.child +ns.child A 10.53.0.3 diff --git a/bin/tests/system/metadata/prereq.sh b/bin/tests/system/metadata/prereq.sh new file mode 100644 index 0000000..a0d4e9c --- /dev/null +++ b/bin/tests/system/metadata/prereq.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +exec $SHELL ../testcrypto.sh diff --git a/bin/tests/system/metadata/setup.sh b/bin/tests/system/metadata/setup.sh new file mode 100644 index 0000000..ae5b11f --- /dev/null +++ b/bin/tests/system/metadata/setup.sh @@ -0,0 +1,63 @@ +#!/bin/sh -e +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +$SHELL ./clean.sh + +test -r $RANDFILE || $GENRANDOM 400 $RANDFILE + +pzone=parent.nil +czone=child.parent.nil + +echo_i "generating keys" + +# active zsk +zsk=`$KEYGEN -q -r $RANDFILE $czone` +echo $zsk > zsk.key + +# not yet published or active +pending=`$KEYGEN -q -r $RANDFILE -P none -A none $czone` +echo $pending > pending.key + +# published but not active +standby=`$KEYGEN -q -r $RANDFILE -A none $czone` +echo $standby > standby.key + +# inactive +inact=`$KEYGEN -q -r $RANDFILE -P now-24h -A now-24h -I now $czone` +echo $inact > inact.key + +# active ksk +ksk=`$KEYGEN -q -r $RANDFILE -fk $czone` +echo $ksk > ksk.key + +# published but not YET active; will be active in 15 seconds +rolling=`$KEYGEN -q -r $RANDFILE -fk $czone` +$SETTIME -A now+15s $rolling > /dev/null +echo $rolling > rolling.key + +# revoked +revoke1=`$KEYGEN -q -r $RANDFILE -fk $czone` +echo $revoke1 > prerev.key +revoke2=`$REVOKE $revoke1` +echo $revoke2 | sed -e 's#\./##' -e "s/\.key.*$//" > postrev.key + +pzsk=`$KEYGEN -q -r $RANDFILE $pzone` +echo $pzsk > parent.zsk.key + +pksk=`$KEYGEN -q -r $RANDFILE -fk $pzone` +echo $pksk > parent.ksk.key + +oldstyle=`$KEYGEN -Cq -r $RANDFILE $pzone` +echo $oldstyle > oldstyle.key + diff --git a/bin/tests/system/metadata/tests.sh b/bin/tests/system/metadata/tests.sh new file mode 100644 index 0000000..5eb0938 --- /dev/null +++ b/bin/tests/system/metadata/tests.sh @@ -0,0 +1,211 @@ +#!/bin/sh +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +pzone=parent.nil pfile=parent.db +czone=child.parent.nil cfile=child.db +status=0 +n=1 + +echo_i "setting key timers" +$SETTIME -A now+15s `cat rolling.key` > /dev/null + +inact=`sed 's/^K'${czone}'.+005+0*\([0-9]\)/\1/' < inact.key` +ksk=`sed 's/^K'${czone}'.+005+0*\([0-9]\)/\1/' < ksk.key` +pending=`sed 's/^K'${czone}'.+005+0*\([0-9]\)/\1/' < pending.key` +postrev=`sed 's/^K'${czone}'.+005+0*\([0-9]\)/\1/' < postrev.key` +prerev=`sed 's/^K'${czone}'.+005+0*\([0-9]\)/\1/' < prerev.key` +rolling=`sed 's/^K'${czone}'.+005+0*\([0-9]\)/\1/' < rolling.key` +standby=`sed 's/^K'${czone}'.+005+0*\([0-9]\)/\1/' < standby.key` +zsk=`sed 's/^K'${czone}'.+005+0*\([0-9]\)/\1/' < zsk.key` + +echo_i "signing zones" +$SIGNER -Sg -o $czone $cfile > /dev/null 2>&1 +$SIGNER -Sg -o $pzone $pfile > /dev/null 2>&1 + +awk '$2 ~ /RRSIG/ { + type = $3; + getline; + id = $3; + if ($4 ~ /'${czone}'/) { + print type, id + } +}' < ${cfile}.signed > sigs + +awk '$2 ~ /DNSKEY/ { + flags = $3; + while ($0 !~ /key id =/) + getline; + id = $NF; + print flags, id; +}' < ${cfile}.signed > keys + +echo_i "checking that KSK signed DNSKEY only ($n)" +ret=0 +grep "DNSKEY $ksk"'$' sigs > /dev/null || ret=1 +grep "SOA $ksk"'$' sigs > /dev/null && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking that ZSK signed ($n)" +ret=0 +grep "SOA $zsk"'$' sigs > /dev/null || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking that standby ZSK did not sign ($n)" +ret=0 +grep " $standby"'$' sigs > /dev/null && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking that inactive key did not sign ($n)" +ret=0 +grep " $inact"'$' sigs > /dev/null && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking that pending key was not published ($n)" +ret=0 +grep " $pending"'$' keys > /dev/null && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking that standby KSK did not sign but is delegated ($n)" +ret=0 +grep " $rolling"'$' sigs > /dev/null && ret=1 +grep " $rolling"'$' keys > /dev/null || ret=1 +egrep "DS[ ]*$rolling[ ]" ${pfile}.signed > /dev/null || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking that key was revoked ($n)" +ret=0 +grep " $prerev"'$' keys > /dev/null && ret=1 +grep " $postrev"'$' keys > /dev/null || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking that revoked key self-signed ($n)" +ret=0 +grep "DNSKEY $postrev"'$' sigs > /dev/null || ret=1 +grep "SOA $postrev"'$' sigs > /dev/null && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "waiting 20 seconds for key changes to occur" +sleep 20 + +echo_i "re-signing zone" +$SIGNER -Sg -o $czone -f ${cfile}.new ${cfile}.signed > /dev/null 2>&1 + +echo_i "checking that standby KSK is now active ($n)" +ret=0 +grep "DNSKEY $rolling"'$' sigs > /dev/null && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking update of an old-style key ($n)" +ret=0 +# printing metadata should not work with an old-style key +$SETTIME -pall `cat oldstyle.key` > /dev/null 2>&1 && ret=1 +$SETTIME -f `cat oldstyle.key` > /dev/null 2>&1 || ret=1 +# but now it should +$SETTIME -pall `cat oldstyle.key` > /dev/null 2>&1 || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking warning about permissions change on key with dnssec-settime ($n)" +uname=`uname -o 2> /dev/null` +if [ Cygwin == "$uname" ]; then + echo_i "Cygwin detected, skipping" +else + ret=0 + # settime should print a warning about changing the permissions + chmod 644 `cat oldstyle.key`.private + $SETTIME -P none `cat oldstyle.key` > settime1.test$n 2>&1 || ret=1 + grep "warning: Permissions on the file.*have changed" settime1.test$n > /dev/null 2>&1 || ret=1 + $SETTIME -P none `cat oldstyle.key` > settime2.test$n 2>&1 || ret=1 + grep "warning: Permissions on the file.*have changed" settime2.test$n > /dev/null 2>&1 && ret=1 + n=`expr $n + 1` + if [ $ret != 0 ]; then echo_i "failed"; fi + status=`expr $status + $ret` +fi + +echo_i "checking warning about delete date < inactive date with dnssec-settime ($n)" +ret=0 +# settime should print a warning about delete < inactive +$SETTIME -I now+15s -D now `cat oldstyle.key` > tmp.out 2>&1 || ret=1 +grep "warning" tmp.out > /dev/null 2>&1 || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking no warning about delete date < inactive date with dnssec-settime when delete date is unset ($n)" +ret=0 +$SETTIME -D none `cat oldstyle.key` > tmp.out 2>&1 || ret=1 +$SETTIME -p all `cat oldstyle.key` > tmp.out 2>&1 || ret=1 +grep "warning" tmp.out > /dev/null 2>&1 && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking warning about delete date < inactive date with dnssec-keygen ($n)" +ret=0 +# keygen should print a warning about delete < inactive +$KEYGEN -q -r $RANDFILE -I now+15s -D now $czone > tmp.out 2>&1 || ret=1 +grep "warning" tmp.out > /dev/null 2>&1 || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking correct behavior setting activation without publication date ($n)" +ret=0 +key=`$KEYGEN -q -r $RANDFILE -A +1w $czone` +pub=`$SETTIME -upP $key | awk '{print $2}'` +act=`$SETTIME -upA $key | awk '{print $2}'` +[ $pub -eq $act ] || ret=1 +key=`$KEYGEN -q -r $RANDFILE -A +1w -i 1d $czone` +pub=`$SETTIME -upP $key | awk '{print $2}'` +act=`$SETTIME -upA $key | awk '{print $2}'` +[ $pub -lt $act ] || ret=1 +key=`$KEYGEN -q -r $RANDFILE -A +1w -P never $czone` +pub=`$SETTIME -upP $key | awk '{print $2}'` +[ $pub = "UNSET" ] || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "checking calculation of dates for a successor key ($n)" +ret=0 +oldkey=`$KEYGEN -q -r $RANDFILE $czone` +newkey=`$KEYGEN -q -r $RANDFILE $czone` +$SETTIME -A -2d -I +2d $oldkey > settime1.test$n 2>&1 || ret=1 +$SETTIME -i 1d -S $oldkey $newkey > settime2.test$n 2>&1 || ret=1 +$SETTIME -pA $newkey | grep "1970" > /dev/null && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "exit status: $status" +[ $status -eq 0 ] || exit 1 |