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

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 0d5779f469518052f541839c891c5d71128248dc..68b4d31214967ea04d4f3e4a5004473ddb77141f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3676.  [bug]           "named-checkconf -z" now checks zones of type
+                       hint and redirect 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 0b3c508f28c4ef0ba66cb47ef0b1b7fac257dd92..6f52a6629ce1aa447899104604c59de523a58501 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,28 @@ 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 and redirect
+        */
+       if (strcasecmp(cfg_obj_asstring(typeobj), "hint") == 0)
+               return (configure_hint(zfile, zclass, mctx));
+       else if ((strcasecmp(cfg_obj_asstring(typeobj), "master") != 0) &&
+                 (strcasecmp(cfg_obj_asstring(typeobj), "redirect") != 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 +381,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 2f05c5da5c8a50e41e82e00904899cab0b7423fe..af99a37634d1bdda8e6a5221ffafaec5646e48a0 100644 (file)
@@ -43,6 +43,12 @@ do
        status=`expr $status + $ret`
 done
 
+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 that named-checkconf catches range errors"
 ret=0
 $CHECKCONF range.conf > /dev/null 2>&1 && ret=1