1999-12-16 23:11:07 +00:00
|
|
|
/*
|
2000-02-03 23:50:32 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
1999-12-16 23:11:07 +00:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2000-07-27 09:55:03 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
|
|
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
|
|
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
1999-12-16 23:11:07 +00:00
|
|
|
*/
|
|
|
|
|
2000-11-18 02:54:22 +00:00
|
|
|
/* $Id: zoneconf.c,v 1.71 2000/11/18 02:54:22 gson Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2000-08-10 00:53:36 +00:00
|
|
|
#include <isc/mem.h>
|
2000-05-08 19:23:32 +00:00
|
|
|
#include <isc/string.h> /* Required for HP/UX (and others?) */
|
2000-04-28 01:12:23 +00:00
|
|
|
#include <isc/util.h>
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/acl.h>
|
2000-08-29 03:48:00 +00:00
|
|
|
#include <dns/ssu.h>
|
1999-12-16 23:11:07 +00:00
|
|
|
#include <dns/zone.h>
|
|
|
|
#include <dns/zoneconf.h>
|
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* These are BIND9 server defaults, not necessarily identical to the
|
|
|
|
* library defaults defined in zone.c.
|
|
|
|
*/
|
1999-12-16 23:11:07 +00:00
|
|
|
#define MAX_XFER_TIME (2*3600) /* Documented default is 2 hours. */
|
2000-01-31 19:53:14 +00:00
|
|
|
#define DNS_DEFAULT_IDLEIN 3600 /* 1 hour */
|
|
|
|
#define DNS_DEFAULT_IDLEOUT 3600 /* 1 hour */
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
#define RETERR(x) do { \
|
|
|
|
isc_result_t _r = (x); \
|
|
|
|
if (_r != ISC_R_SUCCESS) \
|
|
|
|
return (_r); \
|
|
|
|
} while (0)
|
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
/*
|
|
|
|
* Convenience function for configuring a single zone ACL.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2000-04-06 23:59:19 +00:00
|
|
|
configure_zone_acl(dns_c_zone_t *czone, dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
1999-12-16 23:11:07 +00:00
|
|
|
dns_aclconfctx_t *aclconfctx, dns_zone_t *zone,
|
2000-05-08 14:38:29 +00:00
|
|
|
isc_result_t (*getcacl)(dns_c_zone_t *,
|
|
|
|
dns_c_ipmatchlist_t **),
|
|
|
|
isc_result_t (*getviewcacl)(dns_c_view_t *
|
|
|
|
, dns_c_ipmatchlist_t **),
|
|
|
|
isc_result_t (*getglobalcacl)(dns_c_ctx_t *,
|
|
|
|
dns_c_ipmatchlist_t **),
|
1999-12-16 23:11:07 +00:00
|
|
|
void (*setzacl)(dns_zone_t *, dns_acl_t *),
|
|
|
|
void (*clearzacl)(dns_zone_t *))
|
|
|
|
{
|
|
|
|
isc_result_t result;
|
|
|
|
dns_c_ipmatchlist_t *cacl;
|
|
|
|
dns_acl_t *dacl = NULL;
|
|
|
|
result = (*getcacl)(czone, &cacl);
|
2000-04-07 00:51:32 +00:00
|
|
|
if (result == ISC_R_NOTFOUND && getviewcacl != NULL && cview != NULL) {
|
2000-04-06 23:59:19 +00:00
|
|
|
result = (*getviewcacl)(cview, &cacl);
|
|
|
|
}
|
|
|
|
if (result == ISC_R_NOTFOUND && getglobalcacl != NULL) {
|
|
|
|
result = (*getglobalcacl)(cctx, &cacl);
|
2000-02-22 21:24:24 +00:00
|
|
|
}
|
1999-12-16 23:11:07 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
result = dns_acl_fromconfig(cacl, cctx, aclconfctx,
|
|
|
|
dns_zone_getmctx(zone), &dacl);
|
|
|
|
dns_c_ipmatchlist_detach(&cacl);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-12-16 23:11:07 +00:00
|
|
|
return (result);
|
|
|
|
(*setzacl)(zone, dacl);
|
|
|
|
dns_acl_detach(&dacl);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
} else if (result == ISC_R_NOTFOUND) {
|
|
|
|
(*clearzacl)(zone);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
} else {
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Conver a config file zone type into a server zone type.
|
|
|
|
*/
|
2000-01-21 19:22:35 +00:00
|
|
|
static dns_zonetype_t
|
|
|
|
dns_zonetype_fromconf(dns_c_zonetype_t cztype) {
|
|
|
|
switch (cztype) {
|
|
|
|
case dns_c_zone_master:
|
|
|
|
return dns_zone_master;
|
|
|
|
case dns_c_zone_slave:
|
|
|
|
return dns_zone_slave;
|
|
|
|
case dns_c_zone_stub:
|
|
|
|
return dns_zone_stub;
|
2000-05-25 19:27:48 +00:00
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* Hint and forward zones are not really zones;
|
|
|
|
* they should never get this far.
|
|
|
|
*/
|
|
|
|
INSIST(0);
|
|
|
|
return (dns_zone_none); /*NOTREACHED*/
|
2000-01-21 19:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-10 00:53:36 +00:00
|
|
|
/*
|
|
|
|
* Helper function for strtoargv(). Pardon the gratuitous recursion.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2000-08-14 03:50:59 +00:00
|
|
|
strtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp,
|
|
|
|
char ***argvp, unsigned int n)
|
|
|
|
{
|
2000-08-10 00:53:36 +00:00
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
/* Discard leading whitespace. */
|
|
|
|
while (*s == ' ' || *s == '\t')
|
|
|
|
s++;
|
|
|
|
|
|
|
|
if (*s == '\0') {
|
|
|
|
/* We have reached the end of the string. */
|
|
|
|
*argcp = n;
|
|
|
|
*argvp = isc_mem_get(mctx, n * sizeof(char *));
|
|
|
|
if (*argvp == NULL)
|
|
|
|
return (ISC_R_NOMEMORY);
|
|
|
|
} else {
|
|
|
|
char *p = s;
|
|
|
|
while (*p != ' ' && *p != '\t' && *p != '\0')
|
|
|
|
p++;
|
|
|
|
if (*p != '\0')
|
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
result = strtoargvsub(mctx, p, argcp, argvp, n + 1);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
(*argvp)[n] = s;
|
|
|
|
}
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tokenize the string "s" into whitespace-separated words,
|
|
|
|
* return the number of words in '*argcp' and an array
|
|
|
|
* of pointers to the words in '*argvp'. The caller
|
|
|
|
* must free the array using isc_mem_put(). The string
|
|
|
|
* is modified in-place.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2000-08-14 03:50:59 +00:00
|
|
|
strtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp) {
|
2000-08-10 00:53:36 +00:00
|
|
|
return (strtoargvsub(mctx, s, argcp, argvp, 0));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
2000-07-31 19:36:48 +00:00
|
|
|
dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
|
|
|
dns_c_zone_t *czone, dns_aclconfctx_t *ac,
|
2000-04-06 23:59:19 +00:00
|
|
|
dns_zone_t *zone)
|
1999-12-16 23:11:07 +00:00
|
|
|
{
|
|
|
|
isc_result_t result;
|
|
|
|
const char *filename = NULL;
|
2000-07-24 22:59:44 +00:00
|
|
|
dns_notifytype_t notifytype;
|
2000-01-27 19:44:49 +00:00
|
|
|
#ifdef notyet
|
1999-12-16 23:11:07 +00:00
|
|
|
dns_c_severity_t severity;
|
2000-01-27 19:44:49 +00:00
|
|
|
#endif
|
2000-06-01 00:41:23 +00:00
|
|
|
dns_c_iplist_t *iplist;
|
1999-12-16 23:11:07 +00:00
|
|
|
isc_sockaddr_t sockaddr;
|
2000-06-02 17:31:43 +00:00
|
|
|
isc_uint32_t uintval;
|
2000-02-09 19:04:26 +00:00
|
|
|
isc_sockaddr_t sockaddr_any4, sockaddr_any6;
|
2000-05-25 19:27:48 +00:00
|
|
|
dns_ssutable_t *ssutable = NULL;
|
2000-08-10 00:53:36 +00:00
|
|
|
char *cpval;
|
|
|
|
unsigned int dbargc;
|
|
|
|
char **dbargv;
|
|
|
|
static char default_dbtype[] = "rbt";
|
|
|
|
isc_mem_t *mctx = dns_zone_getmctx(zone);
|
2000-11-03 07:16:09 +00:00
|
|
|
dns_dialuptype_t dialup;
|
2000-11-07 23:49:42 +00:00
|
|
|
isc_boolean_t statistics;
|
2000-01-31 15:09:09 +00:00
|
|
|
|
2000-07-31 19:36:48 +00:00
|
|
|
isc_sockaddr_any(&sockaddr_any4);
|
2000-05-25 05:13:19 +00:00
|
|
|
isc_sockaddr_any6(&sockaddr_any6);
|
2000-07-31 19:36:48 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Configure values common to all zone types.
|
|
|
|
*/
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
dns_zone_setclass(zone, czone->zclass);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
dns_zone_settype(zone, dns_zonetype_fromconf(czone->ztype));
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-08-10 00:53:36 +00:00
|
|
|
cpval = NULL;
|
|
|
|
result = dns_c_zone_getdatabase(czone, &cpval);
|
|
|
|
#ifdef notyet
|
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
|
|
|
result = dns_c_view_getdatabase(cview, &cpval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getdatabase(cview, &cpval);
|
|
|
|
#endif
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
cpval = default_dbtype;
|
|
|
|
RETERR(strtoargv(mctx, cpval, &dbargc, &dbargv));
|
2000-08-22 05:14:59 +00:00
|
|
|
/*
|
|
|
|
* ANSI C is strange here. There is no logical reason why (char **)
|
|
|
|
* cannot be promoted automatically to (const char * const *) by the
|
|
|
|
* compiler w/o generating a warning.
|
|
|
|
*/
|
|
|
|
RETERR(dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv));
|
2000-08-10 00:53:36 +00:00
|
|
|
isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-06-05 03:44:17 +00:00
|
|
|
result = dns_c_zone_getfile(czone, &filename);
|
2000-11-18 02:54:22 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
filename = NULL;
|
|
|
|
RETERR(dns_zone_setfile(zone, filename));
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-04-21 00:18:23 +00:00
|
|
|
#ifdef notyet
|
2000-05-25 19:27:48 +00:00
|
|
|
result = dns_c_zone_getchecknames(czone, &severity);
|
|
|
|
if (result == ISC_R_SUCCESS)
|
|
|
|
dns_zone_setchecknames(zone, severity);
|
|
|
|
else
|
|
|
|
dns_zone_setchecknames(zone, dns_c_severity_warn);
|
2000-04-21 00:18:23 +00:00
|
|
|
#endif
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-08-22 05:14:59 +00:00
|
|
|
#ifndef NOMINUM_PUBLIC
|
|
|
|
if (czone->ztype == dns_c_zone_slave)
|
|
|
|
RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
|
|
|
|
dns_c_zone_getallownotify,
|
|
|
|
dns_c_view_getallownotify,
|
|
|
|
dns_c_ctx_getallownotify,
|
|
|
|
dns_zone_setnotifyacl,
|
|
|
|
dns_zone_clearnotifyacl));
|
|
|
|
#endif /* NOMINUM_PUBLIC */
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* XXXAG This probably does not make sense for stubs.
|
|
|
|
*/
|
|
|
|
RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
|
|
|
|
dns_c_zone_getallowquery,
|
|
|
|
dns_c_view_getallowquery,
|
|
|
|
dns_c_ctx_getallowquery,
|
|
|
|
dns_zone_setqueryacl,
|
|
|
|
dns_zone_clearqueryacl));
|
|
|
|
|
2000-11-11 01:05:43 +00:00
|
|
|
result = dns_c_zone_getdialup(czone, &dialup);
|
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
|
|
|
result = dns_c_view_getdialup(cview, &dialup);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getdialup(cctx, &dialup);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
dialup = dns_dialuptype_no;
|
|
|
|
dns_zone_setdialup(zone, dialup);
|
2000-05-25 19:27:48 +00:00
|
|
|
|
2000-11-11 01:05:43 +00:00
|
|
|
result = dns_c_zone_getstatistics(czone, &statistics);
|
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
|
|
|
result = dns_c_view_getstatistics(cview, &statistics);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getstatistics(cctx, &statistics);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
statistics = ISC_FALSE;
|
|
|
|
if (statistics)
|
|
|
|
dns_zone_startcounting(zone);
|
|
|
|
else
|
|
|
|
dns_zone_stopcounting(zone);
|
2000-11-07 23:49:42 +00:00
|
|
|
|
2000-08-08 23:14:29 +00:00
|
|
|
#ifndef NOMINUM_PUBLIC
|
2000-08-14 21:47:42 +00:00
|
|
|
if (czone->ztype != dns_c_zone_stub) {
|
|
|
|
result = dns_c_zone_getmaxnames(czone, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
|
|
|
result = dns_c_view_getmaxnames(cview, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getmaxnames(cctx, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
uintval = 0;
|
|
|
|
dns_zone_setmaxnames(zone, uintval);
|
|
|
|
}
|
2000-08-17 13:13:37 +00:00
|
|
|
|
2000-08-22 05:14:59 +00:00
|
|
|
if (czone->ztype == dns_c_zone_slave) {
|
2000-11-16 19:32:13 +00:00
|
|
|
isc_boolean_t boolean;
|
|
|
|
|
2000-08-22 05:14:59 +00:00
|
|
|
result = dns_c_zone_getnotifyforward(czone, &boolean);
|
2000-08-17 13:13:37 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
2000-08-22 05:14:59 +00:00
|
|
|
result = dns_c_view_getnotifyforward(cview, &boolean);
|
2000-08-17 13:13:37 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-08-22 05:14:59 +00:00
|
|
|
result = dns_c_ctx_getnotifyforward(cctx, &boolean);
|
2000-08-17 13:13:37 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
boolean = ISC_FALSE;
|
2000-08-22 05:14:59 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_NOTIFYFORWARD, boolean);
|
2000-08-17 13:13:37 +00:00
|
|
|
}
|
2000-08-08 23:14:29 +00:00
|
|
|
#endif /* NOMINUM_PUBLIC */
|
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Configure master functionality. This applies
|
|
|
|
* to primary masters (type "master") and slaves
|
|
|
|
* acting as masters (type "slave"), but not to stubs.
|
|
|
|
*/
|
|
|
|
if (czone->ztype != dns_c_zone_stub) {
|
2000-07-24 22:59:44 +00:00
|
|
|
result = dns_c_zone_getnotify(czone, ¬ifytype);
|
2000-04-21 00:18:23 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
2000-07-24 22:59:44 +00:00
|
|
|
result = dns_c_view_getnotify(cview, ¬ifytype);
|
2000-04-21 00:18:23 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-07-24 22:59:44 +00:00
|
|
|
result = dns_c_ctx_getnotify(cctx, ¬ifytype);
|
2000-04-21 00:18:23 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-07-24 22:59:44 +00:00
|
|
|
notifytype = dns_notifytype_yes;
|
|
|
|
dns_zone_setnotifytype(zone, notifytype);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-06-01 00:41:23 +00:00
|
|
|
iplist = NULL;
|
1999-12-16 23:11:07 +00:00
|
|
|
result = dns_c_zone_getalsonotify(czone, &iplist);
|
2000-06-01 00:41:23 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
|
|
|
result = dns_c_view_getalsonotify(cview, &iplist);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getalsonotify(cctx, &iplist);
|
2000-07-25 20:26:11 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
result = dns_zone_setalsonotify(zone, iplist->ips,
|
|
|
|
iplist->nextidx);
|
|
|
|
dns_c_iplist_detach(&iplist);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
|
|
|
|
} else
|
2000-05-25 19:27:48 +00:00
|
|
|
RETERR(dns_zone_setalsonotify(zone, NULL, 0));
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
|
|
|
|
dns_c_zone_getallowtransfer,
|
|
|
|
dns_c_view_gettransferacl,
|
|
|
|
dns_c_ctx_getallowtransfer,
|
|
|
|
dns_zone_setxfracl,
|
|
|
|
dns_zone_clearxfracl));
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-06-05 09:17:14 +00:00
|
|
|
result = dns_c_zone_getmaxtranstimeout(czone, &uintval);
|
2000-04-07 18:16:02 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
2000-05-08 14:38:29 +00:00
|
|
|
result = dns_c_view_getmaxtransfertimeout(cview,
|
2000-06-05 09:17:14 +00:00
|
|
|
&uintval);
|
2000-04-07 18:16:02 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-05-08 14:38:29 +00:00
|
|
|
result = dns_c_ctx_getmaxtransfertimeout(cctx,
|
2000-06-05 09:17:14 +00:00
|
|
|
&uintval);
|
2000-04-07 18:16:02 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-06-05 09:17:14 +00:00
|
|
|
uintval = MAX_XFER_TIME;
|
|
|
|
dns_zone_setmaxxfrout(zone, uintval);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-06-05 09:17:14 +00:00
|
|
|
result = dns_c_zone_getmaxtransidleout(czone, &uintval);
|
2000-08-01 01:33:37 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
2000-05-08 14:38:29 +00:00
|
|
|
result = dns_c_view_getmaxtransferidleout(cview,
|
2000-06-05 09:17:14 +00:00
|
|
|
&uintval);
|
2000-08-01 01:33:37 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-05-08 14:38:29 +00:00
|
|
|
result = dns_c_ctx_getmaxtransferidleout(cctx,
|
2000-06-05 09:17:14 +00:00
|
|
|
&uintval);
|
2000-04-07 18:16:02 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-06-05 09:17:14 +00:00
|
|
|
uintval = DNS_DEFAULT_IDLEOUT;
|
|
|
|
dns_zone_setidleout(zone, uintval);
|
2000-05-25 19:27:48 +00:00
|
|
|
}
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Configure update-related options. These apply to
|
|
|
|
* primary masters only.
|
|
|
|
*/
|
|
|
|
if (czone->ztype == dns_c_zone_master) {
|
|
|
|
RETERR(configure_zone_acl(czone, cctx, NULL, ac, zone,
|
|
|
|
dns_c_zone_getallowupd,
|
|
|
|
NULL, NULL,
|
|
|
|
dns_zone_setupdateacl,
|
|
|
|
dns_zone_clearupdateacl));
|
|
|
|
|
2000-03-06 19:06:07 +00:00
|
|
|
result = dns_c_zone_getssuauth(czone, &ssutable);
|
2000-10-13 23:21:17 +00:00
|
|
|
if (result == ISC_R_SUCCESS)
|
|
|
|
dns_zone_setssutable(zone, ssutable);
|
2000-06-02 17:31:43 +00:00
|
|
|
|
|
|
|
result = dns_c_zone_getsigvalidityinterval(czone, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
|
|
|
result = dns_c_view_getsigvalidityinterval(cview,
|
|
|
|
&uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getsigvalidityinterval(cctx,
|
|
|
|
&uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
uintval = 30 * 24 * 3600;
|
|
|
|
dns_zone_setsigvalidityinterval(zone, uintval);
|
2000-11-06 08:11:11 +00:00
|
|
|
} else if (czone->ztype == dns_c_zone_slave) {
|
|
|
|
RETERR(configure_zone_acl(czone, cctx, NULL, ac, zone,
|
|
|
|
dns_c_zone_getallowupdateforwarding,
|
|
|
|
dns_c_view_getallowupdateforwarding,
|
|
|
|
dns_c_ctx_getallowupdateforwarding,
|
|
|
|
dns_zone_setforwardacl,
|
|
|
|
dns_zone_clearforwardacl));
|
2000-05-25 19:27:48 +00:00
|
|
|
}
|
2000-03-06 19:06:07 +00:00
|
|
|
|
2000-10-31 05:34:18 +00:00
|
|
|
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
|
|
|
result = dns_c_view_gettransfersource(cview, &sockaddr);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
sockaddr = sockaddr_any4;
|
|
|
|
dns_zone_setxfrsource4(zone, &sockaddr);
|
|
|
|
|
|
|
|
result = dns_c_zone_gettransfersourcev6(czone, &sockaddr);
|
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
|
|
|
result = dns_c_view_gettransfersourcev6(cview, &sockaddr);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_gettransfersourcev6(cctx, &sockaddr);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
sockaddr = sockaddr_any6;
|
|
|
|
dns_zone_setxfrsource6(zone, &sockaddr);
|
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Configure slave functionality.
|
|
|
|
*/
|
|
|
|
switch (czone->ztype) {
|
1999-12-16 23:11:07 +00:00
|
|
|
case dns_c_zone_slave:
|
|
|
|
case dns_c_zone_stub:
|
2000-06-01 00:41:23 +00:00
|
|
|
iplist = NULL;
|
1999-12-16 23:11:07 +00:00
|
|
|
result = dns_c_zone_getmasterips(czone, &iplist);
|
2000-04-28 00:58:42 +00:00
|
|
|
if (result == ISC_R_SUCCESS)
|
2000-07-26 18:47:43 +00:00
|
|
|
#ifndef NOMINUM_PUBLIC
|
2000-07-21 18:47:23 +00:00
|
|
|
result = dns_zone_setmasterswithkeys(zone,
|
|
|
|
iplist->ips,
|
|
|
|
iplist->keys,
|
|
|
|
iplist->nextidx);
|
2000-07-26 18:47:43 +00:00
|
|
|
#else /* NOMINUM_PUBLIC */
|
|
|
|
result = dns_zone_setmasters(zone, iplist->ips,
|
|
|
|
iplist->nextidx);
|
2000-08-01 01:33:37 +00:00
|
|
|
#endif /* NOMINUM_PUBLIC */
|
2000-04-28 00:58:42 +00:00
|
|
|
else
|
|
|
|
result = dns_zone_setmasters(zone, NULL, 0);
|
2000-05-25 19:27:48 +00:00
|
|
|
RETERR(result);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-06-05 09:17:14 +00:00
|
|
|
result = dns_c_zone_getmaxtranstimein(czone, &uintval);
|
2000-08-01 01:33:37 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-07-21 18:47:23 +00:00
|
|
|
result = dns_c_ctx_getmaxtransfertimein(cctx,
|
|
|
|
&uintval);
|
2000-04-07 18:16:02 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-06-05 09:17:14 +00:00
|
|
|
uintval = MAX_XFER_TIME;
|
|
|
|
dns_zone_setmaxxfrin(zone, uintval);
|
2000-01-31 19:53:14 +00:00
|
|
|
|
2000-06-05 09:17:14 +00:00
|
|
|
result = dns_c_zone_getmaxtransidlein(czone, &uintval);
|
2000-08-01 01:33:37 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-06-05 09:17:14 +00:00
|
|
|
result = dns_c_ctx_getmaxtransferidlein(cctx,
|
|
|
|
&uintval);
|
2000-04-07 18:16:02 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-06-05 09:17:14 +00:00
|
|
|
uintval = DNS_DEFAULT_IDLEIN;
|
|
|
|
dns_zone_setidlein(zone, uintval);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-08-02 22:29:16 +00:00
|
|
|
result = dns_c_zone_getmaxrefreshtime(czone, &uintval);
|
2000-08-03 00:41:26 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
2000-08-02 22:29:16 +00:00
|
|
|
result = dns_c_view_getmaxrefreshtime(cview, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getmaxrefreshtime(cctx, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
uintval = DNS_ZONE_MAXREFRESH;
|
|
|
|
dns_zone_setmaxrefreshtime(zone, uintval);
|
|
|
|
|
|
|
|
result = dns_c_zone_getminrefreshtime(czone, &uintval);
|
2000-08-03 00:41:26 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
2000-08-02 22:29:16 +00:00
|
|
|
result = dns_c_view_getminrefreshtime(cview, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getminrefreshtime(cctx, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
uintval = DNS_ZONE_MINREFRESH;
|
|
|
|
dns_zone_setminrefreshtime(zone, uintval);
|
|
|
|
|
|
|
|
result = dns_c_zone_getmaxretrytime(czone, &uintval);
|
2000-08-03 00:41:26 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
2000-08-02 22:29:16 +00:00
|
|
|
result = dns_c_view_getmaxretrytime(cview, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getmaxretrytime(cctx, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
uintval = DNS_ZONE_MAXRETRY;
|
|
|
|
dns_zone_setmaxretrytime(zone, uintval);
|
|
|
|
|
|
|
|
result = dns_c_zone_getminretrytime(czone, &uintval);
|
2000-08-03 00:41:26 +00:00
|
|
|
if (result != ISC_R_SUCCESS && cview != NULL)
|
2000-08-02 22:29:16 +00:00
|
|
|
result = dns_c_view_getminretrytime(cview, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
result = dns_c_ctx_getminretrytime(cctx, &uintval);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
uintval = DNS_ZONE_MINRETRY;
|
|
|
|
dns_zone_setminretrytime(zone, uintval);
|
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
break;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
2000-01-21 19:22:35 +00:00
|
|
|
isc_boolean_t
|
2000-05-08 14:38:29 +00:00
|
|
|
dns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone) {
|
2000-01-21 19:22:35 +00:00
|
|
|
const char *cfilename;
|
|
|
|
const char *zfilename;
|
|
|
|
|
|
|
|
if (dns_zonetype_fromconf(czone->ztype) != dns_zone_gettype(zone))
|
|
|
|
return (ISC_FALSE);
|
|
|
|
|
|
|
|
cfilename = NULL;
|
|
|
|
(void) dns_c_zone_getfile(czone, &cfilename);
|
2000-11-18 00:57:23 +00:00
|
|
|
zfilename = dns_zone_getfile(zone);
|
2000-01-21 19:22:35 +00:00
|
|
|
if (cfilename == NULL || zfilename == NULL ||
|
|
|
|
strcmp(cfilename, zfilename) != 0)
|
|
|
|
return (ISC_FALSE);
|
|
|
|
|
|
|
|
return (ISC_TRUE);
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-27 19:44:49 +00:00
|
|
|
isc_result_t
|
2000-05-08 14:38:29 +00:00
|
|
|
dns_zonemgr_configure(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr) {
|
2000-06-05 09:17:14 +00:00
|
|
|
isc_uint32_t val;
|
2000-01-27 19:44:49 +00:00
|
|
|
isc_result_t result;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-27 19:44:49 +00:00
|
|
|
result = dns_c_ctx_gettransfersin(cctx, &val);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-01-27 19:44:49 +00:00
|
|
|
val = 10;
|
|
|
|
dns_zonemgr_settransfersin(zmgr, val);
|
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
result = dns_c_ctx_gettransfersperns(cctx, &val);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
val = 2;
|
|
|
|
dns_zonemgr_settransfersperns(zmgr, val);
|
|
|
|
|
2000-01-27 19:44:49 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|