]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
test failure conditions
authorEvan Hunt <each@isc.org>
Thu, 10 Nov 2022 05:56:16 +0000 (21:56 -0800)
committerMichał Kępień <michal@isc.org>
Thu, 12 Jan 2023 11:21:36 +0000 (12:21 +0100)
verify that updates are refused when the client is disallowed by
allow-query, and update forwarding is refused when the client is
is disallowed by update-forwarding.

verify that "too many DNS UPDATEs" appears in the log file when too
many simultaneous updates are processing.

(cherry picked from commit b91339b80e5b82a56622c93cc1e3cca2d0c11bc0)

bin/tests/system/nsupdate/ns1/named.conf.in
bin/tests/system/nsupdate/tests.sh
bin/tests/system/upforwd/clean.sh
bin/tests/system/upforwd/ns3/named1.conf.in [moved from bin/tests/system/upforwd/ns3/named.conf.in with 79% similarity]
bin/tests/system/upforwd/ns3/named2.conf.in [new file with mode: 0644]
bin/tests/system/upforwd/setup.sh
bin/tests/system/upforwd/tests.sh

index 81d0c99af8e67c95542a651a567691db9b4fd517..a5cc36dec5a601d4adc9245f827563abd9f450c4 100644 (file)
@@ -23,6 +23,7 @@ options {
        recursion no;
        notify yes;
        minimal-responses no;
+       update-quota 1;
 };
 
 acl named-acl {
@@ -83,6 +84,7 @@ zone "other.nil" {
        check-integrity no;
        check-mx warn;
        update-policy local;
+       allow-query { !10.53.0.2; any; };
        allow-query-on { 10.53.0.1; 127.0.0.1; };
        allow-transfer { any; };
 };
index ee634d72570262b8c676a4ff1f422b7d24d105a9..67ffc27c1b4d0aa4473bb3e26da9bda36f17ab4f 100755 (executable)
@@ -1288,6 +1288,34 @@ END
 grep "NSEC3PARAM has excessive iterations (> 150)" nsupdate.out-$n >/dev/null || ret=1
 [ $ret = 0 ] || { echo_i "failed"; status=1; }
 
+n=$((n + 1))
+ret=0
+echo_i "check that update is rejected if query is not allowed ($n)"
+{
+  $NSUPDATE -d <<END
+  local 10.53.0.2
+  server 10.53.0.1 ${PORT}
+  update add reject.other.nil 3600 IN TXT Whatever
+  send
+END
+} > nsupdate.out.test$n 2>&1
+grep 'failed: REFUSED' nsupdate.out.test$n > /dev/null || ret=1
+[ $ret = 0 ] || { echo_i "failed"; status=1; }
+
+n=$((n + 1))
+ret=0
+echo_i "check that update is rejected if quota is exceeded ($n)"
+for loop in 1 2 3 4 5 6 7 8 9 10; do
+{
+  $NSUPDATE -4 -l -p ${PORT} -k ns1/session.key > /dev/null 2>&1 <<END
+  update add txt-$loop.other.nil 3600 IN TXT Whatever
+  send
+END
+} &
+done
+wait_for_log 10 "too many DNS UPDATEs queued" ns1/named.run || ret=1
+[ $ret = 0 ] || { echo_i "failed"; status=1; }
+
 if ! $FEATURETEST --gssapi ; then
   echo_i "SKIPPED: GSSAPI tests"
 else
index 9370bc8d70280ece8d479c7f9e0d324347560f53..14a7d295f8f4abc469012f4b18ca7f0e2aa58c61 100644 (file)
@@ -31,3 +31,5 @@ rm -f keyname keyname.err
 rm -f ns*/named.lock
 rm -f ns1/example2.db
 rm -f ns*/managed-keys.bind*
+rm -f nsupdate.out.*
+rm -f ns*/named.run.prev
similarity index 79%
rename from bin/tests/system/upforwd/ns3/named.conf.in
rename to bin/tests/system/upforwd/ns3/named1.conf.in
index 7ff44655fe45c84739f97f9b6003b03239784d85..61d42c89544bc5e76adc0742270d3a8298543f10 100644 (file)
@@ -30,20 +30,27 @@ key rndc_key {
 };
 
 controls {
-        inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
+       inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
 };
 
 zone "example" {
        type secondary;
        file "example.bk";
-       allow-update-forwarding { any; };
+       allow-update-forwarding { 10.53.0.1; };
        primaries { 10.53.0.1; };
 };
 
 zone "example2" {
        type secondary;
        file "example2.bk";
-       allow-update-forwarding { any; };
+       allow-update-forwarding { 10.53.0.1; };
+       primaries { 10.53.0.1; };
+};
+
+zone "example3" {
+       type secondary;
+       file "example3.bk";
+       allow-update-forwarding { 10.53.0.1; };
        primaries { 10.53.0.1; };
 };
 
diff --git a/bin/tests/system/upforwd/ns3/named2.conf.in b/bin/tests/system/upforwd/ns3/named2.conf.in
new file mode 100644 (file)
index 0000000..86d7469
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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 no;
+       notify yes;
+       update-quota 1;
+};
+
+key rndc_key {
+       secret "1234abcd8765";
+       algorithm @DEFAULT_HMAC@;
+};
+
+controls {
+       inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
+};
+
+zone "example" {
+       type secondary;
+       file "example.bk";
+       allow-update-forwarding { any; };
+       primaries { 10.53.0.1; };
+};
index a7af70efd73710c488aa09890c2da7bdb6c93d33..c7c9afc6035484a8471427b1f5e086a4f379148f 100644 (file)
@@ -19,7 +19,7 @@ cp -f ns3/nomaster.db ns3/nomaster1.db
 
 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 ns3/named1.conf.in ns3/named.conf
 
 if $FEATURETEST --enable-dnstap
 then
