]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] make writable directory and managed-keys directory mandatory
authorEvan Hunt <each@isc.org>
Wed, 11 Oct 2017 01:28:34 +0000 (18:28 -0700)
committerOndřej Surý <ondrej@sury.org>
Wed, 11 Oct 2017 06:21:23 +0000 (08:21 +0200)
4769.   [bug]           The working directory and managed-keys directory has
                        to be writeable (and seekable). [RT #46077]

12 files changed:
CHANGES
bin/named/server.c
bin/tests/system/mkeys/README
bin/tests/system/runtime/clean.sh
bin/tests/system/runtime/ns2/named-alt4.conf [new file with mode: 0644]
bin/tests/system/runtime/ns2/named-alt5.conf [new file with mode: 0644]
bin/tests/system/runtime/ns2/named1.conf [moved from bin/tests/system/runtime/ns2/named.conf with 78% similarity]
bin/tests/system/runtime/setup.sh
bin/tests/system/runtime/tests.sh
doc/arm/Bv9ARM-book.xml
doc/arm/notes.xml
lib/isccfg/parser.c

diff --git a/CHANGES b/CHANGES
index d31525f8e1ada7668a34a2038a93d1a3b464dc84..2d200d9526dd05b19bd8c5f888b55518515ae999 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4769.  [bug]           The working directory and managed-keys directory has
+                       to be writeable (and seekable). [RT #46077]
+
 4768.  [func]          By default, memory is no longer filled with tag values
                        when it is allocated or freed; this improves
                        performance but makes debugging of certain memory
index 17eb5e5d2dfb61b001b6ac1b8143f334b0172625..ee0f59722677dd3fedbf117e9c9fdea1176f3dce 100644 (file)
@@ -1032,6 +1032,15 @@ configure_view_dnsseckeys(dns_view_t *view, const cfg_obj_t *vconfig,
                              directory, isc_result_totext(result));
                goto cleanup;
 
+       } else if (directory != NULL) {
+               if (access(directory, W_OK|X_OK) != 0) {
+                       isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
+                                     NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
+                                     "managed-keys-directory '%s' "
+                                     "is not writable", directory);
+                       result = ISC_R_NOPERM;
+                       goto cleanup;
+               }
        }
        CHECK(add_keydata_zone(view, directory, named_g_mctx));
 
@@ -6150,6 +6159,14 @@ directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) {
                            "option 'directory' contains relative path '%s'",
                            directory);
 
