]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_8] check hint files in named-checkconf -z
authorEvan Hunt <each@isc.org>
Mon, 25 Nov 2013 21:24:16 +0000 (13:24 -0800)
committerEvan Hunt <each@isc.org>
Mon, 25 Nov 2013 21:24:16 +0000 (13:24 -0800)
3676. [bug] "named-checkconf -z" now checks zones of type
hint and redirect as well as master. [RT #35046]

(cherry picked from commit d999ca28d40337907b55eebc28a255b638702379)
(cherry picked from commit 2254826e4cab47a7a8b19ec566404f0aa6fe9e54)

CHANGES
bin/check/named-checkconf.c
bin/tests/system/checkconf/hint-nofile.conf [new file with mode: 0644]
bin/tests/system/checkconf/tests.sh

diff --git a/CHANGES b/CHANGES
index 0bcb6ef3235828e471afac30a56a47f7c1725af2..776dc8801c6d819042e551ace203acdfeefa7db3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3676.  [bug]           "named-checkconf -z" now checks zones of type
+                       hint as well as master. [RT #35046]
+
 3675.  [misc]          Provide a place for third parties to add version
                        information for their extensions in the version
                        file by setting the EXTENSIONS variable.
index ef754ff29af987923ffe084ee0d0329ed1cbbba2..52c89f0c0f23c13326fac1dd97a6e442693c8ed9 100644 (file)
 
 #include <bind9/check.h>
 
+#include <dns/db.h>
 #include <dns/fixedname.h>
 #include <dns/log.h>
 #include <dns/name.h>
+#include <dns/rdataclass.h>
 #include <dns/result.h>
+#include <dns/rootns.h>
 #include <dns/zone.h>
 
 #include "check-tool.h"
@@ -151,6 +154,30 @@ config_get(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj) {
        }
 }
 
+static isc_result_t
+configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
+       isc_result_t result;
+       dns_db_t *db = NULL;
+       dns_rdataclass_t rdclass;
+       isc_textregion_t r;
+
+       if (zfile == NULL)
+               return (ISC_R_FAILURE);
+
+       DE_CONST(zclass, r.base);
+       r.length = strlen(zclass);
+       result = dns_rdataclass_fromtext(&rdclass, &r);
+       if (result != ISC_R_SUCCESS)
+               return (result);
+
+       result = dns_rootns_create(mctx, rdclass, zfile, &db);
+       if (result != ISC_R_SUCCESS)
+               return (result);
+
+       dns_db_detach(&db);
+       return (ISC_R_SUCCESS);
+}
+
 /*% configure the zone */
 static isc_result_t
 configure_zone(const char *vclass, const char *view,
@@ -161,7 +188,7 @@ configure_zone(const char *vclass, const char *view,
        isc_result_t result;
        const char *zclass;
        const char *zname;
-       const char *zfile;
+       const char *zfile = NULL;
        const cfg_obj_t *maps[4];
        const cfg_obj_t *zoptions = NULL;
        const cfg_obj_t *classobj = NULL;
@@ -195,15 +222,26 @@ configure_zone(const char *vclass, const char *view,
        cfg_map_get(zoptions, "type", &typeobj);
        if (typeobj == NULL)
                return (ISC_R_FAILURE);
-       if (strcasecmp(cfg_obj_asstring(typeobj), "master") != 0)
+
+       cfg_map_get(zoptions, "file", &fileobj);
+       if (fileobj != NULL)
+               zfile = cfg_obj_asstring(fileobj);
+
+       /*
+        * Check hints files for hint zones.
+        * Skip loading checks for any type other than master.
+        */
+       if (strcasecmp(cfg_obj_asstring(typeobj), "hint") == 0)
+               return (configure_hint(zfile, zclass, mctx));
+       else if ((strcasecmp(cfg_obj_asstring(typeobj), "master") != 0))
                return (ISC_R_SUCCESS);
+
+       if (zfile == NULL)
+               return (ISC_R_FAILURE);
+
        cfg_map_get(zoptions, "database", &dbobj);
        if (dbobj != NULL)
                return (ISC_R_SUCCESS);
-       cfg_map_get(zoptions, "file", &fileobj);
-       if (fileobj == NULL)
-               return (ISC_R_FAILURE);
-       zfile = cfg_obj_asstring(fileobj);
 
        obj = NULL;
        if (get_maps(maps, "check-dup-records", &obj)) {
@@ -341,7 +379,7 @@ configure_zone(const char *vclass, const char *view,
        if (result != ISC_R_SUCCESS)
                fprintf(stderr, "%s/%s/%s: %s\n", view, zname, zclass,
                        dns_result_totext(result));
-       return(result);
+       return (result);
 }
 
 /*% configure a view */
diff --git a/bin/tests/system/checkconf/hint-nofile.conf b/bin/tests/system/checkconf/hint-nofile.conf
new file mode 100644 (file)
index 0000000..57c07e7
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+zone "." {
+       type hint;
+       file "nonexistent.db";
+};
index 37512e4682cbbaed6c0de41a8625f9ee8fc5c678..a151a32840a46366bce4c3be5690afa579f3274f 100644 (file)
@@ -46,6 +46,12 @@ $CHECKCONF badtsig.conf > /dev/null 2>&1
 if [ $? != 1 ]; then echo "I:failed"; ret=1; fi
 status=`expr $status + $ret`
 
+echo "I: checking that named-checkconf -z catches missing hint file"
+ret=0
+$CHECKCONF -z hint-nofile.conf > /dev/null 2>&1 && ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I: checking named-checkconf dnssec warnings"
 ret=0
 $CHECKCONF dnssec.1 2>&1 | grep 'validation yes.*enable no' > /dev/null || ret=1