]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3710. [bug] Address double dns_zone_detach when switching to
authorMark Andrews <marka@isc.org>
Thu, 16 Jan 2014 23:04:16 +0000 (10:04 +1100)
committerMark Andrews <marka@isc.org>
Thu, 16 Jan 2014 23:09:53 +0000 (10:09 +1100)
                        using automatic empty zones from regular zones.
                        [RT #35177]

(cherry picked from commit db8938c993d3eaeae1d86feb1b5da511831a9014)

CHANGES
bin/named/server.c
bin/tests/system/conf.sh.in
bin/tests/system/emptyzones/clean.sh [new file with mode: 0644]
bin/tests/system/emptyzones/ns1/empty.db [new file with mode: 0644]
bin/tests/system/emptyzones/ns1/named1.conf [new file with mode: 0644]
bin/tests/system/emptyzones/ns1/named2.conf [new file with mode: 0644]
bin/tests/system/emptyzones/ns1/rfc1918.zones [new file with mode: 0644]
bin/tests/system/emptyzones/ns1/root.hint [new file with mode: 0644]
bin/tests/system/emptyzones/setup.sh [new file with mode: 0644]
bin/tests/system/emptyzones/tests.sh [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index f59b64a52f2f7a3e79271e8388f5ab9e769f91d9..3467912221783b6271c2271fb65c4c3f10a7cad6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3710.  [bug]           Address double dns_zone_detach when switching to
+                       using automatic empty zones from regular zones.
+                       [RT #35177]
+
 3706.  [contrib]       queryperf: Fixed a possible integer overflow when
                        printing results. [RT #35182]
 
index 8a26037f1cfe6827a4aeeb9e55baf982bbc15633..998a80eeced88cddce40eccb2bfd2f05b9df3d90 100644 (file)
@@ -990,26 +990,22 @@ on_disable_list(const cfg_obj_t *disablelist, dns_name_t *zonename) {
        return (ISC_FALSE);
 }
 
-static void
-check_dbtype(dns_zone_t **zonep, unsigned int dbtypec, const char **dbargv,
+static isc_result_t
+check_dbtype(dns_zone_t *zone, unsigned int dbtypec, const char **dbargv,
             isc_mem_t *mctx)
 {
        char **argv = NULL;
        unsigned int i;
-       isc_result_t result;
+       isc_result_t result = ISC_R_SUCCESS;
 
-       result = dns_zone_getdbtype(*zonep, &argv, mctx);
-       if (result != ISC_R_SUCCESS) {
-               dns_zone_detach(zonep);
-               return;
-       }
+       CHECK(dns_zone_getdbtype(zone, &argv, mctx));
 
        /*
         * Check that all the arguments match.
         */
        for (i = 0; i < dbtypec; i++)
                if (argv[i] == NULL || strcmp(argv[i], dbargv[i]) != 0) {
-                       dns_zone_detach(zonep);
+                       CHECK(ISC_R_FAILURE);
                        break;
                }
 
@@ -1017,8 +1013,11 @@ check_dbtype(dns_zone_t **zonep, unsigned int dbtypec, const char **dbargv,
         * Check that there are not extra arguments.
         */
        if (i == dbtypec && argv[i] != NULL)
-               dns_zone_detach(zonep);
+               result = ISC_R_FAILURE;
+
+ cleanup:
        isc_mem_free(mctx, argv);
+       return (result);
 }
 
 static isc_result_t
@@ -1228,12 +1227,21 @@ create_empty_zone(dns_zone_t *zone, dns_name_t *name, dns_view_t *view,
         * Is the existing zone the ok to use?
         */
        if (zone != NULL) {
-               if (db != NULL)
-                       check_dbtype(&zone, rbt_dbtypec, rbt_dbtype,
-                                    view->mctx);
-               else
-                       check_dbtype(&zone, empty_dbtypec, empty_dbtype,
-                                    view->mctx);
+               unsigned int typec;
+               const char **dbargv;
+
+               if (db != NULL) {
+                       typec = rbt_dbtypec;
+                       dbargv = rbt_dbtype;
+               } else {
+                       typec = empty_dbtypec;
+                       dbargv = empty_dbtype;
+               }
+
+               result = check_dbtype(zone, typec, dbargv, view->mctx);
+               if (result != ISC_R_SUCCESS)
+                       zone = NULL;
+
                if (zone != NULL && dns_zone_gettype(zone) != dns_zone_master)
                        zone = NULL;
                if (zone != NULL && dns_zone_getfile(zone) != NULL)
index 1a6d153796517ec6ca979ad4f41f963ae8b0d0cc..bdea347caff580959acf18935e67802dcb280c72 100644 (file)
@@ -44,7 +44,9 @@ CHECKCONF=$TOP/bin/check/named-checkconf
 # load on the machine to make it unusable to other users.
 # v6synth
 SUBDIRS="acl additional allow_query builtin cacheclean case checkconf
-        checknames checkzone database dlv dlz dname dnssec formerr
+        checknames checkzone database dlv dlz dname dnssec
+        emptyzones
+        formerr
         forward glue ixfr limits logfileconfig lwresd masterfile
         masterformat notify nsupdate pending resolver rndc rrsetorder
         spf sortlist stub tkey unknown upforwd views wildcard xfer
diff --git a/bin/tests/system/emptyzones/clean.sh b/bin/tests/system/emptyzones/clean.sh
new file mode 100644 (file)
index 0000000..66b3a17
--- /dev/null
@@ -0,0 +1 @@
+rm -f ns1/named.conf
diff --git a/bin/tests/system/emptyzones/ns1/empty.db b/bin/tests/system/emptyzones/ns1/empty.db
new file mode 100644 (file)
index 0000000..d807099
--- /dev/null
@@ -0,0 +1,16 @@
+; Copyright (C) 2014  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.
+
+@ 0 SOA . . 0 0 0 0 0
+@ 0 NS .
diff --git a/bin/tests/system/emptyzones/ns1/named1.conf b/bin/tests/system/emptyzones/ns1/named1.conf
new file mode 100644 (file)
index 0000000..6f54ad2
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2004, 2007, 2009, 2013  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * 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.
+ */
+
+/* $Id: named.conf,v 1.15 2009/05/29 23:47:49 tbox Exp $ */
+
+key rndc_key {
+        algorithm       hmac-sha256;
+        secret          "1234abcd8765";
+};
+
+controls {
+       inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; };
+};
+
+options {
+       query-source address 10.53.0.1 dscp 1;
+       notify-source 10.53.0.1 dscp 2;
+       transfer-source 10.53.0.1 dscp 3;
+       port 5300;
+       pid-file "named.pid";
+       listen-on { 10.53.0.1; };
+       listen-on-v6 { none; };
+       recursion yes;
+       acache-enable yes;
+       deny-answer-addresses { 192.0.2.0/24; 2001:db8:beef::/48; }
+                except-from { "example.org"; };
+       deny-answer-aliases { "example.org"; }
+               except-from { "goodcname.example.net";
+                             "gooddname.example.net"; };
+       allow-query {!10.53.0.8; any; };
+};
+
+zone "." {
+       type hint;
+       file "root.hint";
+};
+
+include "rfc1918.zones";
diff --git a/bin/tests/system/emptyzones/ns1/named2.conf b/bin/tests/system/emptyzones/ns1/named2.conf
new file mode 100644 (file)
index 0000000..467511c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2004, 2007, 2009, 2013  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * 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.
+ */
+
+/* $Id: named.conf,v 1.15 2009/05/29 23:47:49 tbox Exp $ */
+
+key rndc_key {
+        algorithm       hmac-sha256;
+        secret          "1234abcd8765";
+};
+
+controls {
+       inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; };
+};
+
+options {
+       query-source address 10.53.0.1 dscp 1;
+       notify-source 10.53.0.1 dscp 2;
+       transfer-source 10.53.0.1 dscp 3;
+       port 5300;
+       pid-file "named.pid";
+       listen-on { 10.53.0.1; };
+       listen-on-v6 { none; };
+       recursion yes;
+       acache-enable yes;
+       deny-answer-addresses { 192.0.2.0/24; 2001:db8:beef::/48; }
+                except-from { "example.org"; };
+       deny-answer-aliases { "example.org"; }
+               except-from { "goodcname.example.net";
+                             "gooddname.example.net"; };
+       allow-query {!10.53.0.8; any; };
+};
+
+zone "." {
+       type hint;
+       file "root.hint";
+};
diff --git a/bin/tests/system/emptyzones/ns1/rfc1918.zones b/bin/tests/system/emptyzones/ns1/rfc1918.zones
new file mode 100644 (file)
index 0000000..e2f4ac4
--- /dev/null
@@ -0,0 +1,19 @@
+zone "10.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "16.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "17.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "18.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "19.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "20.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "21.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "22.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "23.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "24.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "25.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "26.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "27.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "28.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "29.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "30.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "31.172.IN-ADDR.ARPA" { type master; file "empty.db"; };
+zone "168.192.IN-ADDR.ARPA" { type master; file "empty.db"; };
+
diff --git a/bin/tests/system/emptyzones/ns1/root.hint b/bin/tests/system/emptyzones/ns1/root.hint
new file mode 100644 (file)
index 0000000..2fd180e
--- /dev/null
@@ -0,0 +1,20 @@
+; Copyright (C) 2004, 2007  Internet Systems Consortium, Inc. ("ISC")
+; Copyright (C) 2000, 2001  Internet Software Consortium.
+;
+; 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.
+
+; $Id: root.hint,v 1.7 2007/06/19 23:47:05 tbox Exp $
+
+$TTL 999999
+.                       IN NS  a.root-servers.nil.
+a.root-servers.nil.     IN A   10.53.0.2
diff --git a/bin/tests/system/emptyzones/setup.sh b/bin/tests/system/emptyzones/setup.sh
new file mode 100644 (file)
index 0000000..1faa70e
--- /dev/null
@@ -0,0 +1 @@
+cp -f ns1/named1.conf ns1/named.conf
diff --git a/bin/tests/system/emptyzones/tests.sh b/bin/tests/system/emptyzones/tests.sh
new file mode 100644 (file)
index 0000000..755d89d
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# Copyright (C) 2014  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.
+
+SYSTEMTESTTOP=..
+. $SYSTEMTESTTOP/conf.sh
+
+status=0
+n=0
+
+n=`expr $n + 1`
+echo "I:check that switching to automatic empty zones works ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 reload > /dev/null || ret=1
+sleep 5
+cp ns1/named2.conf ns1/named.conf
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 reload > /dev/null || ret=1
+sleep 5
+$DIG +vc version.bind txt ch @10.53.0.1 -p 5300 > /dev/null || ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+exit $status