]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] zone-directory option for catalog zones
authorEvan Hunt <each@isc.org>
Tue, 31 May 2016 17:36:27 +0000 (10:36 -0700)
committerEvan Hunt <each@isc.org>
Tue, 31 May 2016 17:36:27 +0000 (10:36 -0700)
4380. [experimental] Added a "zone-directory" option to "catalog-zones"
syntax, allowing local masterfiles for slaves
that are provisioned by catalog zones to be stored
in a directory other than the server's working
directory. [RT #42527]

CHANGES
bin/named/server.c
bin/tests/system/catz/clean.sh
bin/tests/system/catz/ns2/named.conf
bin/tests/system/catz/setup.sh
bin/tests/system/catz/tests.sh
doc/arm/catz.xml
lib/dns/catz.c
lib/dns/include/dns/catz.h
lib/isccfg/namedconf.c

diff --git a/CHANGES b/CHANGES
index f2fa4f4fbe9269664ba4bc9054477a41b2b3a368..7ef9c6af45551ee299abd71637c90e13a732c898 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+4380.  [experimental]  Added a "zone-directory" option to "catalog-zones"
+                       syntax, allowing local masterfiles for slaves
+                       that are provisioned by catalog zones to be stored
+                       in a directory other than the server's working
+                       directory. [RT #42527]
+
 4379.   [bug]           An INSIST could be triggered if a zone contains
                        RRSIG records with expiry fields that loop
                        using serial number arithmetic. [RT #40571]
index 58ab7c06be25b516044d4038a22d9c8d3832f02d..cd9ed0d17ce04343256c56bc47706e62b3c8cfa7 100644 (file)
@@ -2367,6 +2367,11 @@ configure_catz_zone(dns_view_t *view, const cfg_obj_t *config,
                result = ns_config_getipandkeylist(config, obj,
                                                   view->mctx, &opts->masters);
 
+       obj = cfg_tuple_get(catz_obj, "zone-directory");
+       if (obj != NULL)
+               opts->zonedir = isc_mem_strdup(view->mctx,
+                                              cfg_obj_asstring(obj));
+
        obj = cfg_tuple_get(catz_obj, "in-memory");
        if (obj != NULL && cfg_obj_isboolean(obj))
                opts->in_memory = cfg_obj_asboolean(obj);
index bf1b2d5aa9e62ec532f7a884e6634d23969f098f..9912e55dcdb767c6b102fa1b012330a7ef7638d8 100644 (file)
@@ -17,7 +17,8 @@ rm -f nsupdate.out.*
 rm -f ns*/named.memstats
 rm -f ns*/named.run
 rm -f ns*/named.lock
-rm -f ns{1,2}/*dom*example.db
+rm -f ns1/*dom*example.db
 rm -f ns{1,2}/catalog.example.db
+rm -rf ns2/zonedir
 rm -f ns*/*.jnl
 rm -f ns*/*.nzf
index 4cd508d78bd69116a124e9203448e76414ae5afe..a641a5c160d1f90dcb935d21586e7f95fb9c9e13 100644 (file)
@@ -32,7 +32,10 @@ options {
        recursion no;
        serial-query-rate 100;
        catalog-zones {
-               zone "catalog.example" default-masters { 10.53.0.1; };
+               zone "catalog.example"
+                        default-masters { 10.53.0.1; }
+                        in-memory no
+                        zone-directory "zonedir";
        };
 };
 
index 8e0d3e8d86b72d814f75e626b210ca51529f67fd..7a3dbcdb7d7211be199a67c48779a5b936309770 100644 (file)
@@ -20,3 +20,4 @@ SYSTEMTESTTOP=..
 $SHELL clean.sh
 
 cat ns1/catalog.example.db.in > ns1/catalog.example.db
+mkdir ns2/zonedir
index c72b99c69078e182f90a010bca6386dc929f31eb..4546d89ef38099392609d9fa4d4ff7c6bdc5d9a5 100644 (file)
@@ -301,5 +301,13 @@ grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo "I:checking that zone-directory is populated ($n)"
+ret=0
+[ -f "ns2/zonedir/__catz___default_catalog.example_dom3.example.db" ] || ret=1
+[ -f "ns2/zonedir/__catz___default_catalog.example_dom4.example.db" ] || ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I:exit status: $status"
 exit $status
index 87cf5fbaec8519a8595103638c0245b5202766ae..6f19f90eb2e781ea0911ed29b1f2efb81ec78fd8 100644 (file)
     </para>
 <screen>
 catalog-zones {
-    zone "catalog.example" default-masters { 10.53.0.1; } in-memory true min-update-interval 10;
+       zone "catalog.example"
+            default-masters { 10.53.0.1; } 
+            in-memory no
+            zone-directory "catzones"
+            min-update-interval 10;
 };
 </screen>
     <para>
@@ -119,6 +123,10 @@ catalog-zones {
       properly configured in the same view. In most configurations, it would
       be a slave zone.
     </para>
+    <para>
+      The options following the zone name are not required, and may be
+      specified in any order:
+    </para>
     <para>
       The <option>default-masters</option> option defines the default masters
       for member zones listed in a catalog zone. This can be overridden by
@@ -134,6 +142,14 @@ catalog-zones {
       will be stored locally in a file whose name is automatically generated
       from the view name, catalog zone name, and member zone name.
     </para>
+    <para>
+      The <option>zone-directory</option> option causes local copies of
+      member zones' master files (if <option>in-memory</option> is not set
+      to <literal>yes</literal>) to be stored in the specified directory.
+      The default is to store zone files in the server's working directory.
+      A non-absolute pathname in <option>zone-directory</option> is
+      assumed to be relative to the working directory.
+    </para>
     <para>
       The <option>min-update-interval</option> option sets the minimum
       interval between processing of updates to catalog zones, in seconds.
index 46b467962ede6051246b8137097675f977e6b78e..9364ff1fc0bf7c0290edcbdfeaaaf728a12d22e6 100644 (file)
@@ -96,12 +96,17 @@ dns_catz_options_init(dns_catz_options_t *options) {
 
        options->in_memory = ISC_FALSE;
        options->min_update_interval = 5;
+       options->zonedir = NULL;
 }
 
 void
 dns_catz_options_free(dns_catz_options_t *options, isc_mem_t *mctx) {
        if (options->masters.count > 0)
                dns_ipkeylist_clear(mctx, &options->masters);
+       if (options->zonedir != NULL) {
+               isc_mem_free(mctx, options->zonedir);
+               options->zonedir = NULL;
+       }
 }
 
 isc_result_t
@@ -112,10 +117,17 @@ dns_catz_options_copy(isc_mem_t *mctx, const dns_catz_options_t *src,
        REQUIRE(dst != NULL);
        REQUIRE(dst->masters.count == 0);
 
-       if (src->masters.count != 0) {
+       if (src->masters.count != 0)
                dns_ipkeylist_copy(mctx, &src->masters, &dst->masters);
+
+       if (dst->zonedir != NULL) {
+               isc_mem_free(mctx, dst->zonedir);
+               dst->zonedir = NULL;
        }
 
+       if (src->zonedir != NULL)
+               dst->zonedir = isc_mem_strdup(mctx, src->zonedir);
+
        return (ISC_R_SUCCESS);
 }
 
@@ -125,6 +137,8 @@ dns_catz_options_setdefault(isc_mem_t *mctx, const dns_catz_options_t *defaults,
 {
        if (opts->masters.count == 0)
                dns_catz_options_copy(mctx, defaults, opts);
+       else if (defaults->zonedir != NULL)
+               opts->zonedir = isc_mem_strdup(mctx, defaults->zonedir);
 
        /* This option is always taken from config, so it's always 'default' */
        opts->in_memory = defaults->in_memory;
@@ -234,7 +248,6 @@ dns_catz_entry_cmp(const dns_catz_entry_t *ea, const dns_catz_entry_t *eb) {
        return (ISC_TRUE);
 }
 
-
 dns_name_t *
 dns_catz_zone_getname(dns_catz_zone_t *zone) {
        REQUIRE(zone != NULL);
@@ -1072,6 +1085,7 @@ dns_catz_generate_masterfilename(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
        isc_sha256_t sha256;
        isc_region_t r;
        isc_result_t result;
+       size_t rlen;
 
        REQUIRE(zone != NULL);
        REQUIRE(entry != NULL);
@@ -1079,26 +1093,38 @@ dns_catz_generate_masterfilename(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
 
        result = isc_buffer_allocate(zone->catzs->mctx, &tbuf,
                                     strlen(zone->catzs->view->name) +
-                                    2*DNS_NAME_FORMATSIZE + 2);
+                                    2 * DNS_NAME_FORMATSIZE + 2);
        if (result != ISC_R_SUCCESS)
                return (result);
        INSIST(tbuf != NULL);
+
        isc_buffer_putstr(tbuf, zone->catzs->view->name);
        isc_buffer_putstr(tbuf, "_");
        result = dns_name_totext(&zone->name, ISC_TRUE, tbuf);
        if (result != ISC_R_SUCCESS)
                goto cleanup;
+
        isc_buffer_putstr(tbuf, "_");
        result = dns_name_totext(&entry->name, ISC_TRUE, tbuf);
        if (result != ISC_R_SUCCESS)
                goto cleanup;
 
-       result = isc_buffer_reserve(buffer, strlen("__catz__") +
-                                   ISC_SHA256_DIGESTSTRINGLENGTH +
-                                   strlen(".db"));
+       /* __catz__<digest>.db */
+       rlen = ISC_SHA256_DIGESTSTRINGLENGTH + 12;
+
+       /* optionally prepend with <zonedir>/ */
+       if (entry->opts.zonedir != NULL)
+               rlen += strlen(entry->opts.zonedir) + 1;
+
+       result = isc_buffer_reserve(buffer, rlen);
        if (result != ISC_R_SUCCESS)
                goto cleanup;
 
+       if (entry->opts.zonedir != NULL) {
+               isc_buffer_putstr(*buffer, entry->opts.zonedir);
+               isc_buffer_putstr(*buffer, "/");
+       }
+
        isc_buffer_usedregion(tbuf, &r);
        isc_buffer_putstr(*buffer, "__catz__");
        if (tbuf->used > ISC_SHA256_DIGESTSTRINGLENGTH) {
@@ -1110,11 +1136,13 @@ dns_catz_generate_masterfilename(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
        } else {
                isc_buffer_copyregion(*buffer, &r);
        }
+
        isc_buffer_putstr(*buffer, ".db");
        result = ISC_R_SUCCESS;
 
 cleanup:
-       isc_buffer_free(&tbuf);
+       if (tbuf != NULL)
+               isc_buffer_free(&tbuf);
        return (result);
 }
 
index 7cff8b9b332c7950807410094d4ac3aeb1e5558e..73bd25028e2213108f6fd6af33747e1812865387 100644 (file)
@@ -51,12 +51,15 @@ struct dns_catz_entry_options {
        /*
         * Options that can be overriden in catalog zone
         */
-       /* masters definition */
+       /* default-masters definition */
        dns_ipkeylist_t masters;
 
        /*
         * Options that are only set in named.conf
         */
+       /* zone-directory definition */
+       char *zonedir;
+
        /* zone should not be stored on disk (no 'file' statement in def */
        isc_boolean_t in_memory;
        /*
index a3ca7c8163bee260dd26f7883701410bc11e73d5..f45eec6483fef80357f18569628d7817cc9e3539 100644 (file)
@@ -1484,6 +1484,7 @@ static cfg_type_t cfg_type_catz_zone = {
 static cfg_tuplefielddef_t catz_zone_fields[] = {
        { "zone name", &cfg_type_catz_zone, 0 },
        { "default-masters", &cfg_type_namesockaddrkeylist, 0 },
+       { "zone-directory", &cfg_type_qstring, 0 },
        { "in-memory", &cfg_type_boolean, 0 },
        { "min-update-interval", &cfg_type_uint32, 0 },
        { NULL, NULL, 0 }