zoneconf.c revision a7e803adb0894257fbc0fc4560ff5d915c2b6194
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt/*
e20788e1216ed720aefa84f3295f7899d9f28c22Mark Andrews * Copyright (C) 1999, 2000 Internet Software Consortium.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt *
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * Permission to use, copy, modify, and distribute this software for any
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * purpose with or without fee is hereby granted, provided that the above
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * copyright notice and this permission notice appear in all copies.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt *
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * SOFTWARE.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <config.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <isc/assertions.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <isc/error.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <isc/mem.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <isc/result.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <dns/aclconf.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <dns/types.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <dns/zone.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#include <dns/zoneconf.h>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt/* XXX copied from zone.c */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#define MAX_XFER_TIME (2*3600) /* Documented default is 2 hours. */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#define DNS_DEFAULT_IDLEIN 3600 /* 1 hour */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#define DNS_DEFAULT_IDLEOUT 3600 /* 1 hour */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt/*
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * Convenience function for configuring a single zone ACL.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt */
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Huntstatic isc_result_t
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Huntconfigure_zone_acl(dns_c_zone_t *czone, dns_c_ctx_t *cctx,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_aclconfctx_t *aclconfctx, dns_zone_t *zone,
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt isc_result_t (*getcacl)(dns_c_zone_t *, dns_c_ipmatchlist_t **),
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt void (*setzacl)(dns_zone_t *, dns_acl_t *),
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt void (*clearzacl)(dns_zone_t *))
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt{
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_result_t result;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_ipmatchlist_t *cacl;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_acl_t *dacl = NULL;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = (*getcacl)(czone, &cacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_acl_fromconfig(cacl, cctx, aclconfctx,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_getmctx(zone), &dacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_ipmatchlist_detach(&cacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt (*setzacl)(zone, dacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_acl_detach(&dacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (ISC_R_SUCCESS);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt } else if (result == ISC_R_NOTFOUND) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt (*clearzacl)(zone);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (ISC_R_SUCCESS);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt } else {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
e20788e1216ed720aefa84f3295f7899d9f28c22Mark Andrews }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt}
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntstatic dns_zonetype_t
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntdns_zonetype_fromconf(dns_c_zonetype_t cztype) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt switch (cztype) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_master:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return dns_zone_master;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_forward:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return dns_zone_forward;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_slave:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return dns_zone_slave;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_stub:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return dns_zone_stub;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_hint:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return dns_zone_hint;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt INSIST(0);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (dns_zone_none); /*NOTREACHED*/
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt}
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntisc_result_t
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntdns_zone_configure(dns_c_ctx_t *cctx, dns_aclconfctx_t *ac,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_zone_t *czone, dns_zone_t *zone)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt{
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_result_t result;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_boolean_t boolean;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt const char *filename = NULL;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#ifdef notyet
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_severity_t severity;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#endif
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_iplist_t *iplist = NULL;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_uint32_t i;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_sockaddr_t sockaddr;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_int32_t maxxfr;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt in_port_t port;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt struct in_addr in4addr_any;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_sockaddr_t sockaddr_any4, sockaddr_any6;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt in4addr_any.s_addr = htonl(INADDR_ANY);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_sockaddr_fromin(&sockaddr_any4, &in4addr_any, 0);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_sockaddr_fromin6(&sockaddr_any6, &in6addr_any, 0);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setclass(zone, czone->zclass);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt /* XXX needs to be an zone option */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_zone_setdbtype(zone, "rbt");
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt switch (czone->ztype) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_master:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_settype(zone, dns_zone_master);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getfile(czone, &filename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_zone_setdatabase(zone, filename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#ifdef notyet
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getchecknames(czone, &severity);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setchecknames(zone, severity);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt else
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setchecknames(zone, dns_c_severity_fail);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#endif
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = configure_zone_acl(czone, cctx, ac, zone,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_zone_getallowupd,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setupdateacl,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearupdateacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = configure_zone_acl(czone, cctx, ac, zone,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_zone_getallowquery,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setqueryacl,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearqueryacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = configure_zone_acl(czone, cctx, ac, zone,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_zone_getallowtransfer,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setxfracl,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearxfracl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getdialup(czone, &boolean);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setoption(zone, DNS_ZONE_O_DIALUP, boolean);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt else
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearoption(zone, DNS_ZONE_O_DIALUP);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getnotify(czone, &boolean);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, boolean);
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt else
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt dns_zone_clearoption(zone, DNS_ZONE_O_NOTIFY);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getalsonotify(czone, &iplist);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS) {
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt for (i = 0; i < iplist->nextidx; i++) {
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt result = dns_zone_addnotify(zone,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt &iplist->ips[i]);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt } else
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearnotify(zone);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmaxtranstimeout(czone, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_getmaxtransfertimeout(cctx, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt maxxfr = MAX_XFER_TIME;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setmaxxfrout(zone, maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmaxtransidleout(czone, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_getmaxtransferidleout(cctx, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt maxxfr = DNS_DEFAULT_IDLEOUT;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setidleout(zone, maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt break;
1b255a0c4eaccf0feff70328a8c108a22abfbf3cEvan Hunt
1b255a0c4eaccf0feff70328a8c108a22abfbf3cEvan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_forward:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#ifdef notyet
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt /*
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * forward zones are still in a state of flux
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt czone->u.fzone.check_names; /* XXX unused in BIND 8 */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt czone->u.fzone.forward; /* XXX*/
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt czone->u.fzone.forwarders; /* XXX*/
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#endif
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt break;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_slave:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_settype(zone, dns_zone_slave);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getfile(czone, &filename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_zone_setdatabase(zone, filename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#ifdef notyet
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getchecknames(czone, &severity);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setchecknames(zone, severity);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt else
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setchecknames(zone, dns_c_severity_warn);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#endif
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = configure_zone_acl(czone, cctx, ac, zone,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_zone_getallowquery,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setqueryacl,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearqueryacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmasterport(czone, &port);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt port = 53;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setmasterport(zone, port);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmasterips(czone, &iplist);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt for (i = 0; i < iplist->nextidx; i++) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_zone_addmaster(zone,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt &iplist->ips[i]);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt } else
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearmasters(zone);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmaxtranstimein(czone, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_getmaxtransfertimein(cctx, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt maxxfr = MAX_XFER_TIME;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setmaxxfrin(zone, maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmaxtransidlein(czone, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_getmaxtransferidlein(cctx, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt maxxfr = DNS_DEFAULT_IDLEIN;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setidlein(zone, maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_gettransfersource(czone, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt sockaddr = sockaddr_any4;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt dns_zone_setxfrsource4(zone, &sockaddr);
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_gettransfersourcev6(czone, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_gettransfersourcev6(cctx, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt sockaddr = sockaddr_any6;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setxfrsource6(zone, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmaxtranstimeout(czone, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_getmaxtransfertimeout(cctx, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt maxxfr = MAX_XFER_TIME;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setmaxxfrout(zone, maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmaxtransidleout(czone, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_getmaxtransferidleout(cctx, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt maxxfr = DNS_DEFAULT_IDLEOUT;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setidleout(zone, maxxfr);
1b255a0c4eaccf0feff70328a8c108a22abfbf3cEvan Hunt
1b255a0c4eaccf0feff70328a8c108a22abfbf3cEvan Hunt break;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_stub:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_settype(zone, dns_zone_stub);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getfile(czone, &filename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_zone_setdatabase(zone, filename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#ifdef notyet
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getchecknames(czone, &severity);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setchecknames(zone, severity);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt else
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setchecknames(zone, dns_c_severity_warn);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#endif
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = configure_zone_acl(czone, cctx, ac, zone,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_c_zone_getallowquery,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setqueryacl,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearqueryacl);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmasterport(czone, &port);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt port = 53;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setmasterport(zone, port);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmasterips(czone, &iplist);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt for (i = 0; i < iplist->nextidx; i++) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_zone_addmaster(zone,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt &iplist->ips[i]);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt } else
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_clearmasters(zone);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmaxtranstimein(czone, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_getmaxtransfertimein(cctx, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt maxxfr = MAX_XFER_TIME;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setmaxxfrin(zone, maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getmaxtransidlein(czone, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_getmaxtransferidlein(cctx, &maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt maxxfr = DNS_DEFAULT_IDLEIN;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setidlein(zone, maxxfr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_gettransfersource(czone, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt sockaddr = sockaddr_any4;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setxfrsource4(zone, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_gettransfersourcev6(czone, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_gettransfersourcev6(cctx, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS) {
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt sockaddr = sockaddr_any6;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setxfrsource6(zone, &sockaddr);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt case dns_c_zone_hint:
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_settype(zone, dns_zone_hint);
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt result = dns_c_zone_getfile(czone, &filename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_zone_setdatabase(zone, filename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (result);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#ifdef notyet
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_zone_getchecknames(czone, &severity);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result == ISC_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setchecknames(zone, severity);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt else
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zone_setchecknames(zone, dns_c_severity_fail);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt#endif
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt break;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt }
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (DNS_R_SUCCESS);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt}
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntisc_boolean_t
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntdns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt{
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt const char *cfilename;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt const char *zfilename;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (dns_zonetype_fromconf(czone->ztype) != dns_zone_gettype(zone))
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (ISC_FALSE);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt cfilename = NULL;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt (void) dns_c_zone_getfile(czone, &cfilename);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt zfilename = dns_zone_getdatabase(zone);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (cfilename == NULL || zfilename == NULL ||
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt strcmp(cfilename, zfilename) != 0)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (ISC_FALSE);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt /* XXX Compare masters, too. */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (ISC_TRUE);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt}
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntisc_result_t
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntdns_zonemgr_configure(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt{
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt isc_int32_t val;
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt isc_result_t result;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = dns_c_ctx_gettransfersin(cctx, &val);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt if (result != DNS_R_SUCCESS)
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt val = 10;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt dns_zonemgr_settransfersin(zmgr, val);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt return (ISC_R_SUCCESS);
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt}
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt