zoneconf.c revision 3aca8e5bf3740bbcc3bb13dde242d7cc369abb27
9e6de65c57eddc3790badaad3b9481aaaed18e03Brian Wellington/*
69fe9aaafdd6a141610e86a777d325db75422070Mark Andrews * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Copyright (C) 1999-2003 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * Permission to use, copy, modify, and distribute this software for any
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * purpose with or without fee is hereby granted, provided that the above
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence */
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉/* $Id: zoneconf.c,v 1.119 2005/02/10 05:53:42 marka Exp $ */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#include <config.h>
d09197467bbb156dccf0cbe72bb5c63480d5cfdcDavid Lawrence
d09197467bbb156dccf0cbe72bb5c63480d5cfdcDavid Lawrence#include <isc/buffer.h>
d09197467bbb156dccf0cbe72bb5c63480d5cfdcDavid Lawrence#include <isc/file.h>
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff#include <isc/mem.h>
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff#include <isc/print.h>
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence#include <isc/string.h> /* Required for HP/UX (and others?) */
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews#include <isc/util.h>
dd57718608494835363244429432599aa15124a3Andreas Gustafsson
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉#include <dns/acl.h>
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence#include <dns/fixedname.h>
82a1986c04057804edf670bf5d59f716785af789Bob Halley#include <dns/log.h>
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence#include <dns/name.h>
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#include <dns/rdatatype.h>
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence#include <dns/ssu.h>
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence#include <dns/view.h>
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence#include <dns/zone.h>
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence#include <named/client.h>
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence#include <named/config.h>
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence#include <named/globals.h>
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence#include <named/log.h>
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence#include <named/server.h>
cace8ff3bdf0d7f3501d1fb728f936d49a190471David Lawrence#include <named/zoneconf.h>
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence/*
c80dde0676a7f36f65e0ad8d646bf505705fe64bDavid Lawrence * These are BIND9 server defaults, not necessarily identical to the
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * library defaults defined in zone.c.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#define RETERR(x) do { \
c80dde0676a7f36f65e0ad8d646bf505705fe64bDavid Lawrence isc_result_t _r = (x); \
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence if (_r != ISC_R_SUCCESS) \
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence return (_r); \
33950f0a0262f4d49528c4adcf8be42807fa2576David Lawrence } while (0)
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence/*
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence * Convenience function for configuring a single zone ACL.
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinstatic isc_result_t
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrenceconfigure_zone_acl(cfg_obj_t *zconfig, cfg_obj_t *vconfig, cfg_obj_t *config,
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence const char *aclname, cfg_aclconfctx_t *actx,
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dns_zone_t *zone,
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence void (*setzacl)(dns_zone_t *, dns_acl_t *),
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence void (*clearzacl)(dns_zone_t *))
c4c843edb3f4c609e3552ee77a43400852400467David Lawrence{
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley isc_result_t result;
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 cfg_obj_t *maps[4];
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley cfg_obj_t *aclobj = NULL;
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington int i = 0;
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence dns_acl_t *dacl = NULL;
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence if (zconfig != NULL)
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence maps[i++] = cfg_tuple_get(zconfig, "options");
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence if (vconfig != NULL)
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence maps[i++] = cfg_tuple_get(vconfig, "options");
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence if (config != NULL) {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein cfg_obj_t *options = NULL;
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence (void)cfg_map_get(config, "options", &options);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence if (options != NULL)
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence maps[i++] = options;
cec7a04adc665a8c1029be008fd97c018c12c1b3David Lawrence }
cec7a04adc665a8c1029be008fd97c018c12c1b3David Lawrence maps[i] = NULL;
cec7a04adc665a8c1029be008fd97c018c12c1b3David Lawrence
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence result = ns_config_get(maps, aclname, &aclobj);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence if (aclobj == NULL) {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence (*clearzacl)(zone);
cec7a04adc665a8c1029be008fd97c018c12c1b3David Lawrence return (ISC_R_SUCCESS);
cec7a04adc665a8c1029be008fd97c018c12c1b3David Lawrence }
cec7a04adc665a8c1029be008fd97c018c12c1b3David Lawrence
cec7a04adc665a8c1029be008fd97c018c12c1b3David Lawrence result = cfg_acl_fromconfig(aclobj, config, ns_g_lctx, actx,
cec7a04adc665a8c1029be008fd97c018c12c1b3David Lawrence dns_zone_getmctx(zone), &dacl);
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence if (result != ISC_R_SUCCESS)
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence return (result);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence (*setzacl)(zone, dacl);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein dns_acl_detach(&dacl);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence return (ISC_R_SUCCESS);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence}
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence/*
593d951248f799e90d30bc69bb89342000b012cdBob Halley * Parse the zone update-policy statement.
82a1986c04057804edf670bf5d59f716785af789Bob Halley */
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrencestatic isc_result_t
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinconfigure_zone_ssutable(cfg_obj_t *zconfig, dns_zone_t *zone) {
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence cfg_obj_t *updatepolicy = NULL;
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence cfg_listelt_t *element, *element2;
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence dns_ssutable_t *table = NULL;
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence isc_mem_t *mctx = dns_zone_getmctx(zone);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence isc_result_t result;
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence (void)cfg_map_get(zconfig, "update-policy", &updatepolicy);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence if (updatepolicy == NULL)
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein return (ISC_R_SUCCESS);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence result = dns_ssutable_create(mctx, &table);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence if (result != ISC_R_SUCCESS)
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence return (result);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence for (element = cfg_list_first(updatepolicy);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence element != NULL;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein element = cfg_list_next(element))
33950f0a0262f4d49528c4adcf8be42807fa2576David Lawrence {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence cfg_obj_t *stmt = cfg_listelt_value(element);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence cfg_obj_t *mode = cfg_tuple_get(stmt, "mode");
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence cfg_obj_t *identity = cfg_tuple_get(stmt, "identity");
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence cfg_obj_t *matchtype = cfg_tuple_get(stmt, "matchtype");
33950f0a0262f4d49528c4adcf8be42807fa2576David Lawrence cfg_obj_t *dname = cfg_tuple_get(stmt, "name");
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence cfg_obj_t *typelist = cfg_tuple_get(stmt, "types");
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence char *str;
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley isc_boolean_t grant = ISC_FALSE;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein unsigned int mtype = DNS_SSUMATCHTYPE_NAME;
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley dns_fixedname_t fname, fident;
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley isc_buffer_t b;
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley dns_rdatatype_t *types;
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley unsigned int i, n;
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley str = cfg_obj_asstring(mode);
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley if (strcasecmp(str, "grant") == 0)
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence grant = ISC_TRUE;
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence else if (strcasecmp(str, "deny") == 0)
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence grant = ISC_FALSE;
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence else
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence INSIST(0);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley str = cfg_obj_asstring(matchtype);
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley if (strcasecmp(str, "name") == 0)
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews mtype = DNS_SSUMATCHTYPE_NAME;
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews else if (strcasecmp(str, "subdomain") == 0)
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews mtype = DNS_SSUMATCHTYPE_SUBDOMAIN;
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews else if (strcasecmp(str, "wildcard") == 0)
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews mtype = DNS_SSUMATCHTYPE_WILDCARD;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else if (strcasecmp(str, "self") == 0)
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence mtype = DNS_SSUMATCHTYPE_SELF;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence INSIST(0);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence dns_fixedname_init(&fident);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence str = cfg_obj_asstring(identity);
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence isc_buffer_init(&b, str, strlen(str));
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence isc_buffer_add(&b, strlen(str));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = dns_name_fromtext(dns_fixedname_name(&fident), &b,
33950f0a0262f4d49528c4adcf8be42807fa2576David Lawrence dns_rootname, ISC_FALSE, NULL);
33950f0a0262f4d49528c4adcf8be42807fa2576David Lawrence if (result != ISC_R_SUCCESS) {
84f8cc7e22cccde283627f6df6b8b74ec473cdc9David Lawrence cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence "'%s' is not a valid name", str);
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence goto cleanup;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence }
401fc772b1bf058a981e3c474fa6502f6ee0e2bfDavid Lawrence
401fc772b1bf058a981e3c474fa6502f6ee0e2bfDavid Lawrence dns_fixedname_init(&fname);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence str = cfg_obj_asstring(dname);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence isc_buffer_init(&b, str, strlen(str));
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence isc_buffer_add(&b, strlen(str));
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence result = dns_name_fromtext(dns_fixedname_name(&fname), &b,
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence dns_rootname, ISC_FALSE, NULL);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence if (result != ISC_R_SUCCESS) {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence "'%s' is not a valid name", str);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence goto cleanup;
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence }
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence n = ns_config_listcount(typelist);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence if (n == 0)
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence types = NULL;
a571ebca8b8c472e775d518e82b7335f93ea25c4Andreas Gustafsson else {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence types = isc_mem_get(mctx, n * sizeof(dns_rdatatype_t));
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence if (types == NULL) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = ISC_R_NOMEMORY;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence goto cleanup;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence }
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence }
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence i = 0;
08e57545c2b1068080f5bf317224160426801406Brian Wellington for (element2 = cfg_list_first(typelist);
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews element2 != NULL;
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews element2 = cfg_list_next(element2))
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence cfg_obj_t *typeobj;
08e57545c2b1068080f5bf317224160426801406Brian Wellington isc_textregion_t r;
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews
08e57545c2b1068080f5bf317224160426801406Brian Wellington INSIST(i < n);
08e57545c2b1068080f5bf317224160426801406Brian Wellington
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence typeobj = cfg_listelt_value(element2);
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence str = cfg_obj_asstring(typeobj);
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence r.base = str;
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence r.length = strlen(str);
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = dns_rdatatype_fromtext(&types[i++], &r);
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence if (result != ISC_R_SUCCESS) {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence "'%s' is not a valid type", str);
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence isc_mem_put(mctx, types,
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence n * sizeof(dns_rdatatype_t));
03052a178cb33b7d62ada0e34f1974e22bb98023David Lawrence goto cleanup;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence }
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews }
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence INSIST(i == n);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews result = dns_ssutable_addrule(table, grant,
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews dns_fixedname_name(&fident),
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews mtype,
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews dns_fixedname_name(&fname),
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence n, types);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (types != NULL)
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence isc_mem_put(mctx, types, n * sizeof(dns_rdatatype_t));
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff if (result != ISC_R_SUCCESS) {
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 goto cleanup;
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 }
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley }
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews result = ISC_R_SUCCESS;
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews dns_zone_setssutable(zone, table);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews cleanup:
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dns_ssutable_detach(&table);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence return (result);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence}
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence/*
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * Convert a config file zone type into a server zone type.
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence */
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrencestatic inline dns_zonetype_t
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrencezonetype_fromconfig(cfg_obj_t *map) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence cfg_obj_t *obj = NULL;
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence isc_result_t result;
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence result = cfg_map_get(map, "type", &obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence INSIST(result == ISC_R_SUCCESS);
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington return (ns_config_getzonetype(obj));
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence}
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews/*
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews * Helper function for strtoargv(). Pardon the gratuitous recursion.
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews */
7554feaef6057f5ea2926076900ac7634b911456Mark Andrewsstatic isc_result_t
7554feaef6057f5ea2926076900ac7634b911456Mark Andrewsstrtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp,
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews char ***argvp, unsigned int n)
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews{
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence isc_result_t result;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence /* Discard leading whitespace. */
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence while (*s == ' ' || *s == '\t')
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence s++;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (*s == '\0') {
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 /* We have reached the end of the string. */
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 *argcp = n;
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 *argvp = isc_mem_get(mctx, n * sizeof(char *));
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 if (*argvp == NULL)
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 return (ISC_R_NOMEMORY);
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 } else {
5597be9bb88de138dfec9fa9176708443813925eTatuya JINMEI 神明達哉 char *p = s;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence while (*p != ' ' && *p != '\t' && *p != '\0')
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence p++;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (*p != '\0')
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence *p++ = '\0';
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews result = strtoargvsub(mctx, p, argcp, argvp, n + 1);
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews if (result != ISC_R_SUCCESS)
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews return (result);
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews (*argvp)[n] = s;
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews }
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence return (ISC_R_SUCCESS);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence}
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence/*
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * Tokenize the string "s" into whitespace-separated words,
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * return the number of words in '*argcp' and an array
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews * of pointers to the words in '*argvp'. The caller
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews * must free the array using isc_mem_put(). The string
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews * is modified in-place.
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence */
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellingtonstatic isc_result_t
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellingtonstrtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp) {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence return (strtoargvsub(mctx, s, argcp, argvp, 0));
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence}
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrencestatic void
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrencechecknames(dns_zonetype_t ztype, cfg_obj_t **maps, cfg_obj_t **objp) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence const char *zone = NULL;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence isc_result_t result;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews switch (ztype) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence case dns_zone_slave: zone = "slave"; break;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence case dns_zone_master: zone = "master"; break;
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington default:
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington INSIST(0);
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington }
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington result = ns_checknames_get(maps, zone, objp);
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington INSIST(result == ISC_R_SUCCESS);
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington}
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrenceisc_result_t
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrencens_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig,
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence cfg_aclconfctx_t *ac, dns_zone_t *zone)
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence{
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence isc_result_t result;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington char *zname;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence dns_rdataclass_t zclass;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence dns_rdataclass_t vclass;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence cfg_obj_t *maps[5];
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington cfg_obj_t *zoptions = NULL;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington cfg_obj_t *options = NULL;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington cfg_obj_t *obj;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington const char *filename = NULL;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington dns_notifytype_t notifytype = dns_notifytype_yes;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington isc_sockaddr_t *addrs;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington dns_name_t **keynames;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington isc_uint32_t count;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington char *cpval;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence unsigned int dbargc;
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington char **dbargv;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence static char default_dbtype[] = "rbt";
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence isc_mem_t *mctx = dns_zone_getmctx(zone);
15bc0af6a1e7e1701179d22db729416e584ae904Brian Wellington dns_dialuptype_t dialup = dns_dialuptype_no;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence dns_zonetype_t ztype;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence int i;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence isc_int32_t journal_size;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence isc_boolean_t multi;
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff isc_boolean_t alt;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence dns_view_t *view;
19c5c23ef6e38965949c996592bd92478da0612cMark Andrews isc_boolean_t check = ISC_FALSE, fail = ISC_FALSE;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence isc_boolean_t ixfrdiff;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence i = 0;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence if (zconfig != NULL) {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence zoptions = cfg_tuple_get(zconfig, "options");
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence maps[i++] = zoptions;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence }
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence if (vconfig != NULL)
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence maps[i++] = cfg_tuple_get(vconfig, "options");
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence if (config != NULL) {
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence (void)cfg_map_get(config, "options", &options);
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence if (options != NULL)
19c5c23ef6e38965949c996592bd92478da0612cMark Andrews maps[i++] = options;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence }
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence maps[i++] = ns_g_defaults;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence maps[i++] = NULL;
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence if (vconfig != NULL)
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence RETERR(ns_config_getclass(cfg_tuple_get(vconfig, "class"),
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dns_rdataclass_in, &vclass));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence vclass = dns_rdataclass_in;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff /*
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence * Configure values common to all zone types.
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence */
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence zname = cfg_obj_asstring(cfg_tuple_get(zconfig, "name"));
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews RETERR(ns_config_getclass(cfg_tuple_get(zconfig, "class"),
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews vclass, &zclass));
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence dns_zone_setclass(zone, zclass);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence ztype = zonetype_fromconfig(zoptions);
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley dns_zone_settype(zone, ztype);
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews obj = NULL;
587fc7b519b0fed4e3dd234527edba1ca9334757David Lawrence result = cfg_map_get(zoptions, "database", &obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (result == ISC_R_SUCCESS)
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence cpval = cfg_obj_asstring(obj);
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence else
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence cpval = default_dbtype;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence RETERR(strtoargv(mctx, cpval, &dbargc, &dbargv));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence /*
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * ANSI C is strange here. There is no logical reason why (char **)
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrews * cannot be promoted automatically to (const char * const *) by the
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * compiler w/o generating a warning.
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence */
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence RETERR(dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv));
df1e2d496e50f6fea810a5ed12f0e290f4261ab3David Lawrence isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence result = cfg_map_get(zoptions, "file", &obj);
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence if (result == ISC_R_SUCCESS)
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington filename = cfg_obj_asstring(obj);
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence RETERR(dns_zone_setfile(zone, filename));
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence obj = NULL;
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews result = cfg_map_get(zoptions, "journal", &obj);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence if (result == ISC_R_SUCCESS)
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence RETERR(dns_zone_setjournal(zone, cfg_obj_asstring(obj)));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (ztype == dns_zone_slave)
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence RETERR(configure_zone_acl(zconfig, vconfig, config,
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence "allow-notify", ac, zone,
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence dns_zone_setnotifyacl,
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence dns_zone_clearnotifyacl));
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence /*
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence * XXXAG This probably does not make sense for stubs.
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence */
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence RETERR(configure_zone_acl(zconfig, vconfig, config,
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence "allow-query", ac, zone,
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence dns_zone_setqueryacl,
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence dns_zone_clearqueryacl));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence obj = NULL;
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews result = ns_config_get(maps, "dialup", &obj);
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews INSIST(result == ISC_R_SUCCESS);
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews if (cfg_obj_isboolean(obj)) {
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews if (cfg_obj_asboolean(obj))
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence dialup = dns_dialuptype_yes;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dialup = dns_dialuptype_no;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence } else {
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley char *dialupstr = cfg_obj_asstring(obj);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence if (strcasecmp(dialupstr, "notify") == 0)
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 dialup = dns_dialuptype_notify;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else if (strcasecmp(dialupstr, "notify-passive") == 0)
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence dialup = dns_dialuptype_notifypassive;
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence else if (strcasecmp(dialupstr, "refresh") == 0)
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence dialup = dns_dialuptype_refresh;
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence else if (strcasecmp(dialupstr, "passive") == 0)
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dialup = dns_dialuptype_passive;
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence else
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence INSIST(0);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence }
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence dns_zone_setdialup(zone, dialup);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence obj = NULL;
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence result = ns_config_get(maps, "zone-statistics", &obj);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence INSIST(result == ISC_R_SUCCESS);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence RETERR(dns_zone_setstatistics(zone, cfg_obj_asboolean(obj)));
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence /*
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence * Configure master functionality. This applies
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence * to primary masters (type "master") and slaves
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * acting as masters (type "slave"), but not to stubs.
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence */
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (ztype != dns_zone_stub) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = ns_config_get(maps, "notify", &obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence INSIST(result == ISC_R_SUCCESS);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (cfg_obj_isboolean(obj)) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (cfg_obj_asboolean(obj))
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence notifytype = dns_notifytype_yes;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence notifytype = dns_notifytype_no;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence } else {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence char *notifystr = cfg_obj_asstring(obj);
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews if (strcasecmp(notifystr, "explicit") == 0)
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence notifytype = dns_notifytype_explicit;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else if (strcasecmp(notifystr, "master-only") == 0)
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence notifytype = dns_notifytype_masteronly;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence INSIST(0);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence }
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence dns_zone_setnotifytype(zone, notifytype);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 obj = NULL;
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 result = ns_config_get(maps, "also-notify", &obj);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence if (result == ISC_R_SUCCESS) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence isc_sockaddr_t *addrs = NULL;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence isc_uint32_t addrcount;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = ns_config_getiplist(config, obj, 0, mctx,
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence &addrs, &addrcount);
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence if (result != ISC_R_SUCCESS)
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence return (result);
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence result = dns_zone_setalsonotify(zone, addrs,
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence addrcount);
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence ns_config_putiplist(mctx, &addrs, addrcount);
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence if (result != ISC_R_SUCCESS)
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence return (result);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence } else
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence RETERR(dns_zone_setalsonotify(zone, NULL, 0));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = ns_config_get(maps, "notify-source", &obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence INSIST(result == ISC_R_SUCCESS);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence RETERR(dns_zone_setnotifysrc4(zone, cfg_obj_assockaddr(obj)));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence result = ns_config_get(maps, "notify-source-v6", &obj);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence INSIST(result == ISC_R_SUCCESS);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence RETERR(dns_zone_setnotifysrc6(zone, cfg_obj_assockaddr(obj)));
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
84f8cc7e22cccde283627f6df6b8b74ec473cdc9David Lawrence
84f8cc7e22cccde283627f6df6b8b74ec473cdc9David Lawrence dns_zone_setisself(zone, ns_client_isself, NULL);
84f8cc7e22cccde283627f6df6b8b74ec473cdc9David Lawrence
84f8cc7e22cccde283627f6df6b8b74ec473cdc9David Lawrence RETERR(configure_zone_acl(zconfig, vconfig, config,
84f8cc7e22cccde283627f6df6b8b74ec473cdc9David Lawrence "allow-transfer", ac, zone,
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence dns_zone_setxfracl,
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence dns_zone_clearxfracl));
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence obj = NULL;
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence result = ns_config_get(maps, "max-transfer-time-out", &obj);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence INSIST(result == ISC_R_SUCCESS);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence dns_zone_setmaxxfrout(zone, cfg_obj_asuint32(obj) * 60);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence
84f8cc7e22cccde283627f6df6b8b74ec473cdc9David Lawrence obj = NULL;
84f8cc7e22cccde283627f6df6b8b74ec473cdc9David Lawrence result = ns_config_get(maps, "max-transfer-idle-out", &obj);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence INSIST(result == ISC_R_SUCCESS);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence dns_zone_setidleout(zone, cfg_obj_asuint32(obj) * 60);
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence obj = NULL;
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence result = ns_config_get(maps, "max-journal-size", &obj);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence INSIST(result == ISC_R_SUCCESS);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dns_zone_setjournalsize(zone, -1);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence if (cfg_obj_isstring(obj)) {
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence const char *str = cfg_obj_asstring(obj);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence INSIST(strcasecmp(str, "unlimited") == 0);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence journal_size = ISC_UINT32_MAX / 2;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence } else {
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 isc_resourcevalue_t value;
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 value = cfg_obj_asuint64(obj);
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 if (value > ISC_UINT32_MAX / 2) {
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 cfg_obj_log(obj, ns_g_lctx,
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence ISC_LOG_ERROR,
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence "'max-journal-size "
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence "%" ISC_PRINT_QUADFORMAT "d' "
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence "is too large",
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence value);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence RETERR(ISC_R_RANGE);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence }
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence journal_size = (isc_uint32_t)value;
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence }
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence dns_zone_setjournalsize(zone, journal_size);
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence obj = NULL;
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence result = ns_config_get(maps, "ixfr-from-differences", &obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence INSIST(result == ISC_R_SUCCESS);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence if (cfg_obj_isboolean(obj))
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence ixfrdiff = cfg_obj_asboolean(obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence else if (strcasecmp(cfg_obj_asstring(obj), "master") &&
3ff8d68793ec466b25dda6ed05d4ec673b66605eBob Halley ztype == dns_zone_master)
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence ixfrdiff = ISC_TRUE;
d65db52903505c1bcbc6dd1651e9f9f347e48217David Lawrence else if (strcasecmp(cfg_obj_asstring(obj), "slave") &&
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence ztype == dns_zone_slave)
d65db52903505c1bcbc6dd1651e9f9f347e48217David Lawrence ixfrdiff = ISC_TRUE;
3ff8d68793ec466b25dda6ed05d4ec673b66605eBob Halley else
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence ixfrdiff = ISC_FALSE;
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence dns_zone_setoption(zone, DNS_ZONEOPT_IXFRFROMDIFFS, ixfrdiff);
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence checknames(ztype, maps, &obj);
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence INSIST(obj != NULL);
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence fail = ISC_FALSE;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence check = ISC_TRUE;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence fail = check = ISC_TRUE;
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence fail = check = ISC_FALSE;
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence } else
6a0cb547d4d73579d4a87ce0c82233b76e8f3c4cDavid Lawrence INSIST(0);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMES, check);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMESFAIL, fail);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
73d62a89f1493865c33c689b3ee3de91c74ad58eDavid Lawrence result = ns_config_get(maps, "notify-delay", &obj);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence INSIST(result == ISC_R_SUCCESS);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence dns_zone_setnotifydelay(zone, cfg_obj_asuint32(obj));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence }
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence /*
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence * Configure update-related options. These apply to
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence * primary masters only.
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence */
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence if (ztype == dns_zone_master) {
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence dns_acl_t *updateacl;
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence RETERR(configure_zone_acl(zconfig, vconfig, config,
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence "allow-update", ac, zone,
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence dns_zone_setupdateacl,
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence dns_zone_clearupdateacl));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington updateacl = dns_zone_getupdateacl(zone);
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews if (updateacl != NULL && dns_acl_isinsecure(updateacl))
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews isc_log_write(ns_g_lctx, DNS_LOGCATEGORY_SECURITY,
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews "zone '%s' allows updates by IP "
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington "address, which is insecure",
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence zname);
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrews
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence RETERR(configure_zone_ssutable(zoptions, zone));
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence obj = NULL;
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence result = ns_config_get(maps, "sig-validity-interval", &obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence INSIST(result == ISC_R_SUCCESS);
f036af2c718147408d738081cdb0a564b981b4cdDavid Lawrence dns_zone_setsigvalidityinterval(zone,
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence cfg_obj_asuint32(obj) * 86400);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = ns_config_get(maps, "key-directory", &obj);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence if (result == ISC_R_SUCCESS) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence filename = cfg_obj_asstring(obj);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence if (!isc_file_isabsolute(filename)) {
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence cfg_obj_log(obj, ns_g_lctx, ISC_LOG_ERROR,
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence "key-directory '%s' "
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence "is not absolute", filename);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence return (ISC_R_FAILURE);
e94e2fe29db85dd7872cbd4635aa50d5e2883c8aDavid Lawrence }
e94e2fe29db85dd7872cbd4635aa50d5e2883c8aDavid Lawrence RETERR(dns_zone_setkeydirectory(zone, filename));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence }
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence obj = NULL;
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence result = ns_config_get(maps, "check-wildcard", &obj);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence if (result == ISC_R_SUCCESS)
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence check = cfg_obj_asboolean(obj);
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 else
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 check = ISC_FALSE;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence dns_zone_setoption(zone, DNS_ZONEOPT_CHECKWILDCARD, check);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence } else if (ztype == dns_zone_slave) {
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence RETERR(configure_zone_acl(zconfig, vconfig, config,
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence "allow-update-forwarding", ac, zone,
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dns_zone_setforwardacl,
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dns_zone_clearforwardacl));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence }
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence /*
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * Configure slave functionality.
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence */
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence switch (ztype) {
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence case dns_zone_slave:
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence case dns_zone_stub:
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence obj = NULL;
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington result = cfg_map_get(zoptions, "masters", &obj);
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence if (obj != NULL) {
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews addrs = NULL;
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence keynames = NULL;
8e1f35e1d738e0bd22ab7971f0ec875a473eb1a2David Lawrence RETERR(ns_config_getipandkeylist(config, obj, mctx,
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence &addrs, &keynames,
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence &count));
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence result = dns_zone_setmasterswithkeys(zone, addrs,
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence keynames, count);
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence ns_config_putipandkeylist(mctx, &addrs, &keynames,
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence count);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff } else
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence result = dns_zone_setmasters(zone, NULL, 0);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff RETERR(result);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence multi = ISC_FALSE;
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence if (count > 1) {
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence obj = NULL;
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence result = ns_config_get(maps, "multi-master", &obj);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence INSIST(result == ISC_R_SUCCESS);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence multi = cfg_obj_asboolean(obj);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence }
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence dns_zone_setoption(zone, DNS_ZONEOPT_MULTIMASTER, multi);
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence obj = NULL;
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence result = ns_config_get(maps, "max-transfer-time-in", &obj);
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence INSIST(result == ISC_R_SUCCESS);
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence dns_zone_setmaxxfrin(zone, cfg_obj_asuint32(obj) * 60);
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence obj = NULL;
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence result = ns_config_get(maps, "max-transfer-idle-in", &obj);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence INSIST(result == ISC_R_SUCCESS);
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence dns_zone_setidlein(zone, cfg_obj_asuint32(obj) * 60);
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = ns_config_get(maps, "max-refresh-time", &obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence INSIST(result == ISC_R_SUCCESS);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dns_zone_setmaxrefreshtime(zone, cfg_obj_asuint32(obj));
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence result = ns_config_get(maps, "min-refresh-time", &obj);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff INSIST(result == ISC_R_SUCCESS);
194f54f4da604a6601edefa2175d48412e01bf2fDavid Lawrence dns_zone_setminrefreshtime(zone, cfg_obj_asuint32(obj));
5f50687f61057f7f0acb161d5803f4a48e40b3a8David Lawrence
0a09237aa0b12f9e478a9617d9d54c8b3512f94bBob Halley obj = NULL;
5f50687f61057f7f0acb161d5803f4a48e40b3a8David Lawrence result = ns_config_get(maps, "max-retry-time", &obj);
587fc7b519b0fed4e3dd234527edba1ca9334757David Lawrence INSIST(result == ISC_R_SUCCESS);
c5945fe694dd3d9db54647e5a06ba184a074b620Brian Wellington dns_zone_setmaxretrytime(zone, cfg_obj_asuint32(obj));
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence
df1e2d496e50f6fea810a5ed12f0e290f4261ab3David Lawrence obj = NULL;
df1e2d496e50f6fea810a5ed12f0e290f4261ab3David Lawrence result = ns_config_get(maps, "min-retry-time", &obj);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence INSIST(result == ISC_R_SUCCESS);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff dns_zone_setminretrytime(zone, cfg_obj_asuint32(obj));
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉
40e7c805a8f38ad9b20dd6c688496fc09fc971c2Mark Andrews obj = NULL;
587fc7b519b0fed4e3dd234527edba1ca9334757David Lawrence result = ns_config_get(maps, "transfer-source", &obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence INSIST(result == ISC_R_SUCCESS);
c4c843edb3f4c609e3552ee77a43400852400467David Lawrence RETERR(dns_zone_setxfrsource4(zone, cfg_obj_assockaddr(obj)));
891a1bead8d02d29eb7b4993d7c0975047b0963dDavid Lawrence ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
587fc7b519b0fed4e3dd234527edba1ca9334757David Lawrence
d7197f2ab048f882cc9f331371096347b9f73df8David Lawrence obj = NULL;
d7197f2ab048f882cc9f331371096347b9f73df8David Lawrence result = ns_config_get(maps, "transfer-source-v6", &obj);
33950f0a0262f4d49528c4adcf8be42807fa2576David Lawrence INSIST(result == ISC_R_SUCCESS);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence RETERR(dns_zone_setxfrsource6(zone, cfg_obj_assockaddr(obj)));
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence obj = NULL;
33950f0a0262f4d49528c4adcf8be42807fa2576David Lawrence result = ns_config_get(maps, "alt-transfer-source", &obj);
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence INSIST(result == ISC_R_SUCCESS);
d7197f2ab048f882cc9f331371096347b9f73df8David Lawrence RETERR(dns_zone_setaltxfrsource4(zone, cfg_obj_assockaddr(obj)));
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence obj = NULL;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence result = ns_config_get(maps, "alt-transfer-source-v6", &obj);
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence INSIST(result == ISC_R_SUCCESS);
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence RETERR(dns_zone_setaltxfrsource6(zone, cfg_obj_assockaddr(obj)));
a6aa36b513d80b086991974cd8834418f045c1ceBob Halley
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrence obj = NULL;
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence (void)ns_config_get(maps, "use-alt-transfer-source", &obj);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence if (obj == NULL) {
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence /*
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrews * Default off when views are in use otherwise
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence * on for BIND 8 compatibility.
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence */
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence view = dns_zone_getview(zone);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence if (view != NULL && strcmp(view->name, "_default") == 0)
a6aa36b513d80b086991974cd8834418f045c1ceBob Halley alt = ISC_TRUE;
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence else
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence alt = ISC_FALSE;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence } else
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence alt = cfg_obj_asboolean(obj);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence dns_zone_setoption(zone, DNS_ZONEOPT_USEALTXFRSRC, alt);
df1e2d496e50f6fea810a5ed12f0e290f4261ab3David Lawrence
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 break;
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrews
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrews default:
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence break;
df1e2d496e50f6fea810a5ed12f0e290f4261ab3David Lawrence }
df1e2d496e50f6fea810a5ed12f0e290f4261ab3David Lawrence
f53facef171a053ab94f62a46e860b2c7ed88e54Bob Halley return (ISC_R_SUCCESS);
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence}
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrenceisc_boolean_t
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrencens_zone_reusable(dns_zone_t *zone, cfg_obj_t *zconfig) {
194f54f4da604a6601edefa2175d48412e01bf2fDavid Lawrence cfg_obj_t *zoptions = NULL;
9a41936e3dbc11c378cd1d397f47fefb18d456abBrian Wellington cfg_obj_t *obj = NULL;
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence const char *cfilename;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence const char *zfilename;
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence
93b01c72951b56eeddf8d4bdceb06785b322e1fdDavid Lawrence zoptions = cfg_tuple_get(zconfig, "options");
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence if (zonetype_fromconfig(zoptions) != dns_zone_gettype(zone))
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence return (ISC_FALSE);
005c7ad70f55a6e4333808cdf63811777254c339David Lawrence
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence obj = NULL;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence (void)cfg_map_get(zoptions, "file", &obj);
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington if (obj != NULL)
08e57545c2b1068080f5bf317224160426801406Brian Wellington cfilename = cfg_obj_asstring(obj);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence else
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence cfilename = NULL;
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence zfilename = dns_zone_getfile(zone);
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence if (!((cfilename == NULL && zfilename == NULL) ||
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence (cfilename != NULL && zfilename != NULL &&
08e57545c2b1068080f5bf317224160426801406Brian Wellington strcmp(cfilename, zfilename) == 0)))
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence return (ISC_FALSE);
7fe56f41ec1bf6dd86e592e2fe8c3c33bc102c7aDavid Lawrence
7fe56f41ec1bf6dd86e592e2fe8c3c33bc102c7aDavid Lawrence return (ISC_TRUE);
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrews}
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrews