]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4541. [bug] rndc addzone should properly reject non master/slave
authorMark Andrews <marka@isc.org>
Tue, 27 Dec 2016 23:27:56 +0000 (10:27 +1100)
committerMark Andrews <marka@isc.org>
Tue, 27 Dec 2016 23:59:23 +0000 (10:59 +1100)
                        zones. [RT #43665]

(cherry picked from commit e20db12918c2e808c9ddb0e5e0f75dae71a63ad7)

CHANGES
bin/named/server.c
bin/tests/system/addzone/ns2/hints.db [new file with mode: 0644]
bin/tests/system/addzone/ns2/redirect.db [new file with mode: 0644]
bin/tests/system/addzone/tests.sh

diff --git a/CHANGES b/CHANGES
index 364f9cce2cb5db590552ef53a2d1dc273f8d9284..f40b213c326803d76bf1b585e87c0718cb8d5e66 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4541.  [bug]           rndc addzone should properly reject non master/slave
+                       zones. [RT #43665]
+
 4539.  [bug]           Referencing a nonexistant zone with rpz could lead
                        to a assertion failure when configuring. [RT #43787]
 
index bf72598ca74a1112303231086e37203f85bf4dea..73c292d85cdf7de48c48ccbce16732c9118f16ab 100644 (file)
@@ -2560,9 +2560,9 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist,
                     element = cfg_list_next(element))
                {
                        const cfg_obj_t *zconfig = cfg_listelt_value(element);
-                       CHECK(configure_zone(config, zconfig, vconfig,
-                                            mctx, view, NULL, actx,
-                                            ISC_TRUE, ISC_FALSE));
+                       CHECK(configure_zone(config, zconfig, vconfig, mctx,
+                                            view, viewlist, actx, ISC_TRUE,
+                                            ISC_FALSE));
                }
        }
 
@@ -4090,7 +4090,7 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
 
        if (ISC_LIST_EMPTY(fwdlist)) {
                if (forwardtype != NULL)
-                       cfg_obj_log(forwarders, ns_g_lctx, ISC_LOG_WARNING,
+                       cfg_obj_log(forwardtype, ns_g_lctx, ISC_LOG_WARNING,
                                    "no forwarders seen; disabling "
                                    "forwarding");
                fwdpolicy = dns_fwdpolicy_none;
@@ -9233,6 +9233,7 @@ ns_server_add_zone(ns_server_t *server, char *args, isc_buffer_t *text) {
        const cfg_obj_t     *views = NULL;
        const cfg_obj_t     *parms = NULL;
        const cfg_obj_t     *obj = NULL;
+       const cfg_obj_t     *zoptions = NULL;
        const cfg_listelt_t *element;
        const char          *zonename;
        const char          *classname = NULL;
@@ -9266,6 +9267,34 @@ ns_server_add_zone(ns_server_t *server, char *args, isc_buffer_t *text) {
        dnsname = dns_fixedname_name(&fname);
        CHECK(dns_name_fromtext(dnsname, &buf, dns_rootname, 0, NULL));
 
+       /* Check the zone type for ones that are not supported by addzone. */
+       zoptions = cfg_tuple_get(parms, "options");
+       obj = NULL;
+       (void)cfg_map_get(zoptions, "type", &obj);
+       if (obj == NULL) {
+               (void) cfg_map_get(zoptions, "in-view", &obj);
+               if (obj != NULL) {
+                       (void) putstr(text,
+                                     "'in-view' zones not supported by ");
+                       (void) putstr(text, "addzone");
+               } else
+                       (void) putstr(text, "zone type not specified");
+               CHECK(ISC_R_FAILURE);
+       }
+       if (strcasecmp(cfg_obj_asstring(obj), "hint") == 0 ||
+           strcasecmp(cfg_obj_asstring(obj), "forward") == 0 ||
+           strcasecmp(cfg_obj_asstring(obj), "redirect") == 0 ||
+           strcasecmp(cfg_obj_asstring(obj), "delegation-only") == 0)
+       {
+               (void) putstr(text, "'");
+               (void) putstr(text, cfg_obj_asstring(obj));
+               (void) putstr(text, "' zones not supported by ");
+               (void) putstr(text, "addzone");
+               CHECK(ISC_R_FAILURE);
+       }
+
        /* Make sense of optional class argument */
        obj = cfg_tuple_get(parms, "class");
        CHECK(ns_config_getclass(obj, dns_rdataclass_in, &rdclass));
@@ -9336,8 +9365,8 @@ ns_server_add_zone(ns_server_t *server, char *args, isc_buffer_t *text) {
        result = isc_task_beginexclusive(server->task);
        RUNTIME_CHECK(result == ISC_R_SUCCESS);
        dns_view_thaw(view);
-       result = configure_zone(cfg->config, parms, vconfig,
-                               server->mctx, view, NULL, cfg->actx,
+       result = configure_zone(cfg->config, parms, vconfig, server->mctx,
+                               view, &ns_g_server->viewlist, cfg->actx,
                                ISC_FALSE, ISC_FALSE);
        dns_view_freeze(view);
        isc_task_endexclusive(server->task);
diff --git a/bin/tests/system/addzone/ns2/hints.db b/bin/tests/system/addzone/ns2/hints.db
new file mode 100644 (file)
index 0000000..274ec9a
--- /dev/null
@@ -0,0 +1,11 @@
+; Copyright (C) 2000, 2001, 2004, 2007, 2016  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/.
+
+; $Id: root.hint,v 1.5 2007/06/19 23:47:01 tbox Exp $
+
+$TTL 999999
+.                       IN NS  a.root-servers.nil.
+a.root-servers.nil.     IN A   10.53.0.1
diff --git a/bin/tests/system/addzone/ns2/redirect.db b/bin/tests/system/addzone/ns2/redirect.db
new file mode 100644 (file)
index 0000000..63a371b
--- /dev/null
@@ -0,0 +1,7 @@
+; Copyright (C) 2016  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/.
+@      0       SOA     . . 0 0 0 0 0
+@      0       NS      .
index 155c78e9551595cbe220699da8668829f6288994..2db7c6d4f4c22468cd4589109f7bdadb61885b22 100755 (executable)
@@ -229,6 +229,68 @@ done
 n=`expr $n + 1`
 status=`expr $status + $ret`
 
+echo "I:check that adding a 'stub' zone works ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'stub.example { type stub; masters { 1.2.3.4; }; file "stub.example.bk"; };' > rndc.out.ns2.$n 2>&1 || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:check that adding a 'static-stub' zone works ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'static-stub.example { type static-stub; server-addresses { 1.2.3.4; }; };' > rndc.out.ns2.$n 2>&1 || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:check that zone type 'redirect' (master) is properly rejected ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"." { type redirect; file "redirect.db"; };' > rndc.out.ns2.$n 2>&1 && ret=1
+grep "zones not supported by addzone" rndc.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:check that zone type 'redirect' (slave) is properly rejected ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"." { type redirect; masters { 1.2.3.4; }; file "redirect.bk"; };' > rndc.out.ns2.$n 2>&1 && ret=1
+grep "zones not supported by addzone" rndc.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:check that zone type 'hint' is properly rejected ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"." { type hint; file "hints.db"; };' > rndc.out.ns2.$n 2>&1 && ret=1
+grep "zones not supported by addzone" rndc.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:check that zone type 'forward' is properly rejected ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'forward.example { type forward; forwarders { 1.2.3.4; }; forward only; };' > rndc.out.ns2.$n 2>&1 && ret=1
+grep "zones not supported by addzone" rndc.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:check that zone type 'delegation-only' is properly rejected ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'delegation-only.example { type delegation-only; };' > rndc.out.ns2.$n 2>&1 && ret=1
+grep "zones not supported by addzone" rndc.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:check that 'in-view' zones are properly rejected ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'in-view.example { in-view "_default"; };' > rndc.out.ns2.$n 2>&1 && ret=1
+grep "zones not supported by addzone" rndc.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I:reconfiguring server with multiple views"
 rm -f ns2/named.conf 
 cp -f ns2/named2.conf ns2/named.conf