zoneconf.c revision 92a31c0f86de860a540e24b1337a8c9bfad56876
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews/*
28d9fd53819cc163629c867466b20d8ebcae8842David Lawrence * Copyright (C) 1999, 2000 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * Permission to use, copy, modify, and distribute this software for any
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * purpose with or without fee is hereby granted, provided that the above
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * 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.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
ebfcb6cf66283096ebda1503b6cc042ce86b6bedBrian Wellington#include <config.h>
0c310d16b05ee94743d33f6920907edee6084fc8Michael Graff
0c310d16b05ee94743d33f6920907edee6084fc8Michael Graff#include <isc/string.h> /* Required for HP/UX (and others?) */
de153390f5a1f6d4fa86af91d4cae772d9846ca0Mark Andrews#include <isc/util.h>
0c310d16b05ee94743d33f6920907edee6084fc8Michael Graff
822f6cdabb1edd44472c7a758b5cae71376fa9beBrian Wellington#include <dns/acl.h>
ebfcb6cf66283096ebda1503b6cc042ce86b6bedBrian Wellington#include <dns/zone.h>
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews#include <dns/zoneconf.h>
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#include <dns/ssu.h>
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
973a19342597823f111fce6a8cd5adfd0e2e7c0dMark Andrews/*
0c310d16b05ee94743d33f6920907edee6084fc8Michael Graff * These are BIND9 server defaults, not necessarily identical to the
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * library defaults defined in zone.c.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#define MAX_XFER_TIME (2*3600) /* Documented default is 2 hours. */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#define DNS_DEFAULT_IDLEIN 3600 /* 1 hour */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#define DNS_DEFAULT_IDLEOUT 3600 /* 1 hour */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
a98551ef592e9be6008e0141ceeb32efd586c5efMark Andrews#define RETERR(x) do { \
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence isc_result_t _r = (x); \
a98551ef592e9be6008e0141ceeb32efd586c5efMark Andrews if (_r != ISC_R_SUCCESS) \
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence return (_r); \
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews } while (0)
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson/*
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Convenience function for configuring a single zone ACL.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews */
eb6bd543c7d072efdca509eb17f8f301c1467b53Mark Andrewsstatic isc_result_t
600cfa2ba4c50017581b6c14e3a688a82ecebbe0David Lawrenceconfigure_zone_acl(dns_c_zone_t *czone, dns_c_ctx_t *cctx, dns_c_view_t *cview,
600cfa2ba4c50017581b6c14e3a688a82ecebbe0David Lawrence dns_aclconfctx_t *aclconfctx, dns_zone_t *zone,
600cfa2ba4c50017581b6c14e3a688a82ecebbe0David Lawrence isc_result_t (*getcacl)(dns_c_zone_t *,
eb6bd543c7d072efdca509eb17f8f301c1467b53Mark Andrews dns_c_ipmatchlist_t **),
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews isc_result_t (*getviewcacl)(dns_c_view_t *
0b056755b2f423ba5f6adac8f7851d78f7d11437David Lawrence , dns_c_ipmatchlist_t **),
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence isc_result_t (*getglobalcacl)(dns_c_ctx_t *,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_c_ipmatchlist_t **),
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence void (*setzacl)(dns_zone_t *, dns_acl_t *),
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence void (*clearzacl)(dns_zone_t *))
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence{
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence isc_result_t result;
0b056755b2f423ba5f6adac8f7851d78f7d11437David Lawrence dns_c_ipmatchlist_t *cacl;
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_acl_t *dacl = NULL;
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence result = (*getcacl)(czone, &cacl);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence if (result == ISC_R_NOTFOUND && getviewcacl != NULL && cview != NULL) {
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence result = (*getviewcacl)(cview, &cacl);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence }
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence if (result == ISC_R_NOTFOUND && getglobalcacl != NULL) {
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence result = (*getglobalcacl)(cctx, &cacl);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence }
0b056755b2f423ba5f6adac8f7851d78f7d11437David Lawrence if (result == ISC_R_SUCCESS) {
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence result = dns_acl_fromconfig(cacl, cctx, aclconfctx,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_zone_getmctx(zone), &dacl);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_c_ipmatchlist_detach(&cacl);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence if (result != ISC_R_SUCCESS)
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence return (result);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence (*setzacl)(zone, dacl);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_acl_detach(&dacl);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence return (ISC_R_SUCCESS);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence } else if (result == ISC_R_NOTFOUND) {
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence (*clearzacl)(zone);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence return (ISC_R_SUCCESS);
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson } else {
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence return (result);
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson }
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson}
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson/*
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson * Conver a config file zone type into a server zone type.
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson */
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafssonstatic dns_zonetype_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencedns_zonetype_fromconf(dns_c_zonetype_t cztype) {
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson switch (cztype) {
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson case dns_c_zone_master:
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence return dns_zone_master;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence case dns_c_zone_slave:
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence return dns_zone_slave;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence case dns_c_zone_stub:
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence return dns_zone_stub;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence default:
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence /*
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Hint and forward zones are not really zones;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * they should never get this far.
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence */
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence INSIST(0);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence return (dns_zone_none); /*NOTREACHED*/
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence }
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence}
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrenceisc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencedns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_c_zone_t *czone, dns_aclconfctx_t *ac,
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_zone_t *zone)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence{
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence isc_result_t result;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence isc_boolean_t boolean;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence const char *filename = NULL;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence#ifdef notyet
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_c_severity_t severity;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence#endif
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_c_iplist_t *iplist;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence isc_sockaddr_t sockaddr;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence isc_int32_t maxxfr;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence isc_sockaddr_t sockaddr_any4, sockaddr_any6;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_ssutable_t *ssutable = NULL;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence isc_sockaddr_any(&sockaddr_any4);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence isc_sockaddr_any6(&sockaddr_any6);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence /*
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Configure values common to all zone types.
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence */
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_zone_setclass(zone, czone->zclass);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_zone_settype(zone, dns_zonetype_fromconf(czone->ztype));
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence /* XXX needs to be an zone option */
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence RETERR(dns_zone_setdbtype(zone, "rbt"));
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence RETERR(dns_c_zone_getfile(czone, &filename));
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence RETERR(dns_zone_setdatabase(zone, filename));
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence#ifdef notyet
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence result = dns_c_zone_getchecknames(czone, &severity);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence if (result == ISC_R_SUCCESS)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_zone_setchecknames(zone, severity);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence else
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_zone_setchecknames(zone, dns_c_severity_warn);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence#endif
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence /*
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * XXXAG This probably does not make sense for stubs.
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence */
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_c_zone_getallowquery,
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_c_view_getallowquery,
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_c_ctx_getallowquery,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_zone_setqueryacl,
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence dns_zone_clearqueryacl));
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence result = dns_c_zone_getdialup(czone, &boolean);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence if (result != ISC_R_SUCCESS)
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence result = dns_c_ctx_getdialup(cctx, &boolean);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence if (result != ISC_R_SUCCESS)
fd4810861c0c0ccb9aebde94e9d289442b2630dbMark Andrews boolean = ISC_FALSE;
fd4810861c0c0ccb9aebde94e9d289442b2630dbMark Andrews dns_zone_setoption(zone, DNS_ZONE_O_DIALUP, boolean);
fd4810861c0c0ccb9aebde94e9d289442b2630dbMark Andrews
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence /*
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Configure master functionality. This applies
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * to primary masters (type "master") and slaves
7ab0e69f61e61e81d489c95c7ebd981e74e7ef16Andreas Gustafsson * acting as masters (type "slave"), but not to stubs.
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews */
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews if (czone->ztype != dns_c_zone_stub) {
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews result = dns_c_zone_getnotify(czone, &boolean);
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews if (result != ISC_R_SUCCESS && cview != NULL)
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews result = dns_c_view_getnotify(cview, &boolean);
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews if (result != ISC_R_SUCCESS)
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews result = dns_c_ctx_getnotify(cctx, &boolean);
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews if (result != ISC_R_SUCCESS)
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews boolean = ISC_TRUE;
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, boolean);
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews iplist = NULL;
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews result = dns_c_zone_getalsonotify(czone, &iplist);
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews if (result != ISC_R_SUCCESS && cview != NULL)
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews result = dns_c_view_getalsonotify(cview, &iplist);
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews if (result != ISC_R_SUCCESS)
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews result = dns_c_ctx_getalsonotify(cctx, &iplist);
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews if (result == ISC_R_SUCCESS)
f6407f9a0b890bebbfd5f738d9c4aef3d3315fe9Michael Graff RETERR(dns_zone_setalsonotify(zone, iplist->ips,
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews iplist->nextidx));
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews else
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrews RETERR(dns_zone_setalsonotify(zone, NULL, 0));
ffe74cc719aa0f10c38fbc1f2f3ea7db0960cb8fMark Andrews
ffe74cc719aa0f10c38fbc1f2f3ea7db0960cb8fMark Andrews RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_c_zone_getallowtransfer,
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_c_view_gettransferacl,
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_c_ctx_getallowtransfer,
bed8e84810a80dad3d37870be927d1dfd015f480Mark Andrews dns_zone_setxfracl,
bed8e84810a80dad3d37870be927d1dfd015f480Mark Andrews dns_zone_clearxfracl));
bed8e84810a80dad3d37870be927d1dfd015f480Mark Andrews
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews result = dns_c_zone_getmaxtranstimeout(czone, &maxxfr);
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews if (result != ISC_R_SUCCESS && cview != NULL)
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews result = dns_c_view_getmaxtransfertimeout(cview,
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews &maxxfr);
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews if (result != ISC_R_SUCCESS)
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews result = dns_c_ctx_getmaxtransfertimeout(cctx,
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews &maxxfr);
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews if (result != ISC_R_SUCCESS)
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews maxxfr = MAX_XFER_TIME;
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews dns_zone_setmaxxfrout(zone, maxxfr);
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews result = dns_c_zone_getmaxtransidleout(czone, &maxxfr);
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington if (result != ISC_R_SUCCESS && cview != NULL)
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington result = dns_c_view_getmaxtransferidleout(cview,
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington &maxxfr);
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews if (result != ISC_R_SUCCESS)
613991eef6bb79b9703382aff26cddd0281da915Bob Halley result = dns_c_ctx_getmaxtransferidleout(cctx,
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews &maxxfr);
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews if (result != ISC_R_SUCCESS)
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington maxxfr = DNS_DEFAULT_IDLEOUT;
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington dns_zone_setidleout(zone, maxxfr);
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington }
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington /*
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington * Configure update-related options. These apply to
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington * primary masters only.
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington */
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington if (czone->ztype == dns_c_zone_master) {
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington RETERR(configure_zone_acl(czone, cctx, NULL, ac, zone,
87ecd67dae468cf5c9bae213c6fa321449b2ebc2Andreas Gustafsson dns_c_zone_getallowupd,
87ecd67dae468cf5c9bae213c6fa321449b2ebc2Andreas Gustafsson NULL, NULL,
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews dns_zone_setupdateacl,
87ecd67dae468cf5c9bae213c6fa321449b2ebc2Andreas Gustafsson dns_zone_clearupdateacl));
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews dns_zone_getssutable(zone, &ssutable);
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews if (ssutable != NULL)
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews dns_ssutable_detach(&ssutable);
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews result = dns_c_zone_getssuauth(czone, &ssutable);
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews if (result == ISC_R_SUCCESS) {
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson dns_ssutable_t *newssutable = NULL;
bcd7fdf06ca76eb2f6eb157f56b612c503e062a7Mark Andrews dns_ssutable_attach(ssutable, &newssutable);
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews dns_zone_setssutable(zone, newssutable);
bcd7fdf06ca76eb2f6eb157f56b612c503e062a7Mark Andrews }
bcd7fdf06ca76eb2f6eb157f56b612c503e062a7Mark Andrews }
bcd7fdf06ca76eb2f6eb157f56b612c503e062a7Mark Andrews
bcd7fdf06ca76eb2f6eb157f56b612c503e062a7Mark Andrews /*
bcd7fdf06ca76eb2f6eb157f56b612c503e062a7Mark Andrews * Configure slave functionality.
bcd7fdf06ca76eb2f6eb157f56b612c503e062a7Mark Andrews */
bcd7fdf06ca76eb2f6eb157f56b612c503e062a7Mark Andrews switch (czone->ztype) {
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews case dns_c_zone_slave:
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews case dns_c_zone_stub:
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson iplist = NULL;
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_c_zone_getmasterips(czone, &iplist);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson if (result == ISC_R_SUCCESS)
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_zone_setmasters(zone, iplist->ips,
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson iplist->nextidx);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson else
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_zone_setmasters(zone, NULL, 0);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson RETERR(result);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_c_zone_getmaxtranstimein(czone, &maxxfr);
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews if (result != ISC_R_SUCCESS)
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff result = dns_c_ctx_getmaxtransfertimein(cctx, &maxxfr);
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews if (result != ISC_R_SUCCESS)
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence maxxfr = MAX_XFER_TIME;
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_zone_setmaxxfrin(zone, maxxfr);
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff result = dns_c_zone_getmaxtransidlein(czone, &maxxfr);
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington if (result != ISC_R_SUCCESS)
5d83b561ad7eb84885a8ec63dee4c51b335f067aBrian Wellington result = dns_c_ctx_getmaxtransferidlein(cctx, &maxxfr);
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff if (result != ISC_R_SUCCESS)
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff maxxfr = DNS_DEFAULT_IDLEIN;
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff dns_zone_setidlein(zone, maxxfr);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_c_zone_gettransfersource(czone, &sockaddr);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence if (result != ISC_R_SUCCESS && cview != NULL)
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_c_view_gettransfersource(cview,
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson &sockaddr);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson if (result != ISC_R_SUCCESS)
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson if (result != ISC_R_SUCCESS)
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson sockaddr = sockaddr_any4;
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson dns_zone_setxfrsource4(zone, &sockaddr);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_c_zone_gettransfersourcev6(czone, &sockaddr);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson if (result != ISC_R_SUCCESS && cview != NULL)
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_c_view_gettransfersourcev6(cview,
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson &sockaddr);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson if (result != ISC_R_SUCCESS)
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson result = dns_c_ctx_gettransfersourcev6(cctx,
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson &sockaddr);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson if (result != ISC_R_SUCCESS)
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson sockaddr = sockaddr_any6;
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson dns_zone_setxfrsource6(zone, &sockaddr);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson break;
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson default:
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson break;
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson }
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson return (ISC_R_SUCCESS);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson}
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafssonisc_boolean_t
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafssondns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone) {
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson const char *cfilename;
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson const char *zfilename;
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson if (dns_zonetype_fromconf(czone->ztype) != dns_zone_gettype(zone))
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence return (ISC_FALSE);
3ddd92da6651bc72aa79a04195ad389d86fd1a66Andreas Gustafsson
8d3e74b1683f714a484bbcf73249e8ee470e36d7Mark Andrews cfilename = NULL;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews (void) dns_c_zone_getfile(czone, &cfilename);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews zfilename = dns_zone_getdatabase(zone);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews if (cfilename == NULL || zfilename == NULL ||
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews strcmp(cfilename, zfilename) != 0)
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews return (ISC_FALSE);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews /* XXX Compare masters, too. */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews return (ISC_TRUE);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
d981ca645597116d227a48bf37cc5edc061c854dBob Halleyisc_result_t
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewsdns_zonemgr_configure(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr) {
e6bd97dded968f82e26b270842b789bff7bca422Mark Andrews isc_int32_t val;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_result_t result;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews result = dns_c_ctx_gettransfersin(cctx, &val);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews if (result != ISC_R_SUCCESS)
f1cae4bcb7ee3060d893f5ab3ba55c1820bf3e4aBrian Wellington val = 10;
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews dns_zonemgr_settransfersin(zmgr, val);
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews result = dns_c_ctx_gettransfersperns(cctx, &val);
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews if (result != ISC_R_SUCCESS)
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews val = 2;
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews dns_zonemgr_settransfersperns(zmgr, val);
389c749a5ee18f1c0d6278ae49f2aae5d5f0d2dcMark Andrews
368b37b616234fce3d23099eb180f1dd38e1fb62Mark Andrews return (ISC_R_SUCCESS);
389c749a5ee18f1c0d6278ae49f2aae5d5f0d2dcMark Andrews}
389c749a5ee18f1c0d6278ae49f2aae5d5f0d2dcMark Andrews
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews