]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_6] check hint files in named-checkconf -z
authorEvan Hunt <each@isc.org>
Mon, 25 Nov 2013 21:25:00 +0000 (13:25 -0800)
committerEvan Hunt <each@isc.org>
Mon, 25 Nov 2013 21:25:00 +0000 (13:25 -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)
(cherry picked from commit 4ed930b4f89550131a6d2ab5f60ffb09e62d102f)

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 6b0a55dd22303f750c517c3375601bd31ee2d3af..4e5fdb22d03c4db615c4db42ccaf4602893e68d5 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 48e1137e8a6a481e24e29ada90d3015572bcdcb4..c49a1ca521c4b9385c777d6325049b52718fb21e 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-mx", &obj)) {
@@ -323,7 +361,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 cc5db0439edb2fe47d1b4ed7dfb1c43963236d2b..c034c1ae24d6d8ec2cc92e203e605a4403ba843d 100644 (file)
@@ -38,6 +38,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: range checking fields that do not allow zero"
 ret=0
 for field in max-retry-time min-retry-time max-refresh-time min-refresh-time; do