From 45d6379135504814ab723b57f0eb8be23393a51d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 09:24:22 +0200 Subject: Adding upstream version 1:9.16.44. Signed-off-by: Daniel Baumann --- bin/tests/system/zero/ans5/ans.pl | 81 +++++++++++++++++++++ bin/tests/system/zero/clean.sh | 22 ++++++ bin/tests/system/zero/ns1/named.conf.in | 29 ++++++++ bin/tests/system/zero/ns1/root.db | 26 +++++++ bin/tests/system/zero/ns2/named.args | 1 + bin/tests/system/zero/ns2/named.conf.in | 34 +++++++++ bin/tests/system/zero/ns2/tld.db | 20 ++++++ bin/tests/system/zero/ns3/named.args | 1 + bin/tests/system/zero/ns3/named.conf.in | 29 ++++++++ bin/tests/system/zero/ns3/root.hint | 13 ++++ bin/tests/system/zero/ns4/named.args | 1 + bin/tests/system/zero/ns4/named.conf.in | 35 +++++++++ bin/tests/system/zero/ns4/one.tld.db | 17 +++++ bin/tests/system/zero/prereq.sh | 23 ++++++ bin/tests/system/zero/setup.sh | 22 ++++++ bin/tests/system/zero/tests.sh | 122 ++++++++++++++++++++++++++++++++ 16 files changed, 476 insertions(+) create mode 100644 bin/tests/system/zero/ans5/ans.pl create mode 100644 bin/tests/system/zero/clean.sh create mode 100644 bin/tests/system/zero/ns1/named.conf.in create mode 100644 bin/tests/system/zero/ns1/root.db create mode 100644 bin/tests/system/zero/ns2/named.args create mode 100644 bin/tests/system/zero/ns2/named.conf.in create mode 100644 bin/tests/system/zero/ns2/tld.db create mode 100644 bin/tests/system/zero/ns3/named.args create mode 100644 bin/tests/system/zero/ns3/named.conf.in create mode 100644 bin/tests/system/zero/ns3/root.hint create mode 100644 bin/tests/system/zero/ns4/named.args create mode 100644 bin/tests/system/zero/ns4/named.conf.in create mode 100644 bin/tests/system/zero/ns4/one.tld.db create mode 100644 bin/tests/system/zero/prereq.sh create mode 100644 bin/tests/system/zero/setup.sh create mode 100644 bin/tests/system/zero/tests.sh (limited to 'bin/tests/system/zero') diff --git a/bin/tests/system/zero/ans5/ans.pl b/bin/tests/system/zero/ans5/ans.pl new file mode 100644 index 0000000..3ca1083 --- /dev/null +++ b/bin/tests/system/zero/ans5/ans.pl @@ -0,0 +1,81 @@ +#!/usr/bin/perl -w + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# 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 https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +# +# Don't respond if the "norespond" file exists; otherwise respond to +# any A or AAAA query. +# + +use IO::File; +use IO::Socket; +use Net::DNS; +use Net::DNS::Packet; + +my $localport = int($ENV{'PORT'}); +if (!$localport) { $localport = 5300; } + +my $sock = IO::Socket::INET->new(LocalAddr => "10.53.0.5", + LocalPort => $localport, Proto => "udp") or die "$!"; + +my $pidf = new IO::File "ans.pid", "w" or die "cannot open pid file: $!"; +print $pidf "$$\n" or die "cannot write pid file: $!"; +$pidf->close or die "cannot close pid file: $!"; +sub rmpid { unlink "ans.pid"; exit 1; }; + +$SIG{INT} = \&rmpid; +$SIG{TERM} = \&rmpid; + +my $octet = 0; + +for (;;) { + $sock->recv($buf, 512); + + print "**** request from " , $sock->peerhost, " port ", $sock->peerport, "\n"; + + my $packet; + + if ($Net::DNS::VERSION > 0.68) { + $packet = new Net::DNS::Packet(\$buf, 0); + $@ and die $@; + } else { + my $err; + ($packet, $err) = new Net::DNS::Packet(\$buf, 0); + $err and die $err; + } + + print "REQUEST:\n"; + $packet->print; + + $packet->header->qr(1); + + my @questions = $packet->question; + my $qname = $questions[0]->qname; + my $qtype = $questions[0]->qtype; + + $packet->header->aa(1); + if ($qtype eq "A") { + $packet->push("answer", + new Net::DNS::RR($qname . + " 0 A 192.0.2." . $octet)); + $octet = $octet + 1; + } elsif ($qtype eq "AAAA") { + $packet->push("answer", + new Net::DNS::RR($qname . + " 300 AAAA 2001:db8:beef::1")); + } + + $sock->send($packet->data); + print "RESPONSE:\n"; + $packet->print; + print "\n"; +} diff --git a/bin/tests/system/zero/clean.sh b/bin/tests/system/zero/clean.sh new file mode 100644 index 0000000..2ef5727 --- /dev/null +++ b/bin/tests/system/zero/clean.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# 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 https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +rm -f */named.conf +rm -f */named.run +rm -f */named.memstats +rm -f ns2/example.db +rm -f ns4/example.bk +rm -f dig.out* +rm -f query.list +rm -f ns*/named.lock +rm -f ns*/managed-keys.bind* diff --git a/bin/tests/system/zero/ns1/named.conf.in b/bin/tests/system/zero/ns1/named.conf.in new file mode 100644 index 0000000..1334c85 --- /dev/null +++ b/bin/tests/system/zero/ns1/named.conf.in @@ -0,0 +1,29 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * 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 https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + query-source address 10.53.0.1; + notify-source 10.53.0.1; + transfer-source 10.53.0.1; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.1; }; + listen-on-v6 { none; }; + recursion no; + dnssec-validation no; +}; + +zone "." { + type primary; + file "root.db"; +}; diff --git a/bin/tests/system/zero/ns1/root.db b/bin/tests/system/zero/ns1/root.db new file mode 100644 index 0000000..fbcb3e2 --- /dev/null +++ b/bin/tests/system/zero/ns1/root.db @@ -0,0 +1,26 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; SPDX-License-Identifier: MPL-2.0 +; +; 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 https://mozilla.org/MPL/2.0/. +; +; See the COPYRIGHT file distributed with this work for additional +; information regarding copyright ownership. + +$TTL 300 +@ SOA ns1. hostmaster.warn.example. ( + 1 3600 1200 604800 3600 ) + NS ns1. +ns1. A 10.53.0.1 +; +example. NS ns2.example. +ns2.example. A 10.53.0.2 +example. NS ns4.example. +ns4.example. A 10.53.0.4 +increment. NS incrementns. +incrementns. A 10.53.0.5 +tld. NS ns2.tld. +ns2.tld. A 10.53.0.2 + diff --git a/bin/tests/system/zero/ns2/named.args b/bin/tests/system/zero/ns2/named.args new file mode 100644 index 0000000..b20594e --- /dev/null +++ b/bin/tests/system/zero/ns2/named.args @@ -0,0 +1 @@ +-m record,size,mctx -c named.conf -d 1 -D zero-ns2 -X named.lock -g -T maxcachesize=2097152 diff --git a/bin/tests/system/zero/ns2/named.conf.in b/bin/tests/system/zero/ns2/named.conf.in new file mode 100644 index 0000000..751eafd --- /dev/null +++ b/bin/tests/system/zero/ns2/named.conf.in @@ -0,0 +1,34 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * 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 https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + query-source address 10.53.0.2; + notify-source 10.53.0.2; + transfer-source 10.53.0.2; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.2; }; + listen-on-v6 { none; }; + recursion no; + dnssec-validation no; +}; + +zone "example" { + type primary; + file "example.db"; +}; + +zone "tld" { + type primary; + file "tld.db"; +}; diff --git a/bin/tests/system/zero/ns2/tld.db b/bin/tests/system/zero/ns2/tld.db new file mode 100644 index 0000000..0ffeb05 --- /dev/null +++ b/bin/tests/system/zero/ns2/tld.db @@ -0,0 +1,20 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; SPDX-License-Identifier: MPL-2.0 +; +; 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 https://mozilla.org/MPL/2.0/. +; +; See the COPYRIGHT file distributed with this work for additional +; information regarding copyright ownership. + +$TTL 1 +@ 300 SOA ns2.tld. hostmaster.ns2.tld. 0 1 1 1 1 +@ 300 NS ns2.tld. +ns2 300 A 10.53.0.2 +; +; The TTL of these delegation records needs to 1. +; +one 1 NS ns4.one.tld. +ns4.one 1 A 10.53.0.4 diff --git a/bin/tests/system/zero/ns3/named.args b/bin/tests/system/zero/ns3/named.args new file mode 100644 index 0000000..9d89bd6 --- /dev/null +++ b/bin/tests/system/zero/ns3/named.args @@ -0,0 +1 @@ +-m record,size,mctx -c named.conf -d 1 -D zero-ns3 -X named.lock -g -T maxcachesize=2097152 diff --git a/bin/tests/system/zero/ns3/named.conf.in b/bin/tests/system/zero/ns3/named.conf.in new file mode 100644 index 0000000..3492b9f --- /dev/null +++ b/bin/tests/system/zero/ns3/named.conf.in @@ -0,0 +1,29 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * 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 https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + query-source address 10.53.0.3; + notify-source 10.53.0.3; + transfer-source 10.53.0.3; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.3; }; + listen-on-v6 { none; }; + recursion yes; + dnssec-validation yes; +}; + +zone "." { + type hint; + file "root.hint"; +}; diff --git a/bin/tests/system/zero/ns3/root.hint b/bin/tests/system/zero/ns3/root.hint new file mode 100644 index 0000000..206e952 --- /dev/null +++ b/bin/tests/system/zero/ns3/root.hint @@ -0,0 +1,13 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; SPDX-License-Identifier: MPL-2.0 +; +; 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 https://mozilla.org/MPL/2.0/. +; +; See the COPYRIGHT file distributed with this work for additional +; information regarding copyright ownership. + +. NS ns1. +ns1. A 10.53.0.1 diff --git a/bin/tests/system/zero/ns4/named.args b/bin/tests/system/zero/ns4/named.args new file mode 100644 index 0000000..09d1fe0 --- /dev/null +++ b/bin/tests/system/zero/ns4/named.args @@ -0,0 +1 @@ +-m record,size,mctx -c named.conf -d 1 -D zero-ns4 -X named.lock -g -T maxcachesize=2097152 diff --git a/bin/tests/system/zero/ns4/named.conf.in b/bin/tests/system/zero/ns4/named.conf.in new file mode 100644 index 0000000..fc8fec6 --- /dev/null +++ b/bin/tests/system/zero/ns4/named.conf.in @@ -0,0 +1,35 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * 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 https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + query-source address 10.53.0.4; + notify-source 10.53.0.4; + transfer-source 10.53.0.4; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.4; }; + listen-on-v6 { none; }; + recursion no; + dnssec-validation yes; +}; + +zone "example" { + type secondary; + primaries { 10.53.0.2; }; + file "example.bk"; +}; + +zone "one.tld" { + type primary; + file "one.tld.db"; +}; diff --git a/bin/tests/system/zero/ns4/one.tld.db b/bin/tests/system/zero/ns4/one.tld.db new file mode 100644 index 0000000..491ba87 --- /dev/null +++ b/bin/tests/system/zero/ns4/one.tld.db @@ -0,0 +1,17 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; SPDX-License-Identifier: MPL-2.0 +; +; 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 https://mozilla.org/MPL/2.0/. +; +; See the COPYRIGHT file distributed with this work for additional +; information regarding copyright ownership. + +$TTL 1 +; The TTL of all these records needs to be 1. +@ 1 SOA ns4.one.tld. hostmaster.ns4.tld. 0 1 1 1 1 +@ 1 NS ns4.one.tld. +ns4 1 A 10.53.0.4 +www 1 A 10.53.0.4 diff --git a/bin/tests/system/zero/prereq.sh b/bin/tests/system/zero/prereq.sh new file mode 100644 index 0000000..ec369f8 --- /dev/null +++ b/bin/tests/system/zero/prereq.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# 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 https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +if $PERL -e 'use Net::DNS;' 2>/dev/null +then + : +else + echo_i "This test requires the Net::DNS library." >&2 + exit 1 +fi diff --git a/bin/tests/system/zero/setup.sh b/bin/tests/system/zero/setup.sh new file mode 100644 index 0000000..592034c --- /dev/null +++ b/bin/tests/system/zero/setup.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# 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 https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +copy_setports ns1/named.conf.in ns1/named.conf +copy_setports ns2/named.conf.in ns2/named.conf +copy_setports ns3/named.conf.in ns3/named.conf +copy_setports ns4/named.conf.in ns4/named.conf + +$SHELL ../genzone.sh 2 4 | sed -e 's/^$TTL 3600$/$TTL 0 ; force TTL to zero/' -e 's/86400.IN SOA/0 SOA/' > ns2/example.db diff --git a/bin/tests/system/zero/tests.sh b/bin/tests/system/zero/tests.sh new file mode 100644 index 0000000..0449552 --- /dev/null +++ b/bin/tests/system/zero/tests.sh @@ -0,0 +1,122 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# 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 https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +#shellcheck source=conf.sh +SYSTEMTESTTOP=.. +. "$SYSTEMTESTTOP/conf.sh" + +dig_with_opts() { + "$DIG" -p "${PORT}" "$@" +} + +wait_for_pid() ( + for pid in "$@"; do + kill -0 "$pid" 2>/dev/null && return 1 + done + return 0 +) + +status=0 +n=0 + +n=$((n+1)) +echo_i "check lookups against TTL=0 records ($n)" +i=0 +ret=0 +passes=10 +dig_with_opts @10.53.0.2 axfr example | grep -v "^ds0" | \ +awk '$2 == "0" { print "-q", $1, $4; print "-q", "zzz"$1, $4;}' > query.list + +# add 1/5 second per query +timeout=$(($(wc -l < query.list) / 5)) +while [ $i -lt $passes ] +do + (dig_with_opts @10.53.0.3 -f query.list > "dig.out$i.1.test$n") & pid1="$!" + (dig_with_opts @10.53.0.3 -f query.list > "dig.out$i.2.test$n") & pid2="$!" + (dig_with_opts @10.53.0.3 -f query.list > "dig.out$i.3.test$n") & pid3="$!" + (dig_with_opts @10.53.0.3 -f query.list > "dig.out$i.4.test$n") & pid4="$!" + (dig_with_opts @10.53.0.3 -f query.list > "dig.out$i.5.test$n") & pid5="$!" + (dig_with_opts @10.53.0.3 -f query.list > "dig.out$i.6.test$n") & pid6="$!" + + retry_quiet "$timeout" wait_for_pid "$pid1" "$pid2" "$pid3" "$pid4" "$pid5" "$pid6" || ret=1 + kill -TERM "$pid1" "$pid2" "$pid3" "$pid4" "$pid5" "$pid6" 2>/dev/null + + wait "$pid1" || ret=1 + wait "$pid2" || ret=1 + wait "$pid3" || ret=1 + wait "$pid4" || ret=1 + wait "$pid5" || ret=1 + wait "$pid6" || ret=1 + + grep "status: SERVFAIL" "dig.out$i.1.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.2.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.3.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.4.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.5.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.6.test$n" > /dev/null && ret=1 + [ $ret = 1 ] && break + i=$((i+1)) + echo_i "successfully completed pass $i of $passes" +done +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status+ret)) + +repeat_query() ( + i=0 + while [ "$i" -lt "$1" ]; do + dig_with_opts +short "@$2" "$3" | tee "dig.out$i.test$n" || return 1 + i=$((i+1)) + done +) + +count_unique() ( + repeat_query "$@" | sort -u | wc -l +) + +n=$((n+1)) +echo_i "check repeated recursive lookups of non recurring TTL=0 responses get new values ($n)" +ret=0 +repeats=9 +count=$(count_unique "$repeats" 10.53.0.3 foo.increment) +if [ "$count" -ne "$repeats" ] ; then echo_i "failed (count=$count, repeats=$repeats)"; ret=1; fi +status=$((status+ret)) + +n=$((n+1)) +echo_i "check lookups against TTL=1 records ($n)" +i=0 +passes=10 +ret=0 +while [ $i -lt $passes ] +do + dig_with_opts @10.53.0.3 www.one.tld > "dig.out$i.1.test$n" || ret=1 + dig_with_opts @10.53.0.3 www.one.tld > "dig.out$i.2.test$n" || ret=1 + dig_with_opts @10.53.0.3 www.one.tld > "dig.out$i.3.test$n" || ret=1 + dig_with_opts @10.53.0.3 www.one.tld > "dig.out$i.4.test$n" || ret=1 + dig_with_opts @10.53.0.3 www.one.tld > "dig.out$i.5.test$n" || ret=1 + dig_with_opts @10.53.0.3 www.one.tld > "dig.out$i.6.test$n" || ret=1 + grep "status: SERVFAIL" "dig.out$i.1.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.2.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.3.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.4.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.5.test$n" > /dev/null && ret=1 + grep "status: SERVFAIL" "dig.out$i.6.test$n" > /dev/null && ret=1 + [ $ret = 1 ] && break + i=$((i+1)) + echo_i "successfully completed pass $i of $passes" + sleep 1 +done +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status+ret)) + +echo_i "exit status: $status" +[ "$status" -eq 0 ] || exit 1 -- cgit v1.2.3