index c0293b3132efc0bc8c6f3ba4bec883b97104d1cd..35c55880b3a9da96d95db5a6320e2147611f7a30 100644 (file)
@@ -82,6 +82,7 @@ if [ $ret != 0 ] ; then echo_i "failed"; status=`expr $status + $ret`; fi
 echo_i "updating zone (signed) ($n)"
 ret=0
 $NSUPDATE -y update.example:c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K -- - <<EOF || ret=1
+local 10.53.0.1
 server 10.53.0.3 ${PORT}
 update add updated.example. 600 A 10.10.10.1
 update add updated.example. 600 TXT Foo
@@ -140,6 +141,7 @@ fi
 echo_i "updating zone (unsigned) ($n)"
 ret=0
 $NSUPDATE -- - <<EOF || ret=1
+local 10.53.0.1
 server 10.53.0.3 ${PORT}
 update add unsigned.example. 600 A 10.10.10.1
 update add unsigned.example. 600 TXT Foo
@@ -196,6 +198,7 @@ while [ $count -lt 5 -a $ret -eq 0 ]
 do
 (
 $NSUPDATE -- - <<EOF 
+local 10.53.0.1
 server 10.53.0.3 ${PORT}
 zone nomaster
 update add unsigned.nomaster. 600 A 10.10.10.1
@@ -227,6 +230,7 @@ then
        ret=0
        keyname=`cat keyname`
        $NSUPDATE -k $keyname.private -- - <<EOF
+       local 10.53.0.1
        server 10.53.0.3 ${PORT}
        zone example2
        update add unsigned.example2. 600 A 10.10.10.1
@@ -251,5 +255,40 @@ EOF
        fi
 fi
 
+echo_i "attempting an update that should be rejected by ACL ($n)"
+ret=0
+{
+        $NSUPDATE -- - << EOF
+        local 10.53.0.2
+        server 10.53.0.3 ${PORT}
+        update add another.unsigned.example. 600 A 10.10.10.2
+        update add another.unsigned.example. 600 TXT Bar
+        send
+EOF
+} > nsupdate.out.$n 2>&1
+grep REFUSED nsupdate.out.$n > /dev/null || ret=1
+if [ $ret != 0 ] ; then echo_i "failed"; status=`expr $status + $ret`; fi
+n=`expr $n + 1`
+
+n=$((n + 1))
+ret=0
+echo_i "attempting updates that should exceed quota ($n)"
+# lower the update quota to 1.
+copy_setports ns3/named2.conf.in ns3/named.conf
+rndc_reconfig ns3 10.53.0.3
+nextpart ns3/named.run > /dev/null
+for loop in 1 2 3 4 5 6 7 8 9 10; do
+{
+  $NSUPDATE -- - > /dev/null 2>&1 <<END
+  local 10.53.0.1
+  server 10.53.0.3 ${PORT}
+  update add txt-$loop.unsigned.example 300 IN TXT Whatever
+  send
+END
+} &
+done
+wait_for_log 10 "too many DNS UPDATEs queued" ns3/named.run || ret=1
+[ $ret = 0 ] || { echo_i "failed"; status=1; }
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1