+       if (access(directory, W_OK|X_OK) != 0) {
+               isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
+                             NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
+                             "directory '%s' is not writable",
+                             directory);
+               return (ISC_R_NOPERM);
+       }
+
        result = isc_dir_chdir(directory);
        if (result != ISC_R_SUCCESS) {
                cfg_obj_log(obj, named_g_lctx, ISC_LOG_ERROR,
index 43a88471baeec6b502d66dbca95062dfb2b937ea..5b42f38f016bad8356e55210de949be88916e5cd 100644 (file)
@@ -10,9 +10,9 @@ with RFC 5011 Automated Updates of DNSSEC Trust Anchors.
 ns1 is the root server that offers new KSKs and hosts one record for
 testing. The TTL for the zone's records is 2 seconds.
 
-ns2 is a validator uses managed-keys.
-"named -T rfc5011holddown=4" switch is used so it will attempt to do
-the automated updates frequently.
+ns2 is a validator that uses managed-keys.  "-T mkeytimers=2/20/40"
+is used so it will attempt do automated updates frequently. "-T tat=1"
+is used so it will send TAT queries once per second.
 
 ns3 is a validator with a broken key in managed-keys.
 
index 5e0e33b0c383d7df658edcd381d1e714232c6f55..5f150c274b6347075e33e0837d7eddb0be23a06a 100644 (file)
@@ -6,6 +6,11 @@
 # 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/.
 
+rm -f ns2/named.conf
 rm -f */named.memstats
 rm -f */named*.run
 rm -f ns*/named.lock ns*/named*.pid ns*/other.lock
+rm -f *.pid
+rm -f rndc.out*
+[ -d ns2/nope ] && chmod 755 ns2/nope
+rm -rf ns2/nope
diff --git a/bin/tests/system/runtime/ns2/named-alt4.conf b/bin/tests/system/runtime/ns2/named-alt4.conf
new file mode 100644 (file)
index 0000000..2715508
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2017  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/.
+ */
+
+options {
+        directory "./nope";
+        port 5300;
+        pid-file "../named4.pid";
+        listen-on { 127.0.0.1; };
+        listen-on-v6 { none; };
+        recursion no;
+};
diff --git a/bin/tests/system/runtime/ns2/named-alt5.conf b/bin/tests/system/runtime/ns2/named-alt5.conf
new file mode 100644 (file)
index 0000000..9cfc6ed
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2017  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/.
+ */
+
+options {
+       managed-keys-directory "./nope";
+        port 5300;
+        pid-file "../named4.pid";
+        listen-on { 127.0.0.1; };
+        listen-on-v6 { none; };
+        recursion no;
+};
similarity index 78%
rename from bin/tests/system/runtime/ns2/named.conf
rename to bin/tests/system/runtime/ns2/named1.conf
index 635b9a92626b80f6bb64d9ddadb3aab4043c3f25..ea0e89fa94ea9e0662ccf136d2bacb7446a8c4c8 100644 (file)
@@ -21,3 +21,13 @@ options {
        dnssec-enable no;
        dnssec-validation no;
 };
+
+key rndc_key {
+       secret "1234abcd8765";
+       algorithm hmac-sha256;
+};
+
+controls {
+       inet 10.53.0.2 port 9953 allow { any; } keys { rndc_key; };
+};
+
index 09791719bad2722a4188e02f1ae9214fc0f5a7dc..33a70833b9b78fc8536c0ca833e1da9a055123b4 100644 (file)
@@ -10,3 +10,8 @@ SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
 
 $SHELL clean.sh 
+
+cp ns2/named1.conf ns2/named.conf
+
+mkdir ns2/nope
+chmod 555 ns2/nope
index 36bbca9fc88a9987fa13fbe16559ff046f0f492a..a1d586109f5405fccf7207ca6d9503da0fa03a3a 100644 (file)
@@ -20,17 +20,15 @@ if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
 if [ ! "$CYGWIN" ]; then
-
-n=`expr $n + 1`
-echo "I:verifying that named checks for conflicting listeners ($n)"
-ret=0
-(cd ns2; $NAMED -c named-alt1.conf -D ns2-extra-1 -X other.lock -m record,size,mctx -d 99 -g -U 4 >> named2.run 2>&1 & )
-sleep 2
-grep "unable to listen on any configured interface" ns2/named2.run > /dev/null || ret=1
-[ -s ns2/named2.pid ] && $KILL -15 `cat ns2/named2.pid`
-if [ $ret != 0 ]; then echo "I:failed"; fi
-status=`expr $status + $ret`
-
+    n=`expr $n + 1`
+    echo "I:verifying that named checks for conflicting listeners ($n)"
+    ret=0
+    (cd ns2; $NAMED -c named-alt1.conf -D ns2-extra-1 -X other.lock -m record,size,mctx -d 99 -g -U 4 >> named2.run 2>&1 & )
+    sleep 2
+    grep "unable to listen on any configured interface" ns2/named2.run > /dev/null || ret=1
+    [ -s ns2/named2.pid ] && $KILL -15 `cat ns2/named2.pid`
+    if [ $ret != 0 ]; then echo "I:failed"; fi
+    status=`expr $status + $ret`
 fi
 
 n=`expr $n + 1`
@@ -53,6 +51,51 @@ grep "another named process" ns2/named4.run > /dev/null && ret=1
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo "I: checking that named refuses to reconfigure if working directory is not writable ($n)"
+ret=0
+cp -f ns2/named-alt4.conf ns2/named.conf
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig > rndc.out.$n 2>&1
+grep "failed: permission denied" rndc.out.$n > /dev/null 2>&1 || ret=1
+sleep 1
+grep "[^-]directory './nope' is not writable" ns2/named.run > /dev/null 2>&1 || ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+n=`expr $n + 1`
+echo "I: checking that named refuses to reconfigure if managed-keys-directory is not writable ($n)"
+ret=0
+cp -f ns2/named-alt5.conf ns2/named.conf
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig > rndc.out.$n 2>&1
+grep "failed: permission denied" rndc.out.$n > /dev/null 2>&1 || ret=1
+sleep 1
+grep "managed-keys-directory './nope' is not writable" ns2/named.run > /dev/null 2>&1 || ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+n=`expr $n + 1`
+echo "I: checking that named refuses to start if working directory is not writable ($n)"
+ret=0
+cd ns2
+$NAMED -c named-alt4.conf -d 99 -g > named4.run 2>&1 &
+sleep 2
+grep "exiting (due to fatal error)" named4.run > /dev/null || ret=1
+[ -s named4.pid ] && kill -15 `cat named4.pid` > /dev/null 2>&1
+cd ..
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+n=`expr $n + 1`
+echo "I: checking that named refuses to start if managed-keys-directory is not writable ($n)"
+ret=0
+cd ns2
+$NAMED -c named-alt5.conf -d 99 -g > named5.run 2>&1 &
+sleep 2
+grep "exiting (due to fatal error)" named5.run > /dev/null || ret=1
+[ -s named5.pid ] && kill -15 `cat named5.pid` > /dev/null 2>&1
+cd ..
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
 
 echo "I:exit status: $status"
 [ $status -eq 0 ] || exit 1
index d00937758bfc978a241998c5f2adcffc5f75d690..61f04c144325c137844d9d4ace5bdc707882ca33 100644 (file)
@@ -4670,17 +4670,16 @@ badresp:1,adberr:0,findfail:0,valfail:0]
            <listitem>
              <para>
                The working directory of the server.
-               Any non-absolute pathnames in the configuration file will be
-               taken
-               as relative to this directory. The default location for most
-               server
-               output files (e.g. <filename>named.run</filename>)
-               is this directory.
+               Any non-absolute pathnames in the configuration file will
+               be taken as relative to this directory. The default
+               location for most server output files
+               (e.g. <filename>named.run</filename>) is this directory.
                If a directory is not specified, the working directory
                defaults to `<filename>.</filename>', the directory from
-               which the server
-               was started. The directory specified should be an absolute
-               path.
+               which the server was started. The directory specified
+               should be an absolute path, and <emphasis>must</emphasis>
+               be writable by the effective user ID of the
+               <command>named</command> process.
              </para>
            </listitem>
          </varlistentry>
@@ -4957,7 +4956,9 @@ badresp:1,adberr:0,findfail:0,valfail:0]
              <para>
                Specifies the directory in which to store the files that
                track managed DNSSEC keys.  By default, this is the working
-               directory.
+               directory.  The directory <emphasis>must</emphasis>
+               be writable by the effective user ID of the
+               <command>named</command> process.
              </para>
              <para>
                If <command>named</command> is not configured to use views,
index c111f755041041d215c719fcc55698b989f64c8a..0ecb3420831f1c8284a7008767b6b55c47b7ac01 100644 (file)
          anchor is now a fatal configuration error. [RT #46155]
        </para>
       </listitem>
+      <listitem>
+       <para>
+         <command>named</command> will no longer start or accept
+         reconfiguration if the working directory (specified by the
+         <command>directory</command> option) or the managed-keys
+         directory (specified by <command>managed-keys-directory</command>
+         are not writable by the effective user ID. [RT #46077]
+       </para>
+      </listitem>
       <listitem>
        <para>
          Previously, <command>update-policy local;</command> accepted
index 1871046cd30575de279c6a19435d2d906dcaa1ae..6d15e0c9538c1d726403bfadd02c34347e07eb1e 100644 (file)
@@ -566,7 +566,8 @@ parse2(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
 
        if (result != ISC_R_SUCCESS) {
                /* Parsing failed but no errors have been logged. */
-               cfg_parser_error(pctx, 0, "parsing failed");
+               cfg_parser_error(pctx, 0, "parsing failed: %s",
+                                isc_result_totext(result));
                goto cleanup;
        }