]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_8] warn if key-directory doesn't exist
authorEvan Hunt <each@isc.org>
Fri, 20 Dec 2013 22:58:31 +0000 (14:58 -0800)
committerEvan Hunt <each@isc.org>
Fri, 20 Dec 2013 22:58:31 +0000 (14:58 -0800)
3694. [bug] Warn when a key-directory is configured for a zone,
but does not exist or is not a directory. [RT #35109]

(cherry picked from commit c14ba7107063650e7f4329e8c54adca57913381b)
(cherry picked from commit 23541812260b4c0e8b5a32240146150a03f51035)

CHANGES
bin/tests/system/checkconf/clean.sh
bin/tests/system/checkconf/tests.sh
bin/tests/system/checkconf/warn-keydir.conf [new file with mode: 0644]
lib/bind9/check.c

diff --git a/CHANGES b/CHANGES
index 1658e455a11bb215d0dca0a32644e52f73f4119b..21f43ef6aa65f1301176893e700f5ed08bb20e38 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3694.  [bug]           Warn when a key-directory is configured for a zone,
+                       but does not exist or is not a directory. [RT #35109]
+
 3693.  [security]      memcpy was incorrectly called with overlapping
                        ranges resulting in malformed names being generated
                        on some platforms.  This could cause INSIST failures
index 6a23edb18cb132352a90784886d82301d601d1c5..76ad0de604db2c44bff39836ff6309c138e47b4e 100644 (file)
@@ -17,3 +17,4 @@
 # $Id: clean.sh,v 1.1.6.2 2011/05/07 05:53:23 each Exp $
 
 rm -f good.conf.in good.conf.out badzero.conf
+rm -rf test.keydir
index 84958911bb83fb040b7e27c9fe4b62f78583bc10..f626ef1da2c684b702f35ee2229454f2d4b5dc1b 100644 (file)
@@ -102,5 +102,21 @@ done
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
+echo "I: checking for missing key directory warning"
+ret=0
+rm -rf test.keydir
+n=`$CHECKCONF warn-keydir.conf 2>&1 | grep "'test.keydir' does not exist" | wc -l`
+[ $n -eq 1 ] || ret=1
+touch test.keydir
+n=`$CHECKCONF warn-keydir.conf 2>&1 | grep "'test.keydir' is not a directory" | wc -l`
+[ $n -eq 1 ] || ret=1
+rm -f test.keydir
+mkdir test.keydir
+n=`$CHECKCONF warn-keydir.conf 2>&1 | grep "key-directory" | wc -l`
+[ $n -eq 0 ] || ret=1
+rm -rf test.keydir
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I:exit status: $status"
 exit $status
diff --git a/bin/tests/system/checkconf/warn-keydir.conf b/bin/tests/system/checkconf/warn-keydir.conf
new file mode 100644 (file)
index 0000000..3ee8118
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+/*
+ * key-directory defined but doesn't exist.
+ */
+options {
+        directory ".";
+};
+
+zone dummy {
+       type master;
+       file "xxxx";
+        key-directory "test.keydir";
+};
index 7c975c9846af434d417c91057fb22756acc7e140..d81c467160990150d9067218a293907a9bc0055c 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <isc/base64.h>
 #include <isc/buffer.h>
+#include <isc/file.h>
 #include <isc/log.h>
 #include <isc/mem.h>
 #include <isc/netaddr.h>
@@ -1700,6 +1701,35 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
                }
        }
 
+       /*
+        * Warn if key-directory doesn't exist
+        */
+       obj = NULL;
+       tresult = cfg_map_get(zoptions, "key-directory", &obj);
+       if (tresult == ISC_R_SUCCESS) {
+               const char *dir = cfg_obj_asstring(obj);
+               tresult = isc_file_isdirectory(dir);
+               switch (tresult) {
+               case ISC_R_SUCCESS:
+                       break;
+               case ISC_R_FILENOTFOUND:
+                       cfg_obj_log(obj, logctx, ISC_LOG_WARNING,
+                                   "key-directory: '%s' does not exist",
+                                   dir);
+                       break;
+               case ISC_R_INVALIDFILE:
+                       cfg_obj_log(obj, logctx, ISC_LOG_WARNING,
+                                   "key-directory: '%s' is not a directory",
+                                   dir);
+                       break;
+               default:
+                       cfg_obj_log(obj, logctx, ISC_LOG_WARNING,
+                                   "key-directory: '%s' %s",
+                                   dir, isc_result_totext(tresult));
+                       result = tresult;
+               }
+       }
+
        /*
         * Check various options.
         */