]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
named-checkconf -z could exit with an incorrect staatus
authorEvan Hunt <each@isc.org>
Thu, 30 Apr 2020 20:17:37 +0000 (13:17 -0700)
committerEvan Hunt <each@isc.org>
Sat, 2 May 2020 00:47:44 +0000 (17:47 -0700)
the CHECK() macro resets result, so an error code from an earlier
view could be erased if the last view loaded had no errors.

(cherry picked from commit 7e736602062a4f96b5ff5e89cd998db861362b03)

CHANGES
bin/check/named-checkconf.c
bin/tests/system/checkconf/check-missing-zone.conf [new file with mode: 0644]
bin/tests/system/checkconf/tests.sh
util/copyrights

diff --git a/CHANGES b/CHANGES
index cb37ce13f7fb68ee4f568f589ef0728d837f2791..ed5779da0dffc032cc343d98e80d6e5f921ece1e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+5404.  [bug]           'named-checkconf -z' could incorrectly indicate
+                       success if errors were found in one view but not in a
+                       subsequent one. [GL #1807]
+
 5398.  [bug]           Named could fail to restart if a zone added with
                        'rndc addzone' contained a double quote (") in
                        its name.  [GL #1695]
index ff1c0d260abe90e4ee4ea22206d435a5cea4547f..4c26c3ee51b24a3d99fe615155d056c8a5ae5966 100644 (file)
@@ -490,10 +490,15 @@ load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx) {
                        continue;
 
                classobj = cfg_tuple_get(vconfig, "class");
-               CHECK(config_getclass(classobj, dns_rdataclass_in,
-                                        &viewclass));
-               if (dns_rdataclass_ismeta(viewclass))
+               tresult = config_getclass(classobj, dns_rdataclass_in,
+                                         &viewclass);
+               if (tresult != ISC_R_SUCCESS) {
+                       CHECK(tresult);
+               }
+
+               if (dns_rdataclass_ismeta(viewclass)) {
                        CHECK(ISC_R_FAILURE);
+               }
 
                dns_rdataclass_format(viewclass, buf, sizeof(buf));
                vname = cfg_obj_asstring(cfg_tuple_get(vconfig, "name"));
diff --git a/bin/tests/system/checkconf/check-missing-zone.conf b/bin/tests/system/checkconf/check-missing-zone.conf
new file mode 100644 (file)
index 0000000..f43d3e2
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+view missing {
+       zone missing.example {
+               type master;
+               file "missing.example.db";
+       };
+};
+
+view good {
+       zone shared.example {
+               type master;
+               file "shared.example.db";
+       };
+};
index 3c6832574b7d5ef9245d966df4d534f127d88221..85fb4839e987e8646777671205ccf2be6ec6209c 100644 (file)
@@ -355,6 +355,13 @@ grep "zone shared.example/IN: loaded serial" < checkconf.out7 > /dev/null || ret
 if [ $ret != 0 ]; then echo_i "failed"; ret=1; fi
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo_i "check that named-checkconf -z returns error when a later view is okay ($n)"
+ret=0
+$CHECKCONF -z check-missing-zone.conf > checkconf.out$n 2>&1 && ret=1
+if [ $ret != 0 ]; then echo_i "failed"; ret=1; fi
+status=`expr $status + $ret`
+
 n=`expr $n + 1`
 echo_i "check that named-checkconf prints max-cache-size <percentage> correctly ($n)"
 ret=0
index b1933387295d14cbf922b8d12918d364b0e7ab85..aa8dae1289eaf901f1b3c4ec45763d76eb6f4605 100644 (file)
 ./bin/tests/system/checkconf/check-dlv-ksk-key.conf    CONF-C  2018,2019,2020
 ./bin/tests/system/checkconf/check-dup-records-fail.conf       CONF-C  2014,2016,2018,2019,2020
 ./bin/tests/system/checkconf/check-dup-records.db      ZONE    2014,2016,2018,2019,2020
+./bin/tests/system/checkconf/check-missing-zone.conf   CONF-C  2020
 ./bin/tests/system/checkconf/check-mx-cname-fail.conf  CONF-C  2014,2016,2018,2019,2020
 ./bin/tests/system/checkconf/check-mx-cname.db ZONE    2014,2016,2018,2019,2020
 ./bin/tests/system/checkconf/check-mx-fail.conf        CONF-C  2014,2016,2018,2019,2020