]> 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>
Fri, 1 May 2020 23:47:54 +0000 (16: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.

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

diff --git a/CHANGES b/CHANGES
index 173cacd838db2f9affd3a8dcb38f6d765c77f9b0..75529d89ec75ee2ad623a4b67fdd262bbf18cb18 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]
+
 5403.  [func]          Don't set udp recv/send buffer sizes, sockets will
                        use system defaults. [GL #1713]
 
index 444941db797ff892a8c39a114c0d2c50e30e14f3..a6884833b5f9993f774b9b72ff8f7918a9468ef9 100644 (file)
@@ -530,7 +530,12 @@ load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx,
                }
 
                classobj = cfg_tuple_get(vconfig, "class");
-               CHECK(config_getclass(classobj, dns_rdataclass_in, &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);
                }
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 0b62e27b71f509410aac9ccd2a3fe5eef01c0c5d..a3901111faf900e3316bf2d36fd6419278aeac3e 100644 (file)
@@ -364,6 +364,13 @@ grep "zone shared.example/IN: loaded serial" < checkconf.out$n > /dev/null || re
 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