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