1999-01-19 06:32:53 +00:00
|
|
|
/*
|
2001-01-09 22:01:04 +00:00
|
|
|
* Copyright (C) 1999-2001 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
1999-01-19 06:32:53 +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-01-19 06:32:53 +00:00
|
|
|
*/
|
|
|
|
|
2001-06-04 14:08:34 +00:00
|
|
|
/* $Id: server.c,v 1.329 2001/06/04 14:08:34 marka Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
1999-01-19 06:32:53 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
#include <isc/app.h>
|
2000-04-10 21:31:41 +00:00
|
|
|
#include <isc/base64.h>
|
2000-01-21 23:55:12 +00:00
|
|
|
#include <isc/dir.h>
|
2000-06-09 22:33:52 +00:00
|
|
|
#include <isc/entropy.h>
|
2000-09-07 18:37:38 +00:00
|
|
|
#include <isc/file.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/lex.h>
|
2000-11-15 00:19:49 +00:00
|
|
|
#include <isc/print.h>
|
|
|
|
#include <isc/resource.h>
|
2000-11-08 18:58:02 +00:00
|
|
|
#include <isc/stdio.h>
|
2000-05-09 15:02:20 +00:00
|
|
|
#include <isc/string.h>
|
2000-01-21 23:55:12 +00:00
|
|
|
#include <isc/task.h>
|
1999-01-19 06:32:53 +00:00
|
|
|
#include <isc/timer.h>
|
1999-12-16 22:24:22 +00:00
|
|
|
#include <isc/util.h>
|
1999-01-19 06:32:53 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
#include <isccfg/cfg.h>
|
|
|
|
#include <isccfg/check.h>
|
|
|
|
|
1999-12-02 22:38:34 +00:00
|
|
|
#include <dns/cache.h>
|
2000-01-21 23:55:12 +00:00
|
|
|
#include <dns/db.h>
|
2000-01-26 19:25:22 +00:00
|
|
|
#include <dns/dispatch.h>
|
2000-08-24 22:15:40 +00:00
|
|
|
#include <dns/forward.h>
|
2000-01-21 23:55:12 +00:00
|
|
|
#include <dns/journal.h>
|
2000-04-10 21:31:41 +00:00
|
|
|
#include <dns/keytable.h>
|
2000-09-05 03:35:24 +00:00
|
|
|
#include <dns/master.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/peer.h>
|
2000-11-30 20:47:53 +00:00
|
|
|
#include <dns/rdataclass.h>
|
2000-04-10 21:31:41 +00:00
|
|
|
#include <dns/rdatastruct.h>
|
2000-01-31 19:59:11 +00:00
|
|
|
#include <dns/resolver.h>
|
2000-01-22 01:59:02 +00:00
|
|
|
#include <dns/rootns.h>
|
2000-12-01 23:49:59 +00:00
|
|
|
#include <dns/stats.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/tkey.h>
|
1999-08-05 22:14:43 +00:00
|
|
|
#include <dns/view.h>
|
1999-10-13 17:50:21 +00:00
|
|
|
#include <dns/zone.h>
|
2000-10-12 21:52:00 +00:00
|
|
|
#include <dns/zt.h>
|
1999-01-19 06:32:53 +00:00
|
|
|
|
2000-06-07 01:44:33 +00:00
|
|
|
#include <dst/dst.h>
|
|
|
|
|
2000-01-18 18:09:47 +00:00
|
|
|
#include <named/client.h>
|
2001-03-04 21:21:39 +00:00
|
|
|
#include <named/config.h>
|
2001-03-27 00:44:59 +00:00
|
|
|
#include <named/control.h>
|
2000-01-13 23:32:41 +00:00
|
|
|
#include <named/interfacemgr.h>
|
1999-10-22 19:35:19 +00:00
|
|
|
#include <named/log.h>
|
2000-02-28 18:38:44 +00:00
|
|
|
#include <named/logconf.h>
|
2000-10-04 23:19:01 +00:00
|
|
|
#include <named/lwresd.h>
|
2000-01-28 20:09:49 +00:00
|
|
|
#include <named/os.h>
|
1999-07-24 01:16:38 +00:00
|
|
|
#include <named/server.h>
|
2000-11-27 19:42:38 +00:00
|
|
|
#include <named/tkeyconf.h>
|
|
|
|
#include <named/tsigconf.h>
|
|
|
|
#include <named/zoneconf.h>
|
1999-01-19 06:32:53 +00:00
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
/*
|
|
|
|
* Check an operation for failure. Assumes that the function
|
|
|
|
* using it has a 'result' variable and a 'cleanup' label.
|
|
|
|
*/
|
|
|
|
#define CHECK(op) \
|
|
|
|
do { result = (op); \
|
|
|
|
if (result != ISC_R_SUCCESS) goto cleanup; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define CHECKM(op, msg) \
|
|
|
|
do { result = (op); \
|
|
|
|
if (result != ISC_R_SUCCESS) { \
|
|
|
|
isc_log_write(ns_g_lctx, \
|
|
|
|
NS_LOGCATEGORY_GENERAL, \
|
|
|
|
NS_LOGMODULE_SERVER, \
|
|
|
|
ISC_LOG_ERROR, \
|
|
|
|
"%s: %s", msg, \
|
|
|
|
isc_result_totext(result)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
|
|
|
} while (0) \
|
|
|
|
|
|
|
|
#define CHECKFATAL(op, msg) \
|
|
|
|
do { result = (op); \
|
|
|
|
if (result != ISC_R_SUCCESS) \
|
|
|
|
fatal(msg, result); \
|
|
|
|
} while (0) \
|
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
static void
|
|
|
|
fatal(const char *msg, isc_result_t result);
|
|
|
|
|
|
|
|
static void
|
|
|
|
ns_server_reload(isc_task_t *task, isc_event_t *event);
|
2000-01-26 17:35:16 +00:00
|
|
|
|
2000-01-25 21:21:05 +00:00
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
ns_listenelt_fromconfig(cfg_obj_t *listener, cfg_obj_t *config,
|
2000-11-27 19:42:38 +00:00
|
|
|
ns_aclconfctx_t *actx,
|
2000-01-25 21:21:05 +00:00
|
|
|
isc_mem_t *mctx, ns_listenelt_t **target);
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
ns_listenlist_fromconfig(cfg_obj_t *listenlist, cfg_obj_t *config,
|
2000-11-27 19:42:38 +00:00
|
|
|
ns_aclconfctx_t *actx,
|
2000-01-25 21:21:05 +00:00
|
|
|
isc_mem_t *mctx, ns_listenlist_t **target);
|
2000-01-21 23:55:12 +00:00
|
|
|
|
2000-08-24 22:15:40 +00:00
|
|
|
static isc_result_t
|
2001-03-09 19:07:30 +00:00
|
|
|
configure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
|
|
|
|
cfg_obj_t *forwarders, cfg_obj_t *forwardtype);
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
|
|
|
|
isc_mem_t *mctx, dns_view_t *view,
|
|
|
|
ns_aclconfctx_t *aclconf);
|
2000-08-24 22:15:40 +00:00
|
|
|
|
2000-04-06 17:31:33 +00:00
|
|
|
/*
|
|
|
|
* Configure a single view ACL at '*aclp'. Get its configuration by
|
|
|
|
* calling 'getvcacl' (for per-view configuration) and maybe 'getscacl'
|
|
|
|
* (for a global default).
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
configure_view_acl(cfg_obj_t *vconfig, cfg_obj_t *config,
|
|
|
|
const char *aclname, ns_aclconfctx_t *actx,
|
|
|
|
isc_mem_t *mctx, dns_acl_t **aclp)
|
2000-04-06 17:31:33 +00:00
|
|
|
{
|
|
|
|
isc_result_t result;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *maps[3];
|
|
|
|
cfg_obj_t *aclobj = NULL;
|
|
|
|
int i = 0;
|
|
|
|
|
2001-06-04 14:08:34 +00:00
|
|
|
if (*aclp != NULL)
|
|
|
|
dns_acl_detach(aclp);
|
2001-03-04 21:21:39 +00:00
|
|
|
if (vconfig != NULL)
|
|
|
|
maps[i++] = cfg_tuple_get(vconfig, "options");
|
|
|
|
if (config != NULL) {
|
|
|
|
cfg_obj_t *options = NULL;
|
|
|
|
cfg_map_get(config, "options", &options);
|
|
|
|
if (options != NULL)
|
|
|
|
maps[i++] = options;
|
|
|
|
}
|
|
|
|
maps[i] = NULL;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
result = ns_config_get(maps, aclname, &aclobj);
|
|
|
|
if (aclobj == NULL)
|
2000-07-10 11:35:02 +00:00
|
|
|
/*
|
|
|
|
* No value available. *aclp == NULL.
|
|
|
|
*/
|
2000-04-06 17:31:33 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
result = ns_acl_fromconfig(aclobj, config, actx, mctx, aclp);
|
2000-04-06 17:31:33 +00:00
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-11-15 01:16:30 +00:00
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
configure_view_dnsseckey(cfg_obj_t *vconfig, cfg_obj_t *key,
|
2000-11-15 01:16:30 +00:00
|
|
|
dns_keytable_t *keytable, isc_mem_t *mctx)
|
|
|
|
{
|
|
|
|
dns_rdataclass_t viewclass;
|
|
|
|
dns_rdata_key_t keystruct;
|
2001-03-04 21:21:39 +00:00
|
|
|
isc_uint32_t flags, proto, alg;
|
|
|
|
char *keystr, *keynamestr;
|
2000-11-15 01:16:30 +00:00
|
|
|
unsigned char keydata[4096];
|
|
|
|
isc_buffer_t keydatabuf;
|
|
|
|
unsigned char rrdata[4096];
|
|
|
|
isc_buffer_t rrdatabuf;
|
|
|
|
isc_region_t r;
|
|
|
|
dns_fixedname_t fkeyname;
|
|
|
|
dns_name_t *keyname;
|
|
|
|
isc_buffer_t namebuf;
|
|
|
|
isc_result_t result;
|
|
|
|
dst_key_t *dstkey = NULL;
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
flags = cfg_obj_asuint32(cfg_tuple_get(key, "flags"));
|
|
|
|
proto = cfg_obj_asuint32(cfg_tuple_get(key, "protocol"));
|
|
|
|
alg = cfg_obj_asuint32(cfg_tuple_get(key, "algorithm"));
|
|
|
|
keyname = dns_fixedname_name(&fkeyname);
|
|
|
|
keynamestr = cfg_obj_asstring(cfg_tuple_get(key, "name"));
|
|
|
|
|
|
|
|
if (vconfig == NULL)
|
2000-11-15 01:16:30 +00:00
|
|
|
viewclass = dns_rdataclass_in;
|
2001-03-04 21:21:39 +00:00
|
|
|
else {
|
|
|
|
cfg_obj_t *classobj = cfg_tuple_get(vconfig, "class");
|
|
|
|
CHECK(ns_config_getclass(classobj, &viewclass));
|
|
|
|
}
|
2000-11-15 01:16:30 +00:00
|
|
|
keystruct.common.rdclass = viewclass;
|
|
|
|
keystruct.common.rdtype = dns_rdatatype_key;
|
|
|
|
/*
|
2001-03-04 21:21:39 +00:00
|
|
|
* The key data in keystruct is not dynamically allocated.
|
2000-11-15 01:16:30 +00:00
|
|
|
*/
|
|
|
|
keystruct.mctx = NULL;
|
|
|
|
|
|
|
|
ISC_LINK_INIT(&keystruct.common, link);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
if (flags > 0xffff)
|
2000-11-15 01:16:30 +00:00
|
|
|
CHECKM(ISC_R_RANGE, "key flags");
|
2001-03-04 21:21:39 +00:00
|
|
|
if (proto > 0xff)
|
2000-11-15 01:16:30 +00:00
|
|
|
CHECKM(ISC_R_RANGE, "key protocol");
|
2001-03-04 21:21:39 +00:00
|
|
|
if (alg > 0xff)
|
2000-11-15 01:16:30 +00:00
|
|
|
CHECKM(ISC_R_RANGE, "key algorithm");
|
2001-03-04 21:21:39 +00:00
|
|
|
keystruct.flags = (isc_uint16_t)flags;
|
|
|
|
keystruct.protocol = (isc_uint8_t)proto;
|
|
|
|
keystruct.algorithm = (isc_uint8_t)alg;
|
2000-11-15 01:16:30 +00:00
|
|
|
|
|
|
|
isc_buffer_init(&keydatabuf, keydata, sizeof(keydata));
|
|
|
|
isc_buffer_init(&rrdatabuf, rrdata, sizeof(rrdata));
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
keystr = cfg_obj_asstring(cfg_tuple_get(key, "key"));
|
2001-03-22 00:07:07 +00:00
|
|
|
CHECK(isc_base64_decodestring(keystr, &keydatabuf));
|
2000-11-15 01:16:30 +00:00
|
|
|
isc_buffer_usedregion(&keydatabuf, &r);
|
|
|
|
keystruct.datalen = r.length;
|
|
|
|
keystruct.data = r.base;
|
|
|
|
|
|
|
|
CHECK(dns_rdata_fromstruct(NULL,
|
|
|
|
keystruct.common.rdclass,
|
|
|
|
keystruct.common.rdtype,
|
|
|
|
&keystruct, &rrdatabuf));
|
|
|
|
dns_fixedname_init(&fkeyname);
|
2001-03-04 21:21:39 +00:00
|
|
|
isc_buffer_init(&namebuf, keynamestr, strlen(keynamestr));
|
|
|
|
isc_buffer_add(&namebuf, strlen(keynamestr));
|
2000-11-15 01:16:30 +00:00
|
|
|
CHECK(dns_name_fromtext(keyname, &namebuf,
|
|
|
|
dns_rootname, ISC_FALSE,
|
|
|
|
NULL));
|
|
|
|
CHECK(dst_key_fromdns(keyname, viewclass, &rrdatabuf,
|
|
|
|
mctx, &dstkey));
|
|
|
|
|
|
|
|
CHECK(dns_keytable_add(keytable, &dstkey));
|
|
|
|
INSIST(dstkey == NULL);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
cleanup:
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_log(key, ns_g_lctx, ISC_LOG_ERROR,
|
|
|
|
"configuring trusted key for '%s': %s",
|
|
|
|
keynamestr, isc_result_totext(result));
|
2000-11-15 01:16:30 +00:00
|
|
|
result = ISC_R_FAILURE;
|
|
|
|
|
|
|
|
if (dstkey != NULL)
|
|
|
|
dst_key_free(&dstkey);
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-04-10 21:31:41 +00:00
|
|
|
/*
|
2000-05-25 21:43:18 +00:00
|
|
|
* Configure DNSSEC keys for a view. Currently used only for
|
|
|
|
* the security roots.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2001-03-04 21:21:39 +00:00
|
|
|
* The per-view configuration values and the server-global defaults are read
|
|
|
|
* from 'vconfig' and 'config'. The variable to be configured is '*target'.
|
2000-04-10 21:31:41 +00:00
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
configure_view_dnsseckeys(cfg_obj_t *vconfig, cfg_obj_t *config,
|
|
|
|
isc_mem_t *mctx, dns_keytable_t **target)
|
2000-04-10 21:31:41 +00:00
|
|
|
{
|
|
|
|
isc_result_t result;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *keys = NULL;
|
|
|
|
cfg_obj_t *voptions = NULL;
|
|
|
|
cfg_listelt_t *element, *element2;
|
|
|
|
cfg_obj_t *keylist;
|
|
|
|
cfg_obj_t *key;
|
2000-04-10 21:31:41 +00:00
|
|
|
dns_keytable_t *keytable = NULL;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-10 21:31:41 +00:00
|
|
|
CHECK(dns_keytable_create(mctx, &keytable));
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
if (vconfig != NULL)
|
|
|
|
voptions = cfg_tuple_get(vconfig, "options");
|
2000-05-25 21:43:18 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
keys = NULL;
|
|
|
|
if (voptions != NULL)
|
|
|
|
(void)cfg_map_get(voptions, "trusted-keys", &keys);
|
|
|
|
if (keys == NULL)
|
|
|
|
(void)cfg_map_get(config, "trusted-keys", &keys);
|
|
|
|
|
|
|
|
for (element = cfg_list_first(keys);
|
|
|
|
element != NULL;
|
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
|
|
|
keylist = cfg_listelt_value(element);
|
|
|
|
for (element2 = cfg_list_first(keylist);
|
|
|
|
element2 != NULL;
|
|
|
|
element2 = cfg_list_next(element2))
|
|
|
|
{
|
|
|
|
key = cfg_listelt_value(element2);
|
|
|
|
CHECK(configure_view_dnsseckey(vconfig, key,
|
2000-11-15 01:16:30 +00:00
|
|
|
keytable, mctx));
|
2000-04-11 17:52:57 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-10 21:31:41 +00:00
|
|
|
dns_keytable_detach(target);
|
|
|
|
*target = keytable; /* Transfer ownership. */
|
|
|
|
keytable = NULL;
|
|
|
|
result = ISC_R_SUCCESS;
|
2000-11-15 01:16:30 +00:00
|
|
|
|
2000-04-10 21:31:41 +00:00
|
|
|
cleanup:
|
|
|
|
return (result);
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-10 21:31:41 +00:00
|
|
|
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
/*
|
|
|
|
* Get a dispatch appropriate for the resolver of a given view.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
get_view_querysource_dispatch(cfg_obj_t **maps,
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
int af, dns_dispatch_t **dispatchp)
|
|
|
|
{
|
|
|
|
isc_result_t result;
|
|
|
|
dns_dispatch_t *disp;
|
|
|
|
isc_sockaddr_t sa;
|
|
|
|
unsigned int attrs, attrmask;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *obj = NULL;
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make compiler happy.
|
|
|
|
*/
|
|
|
|
result = ISC_R_FAILURE;
|
|
|
|
|
|
|
|
switch (af) {
|
|
|
|
case AF_INET:
|
2001-03-04 21:21:39 +00:00
|
|
|
result = ns_config_get(maps, "query-source", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
break;
|
|
|
|
case AF_INET6:
|
2001-03-04 21:21:39 +00:00
|
|
|
result = ns_config_get(maps, "query-source-v6", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
INSIST(0);
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
sa = *(cfg_obj_assockaddr(obj));
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
INSIST(isc_sockaddr_pf(&sa) == af);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we don't support this address family, we're done!
|
|
|
|
*/
|
|
|
|
switch (af) {
|
|
|
|
case AF_INET:
|
|
|
|
result = isc_net_probeipv4();
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
result = isc_net_probeipv6();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
INSIST(0);
|
|
|
|
}
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to find a dispatcher that we can share.
|
|
|
|
*/
|
|
|
|
attrs = 0;
|
|
|
|
attrs |= DNS_DISPATCHATTR_UDP;
|
|
|
|
switch (af) {
|
|
|
|
case AF_INET:
|
|
|
|
attrs |= DNS_DISPATCHATTR_IPV4;
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
attrs |= DNS_DISPATCHATTR_IPV6;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
attrmask = 0;
|
|
|
|
attrmask |= DNS_DISPATCHATTR_UDP;
|
|
|
|
attrmask |= DNS_DISPATCHATTR_TCP;
|
|
|
|
attrmask |= DNS_DISPATCHATTR_IPV4;
|
|
|
|
attrmask |= DNS_DISPATCHATTR_IPV6;
|
|
|
|
|
|
|
|
disp = NULL;
|
|
|
|
result = dns_dispatch_getudp(ns_g_dispatchmgr, ns_g_socketmgr,
|
|
|
|
ns_g_taskmgr, &sa, 4096,
|
|
|
|
1000, 32768, 16411, 16433,
|
|
|
|
attrs, attrmask, &disp);
|
2000-06-13 16:33:19 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
2000-11-15 01:16:30 +00:00
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
2000-06-13 16:33:19 +00:00
|
|
|
"could not get query source dispatcher");
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
return (result);
|
2000-06-13 16:33:19 +00:00
|
|
|
}
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
|
|
|
|
*dispatchp = disp;
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
static isc_result_t
|
|
|
|
configure_peer(cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) {
|
|
|
|
isc_sockaddr_t *sa;
|
|
|
|
isc_netaddr_t na;
|
|
|
|
dns_peer_t *peer;
|
|
|
|
cfg_obj_t *obj;
|
|
|
|
char *str;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
sa = cfg_obj_assockaddr(cfg_map_getname(cpeer));
|
|
|
|
isc_netaddr_fromsockaddr(&na, sa);
|
|
|
|
|
|
|
|
peer = NULL;
|
|
|
|
result = dns_peer_new(mctx, &na, &peer);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(cpeer, "bogus", &obj);
|
|
|
|
if (obj != NULL)
|
|
|
|
dns_peer_setbogus(peer, cfg_obj_asboolean(obj));
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(cpeer, "provide-ixfr", &obj);
|
|
|
|
if (obj != NULL)
|
|
|
|
dns_peer_setprovideixfr(peer, cfg_obj_asboolean(obj));
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(cpeer, "request-ixfr", &obj);
|
|
|
|
if (obj != NULL)
|
|
|
|
dns_peer_setrequestixfr(peer, cfg_obj_asboolean(obj));
|
|
|
|
|
2001-03-06 23:54:37 +00:00
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(cpeer, "edns", &obj);
|
|
|
|
if (obj != NULL)
|
|
|
|
dns_peer_setsupportedns(peer, cfg_obj_asboolean(obj));
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(cpeer, "transfers", &obj);
|
|
|
|
if (obj != NULL)
|
|
|
|
dns_peer_settransfers(peer, cfg_obj_asuint32(obj));
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(cpeer, "transfer-format", &obj);
|
|
|
|
if (obj != NULL) {
|
|
|
|
str = cfg_obj_asstring(obj);
|
|
|
|
if (strcasecmp(str, "many-answers") == 0)
|
|
|
|
dns_peer_settransferformat(peer, dns_many_answers);
|
|
|
|
else if (strcasecmp(str, "one-answer") == 0)
|
|
|
|
dns_peer_settransferformat(peer, dns_one_answer);
|
|
|
|
else
|
|
|
|
INSIST(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(cpeer, "keys", &obj);
|
|
|
|
if (obj != NULL) {
|
|
|
|
result = dns_peer_setkeybycharp(peer, cfg_obj_asstring(obj));
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
*peerp = peer;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
dns_peer_detach(&peer);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-01-21 19:24:01 +00:00
|
|
|
/*
|
2001-03-04 21:21:39 +00:00
|
|
|
* Configure 'view' according to 'vconfig', taking defaults from 'config'
|
|
|
|
* where values are missing in 'vconfig'.
|
2000-04-07 17:08:12 +00:00
|
|
|
*
|
2001-03-04 21:21:39 +00:00
|
|
|
* When configuring the default view, 'vconfig' will be NULL and the
|
|
|
|
* global defaults in 'config' used exclusively.
|
2000-01-21 19:24:01 +00:00
|
|
|
*/
|
1999-10-15 01:51:48 +00:00
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
|
2000-11-27 19:42:38 +00:00
|
|
|
isc_mem_t *mctx, ns_aclconfctx_t *actx)
|
1999-10-15 01:51:48 +00:00
|
|
|
{
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *maps[4];
|
|
|
|
cfg_obj_t *cfgmaps[3];
|
|
|
|
cfg_obj_t *options = NULL;
|
|
|
|
cfg_obj_t *voptions = NULL;
|
2001-03-09 19:07:30 +00:00
|
|
|
cfg_obj_t *forwardtype;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *forwarders;
|
|
|
|
cfg_obj_t *zonelist;
|
|
|
|
cfg_obj_t *obj;
|
|
|
|
cfg_listelt_t *element;
|
|
|
|
in_port_t port;
|
2000-03-02 23:47:39 +00:00
|
|
|
dns_cache_t *cache = NULL;
|
1999-10-15 01:51:48 +00:00
|
|
|
isc_result_t result;
|
2000-08-31 12:15:17 +00:00
|
|
|
isc_uint32_t max_cache_size;
|
2000-11-08 03:53:16 +00:00
|
|
|
isc_uint32_t lame_ttl;
|
2000-01-21 20:24:49 +00:00
|
|
|
dns_tsig_keyring_t *ring;
|
2000-03-02 23:47:39 +00:00
|
|
|
dns_view_t *pview = NULL; /* Production view */
|
2000-04-12 01:38:26 +00:00
|
|
|
isc_mem_t *cmctx;
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
dns_dispatch_t *dispatch4 = NULL;
|
|
|
|
dns_dispatch_t *dispatch6 = NULL;
|
2001-01-12 22:22:17 +00:00
|
|
|
isc_boolean_t reused_cache = ISC_FALSE;
|
2001-03-04 21:21:39 +00:00
|
|
|
int i;
|
|
|
|
char *str;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-21 19:24:01 +00:00
|
|
|
REQUIRE(DNS_VIEW_VALID(view));
|
1999-08-05 22:14:43 +00:00
|
|
|
|
2000-04-12 01:38:26 +00:00
|
|
|
cmctx = NULL;
|
2000-01-31 19:59:11 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
if (config != NULL)
|
|
|
|
cfg_map_get(config, "options", &options);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
if (vconfig != NULL) {
|
|
|
|
voptions = cfg_tuple_get(vconfig, "options");
|
|
|
|
maps[i++] = voptions;
|
|
|
|
}
|
|
|
|
if (options != NULL)
|
|
|
|
maps[i++] = options;
|
|
|
|
maps[i++] = ns_g_defaults;
|
|
|
|
maps[i] = NULL;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
if (voptions != NULL)
|
|
|
|
cfgmaps[i++] = voptions;
|
|
|
|
if (config != NULL)
|
|
|
|
cfgmaps[i++] = config;
|
|
|
|
cfgmaps[i] = NULL;
|
|
|
|
|
|
|
|
|
2000-06-05 19:10:13 +00:00
|
|
|
/*
|
|
|
|
* Set the view's port number for outgoing queries.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECKM(ns_config_getport(config, &port), "port");
|
2000-06-05 19:10:13 +00:00
|
|
|
dns_view_setdstport(view, port);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
/*
|
|
|
|
* Configure the zones.
|
|
|
|
*/
|
|
|
|
zonelist = NULL;
|
|
|
|
if (voptions != NULL)
|
|
|
|
(void)cfg_map_get(voptions, "zone", &zonelist);
|
|
|
|
else
|
|
|
|
(void)cfg_map_get(config, "zone", &zonelist);
|
|
|
|
for (element = cfg_list_first(zonelist);
|
|
|
|
element != NULL;
|
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
|
|
|
cfg_obj_t *zconfig = cfg_listelt_value(element);
|
|
|
|
CHECK(configure_zone(config, zconfig, vconfig, mctx, view,
|
|
|
|
actx));
|
|
|
|
}
|
|
|
|
|
1999-10-15 01:51:48 +00:00
|
|
|
/*
|
2000-03-02 23:47:39 +00:00
|
|
|
* Configure the view's cache. Try to reuse an existing
|
|
|
|
* cache if possible, otherwise create a new cache.
|
|
|
|
* Note that the ADB is not preserved in either case.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
|
|
|
* XXX Determining when it is safe to reuse a cache is
|
2000-03-02 23:47:39 +00:00
|
|
|
* tricky. When the view's configuration changes, the cached
|
|
|
|
* data may become invalid because it reflects our old
|
|
|
|
* view of the world. As more view attributes become
|
|
|
|
* configurable, we will have to add code here to check
|
|
|
|
* whether they have changed in ways that could
|
|
|
|
* invalidate the cache.
|
1999-10-15 01:51:48 +00:00
|
|
|
*/
|
2000-03-02 23:47:39 +00:00
|
|
|
result = dns_viewlist_find(&ns_g_server->viewlist,
|
|
|
|
view->name, view->rdclass,
|
|
|
|
&pview);
|
|
|
|
if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
if (pview != NULL) {
|
|
|
|
INSIST(pview->cache != NULL);
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
2000-11-15 01:16:30 +00:00
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_DEBUG(3),
|
|
|
|
"reusing existing cache");
|
2001-01-12 22:22:17 +00:00
|
|
|
reused_cache = ISC_TRUE;
|
2000-03-02 23:47:39 +00:00
|
|
|
dns_cache_attach(pview->cache, &cache);
|
|
|
|
dns_view_detach(&pview);
|
|
|
|
} else {
|
2000-04-12 01:38:26 +00:00
|
|
|
CHECK(isc_mem_create(0, 0, &cmctx));
|
|
|
|
CHECK(dns_cache_create(cmctx, ns_g_taskmgr, ns_g_timermgr,
|
2000-03-02 23:47:39 +00:00
|
|
|
view->rdclass, "rbt", 0, NULL, &cache));
|
|
|
|
}
|
1999-12-02 22:38:34 +00:00
|
|
|
dns_view_setcache(view, cache);
|
2000-04-07 18:04:24 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
/*
|
|
|
|
* cache-file cannot be inherited if views are present, but this
|
|
|
|
* should be caught by the configuration checking stage.
|
|
|
|
*/
|
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "cache-file", &obj);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
dns_cache_setfilename(cache, cfg_obj_asstring(obj));
|
2001-01-12 22:22:17 +00:00
|
|
|
if (!reused_cache)
|
|
|
|
CHECK(dns_cache_load(cache));
|
|
|
|
}
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "cleaning-interval", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
dns_cache_setcleaninginterval(cache, cfg_obj_asuint32(obj));
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "max-cache-size", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
if (cfg_obj_isstring(obj)) {
|
|
|
|
str = cfg_obj_asstring(obj);
|
|
|
|
INSIST(strcasecmp(str, "unlimited") == 0);
|
|
|
|
max_cache_size = ISC_UINT32_MAX;
|
|
|
|
} else {
|
|
|
|
isc_resourcevalue_t value;
|
|
|
|
value = cfg_obj_asuint64(obj);
|
|
|
|
if (value > ISC_UINT32_MAX) {
|
|
|
|
cfg_obj_log(obj, ns_g_lctx, ISC_LOG_ERROR,
|
|
|
|
"'max-cache-size "
|
|
|
|
"%" ISC_PRINT_QUADFORMAT "d' is too large",
|
|
|
|
value);
|
|
|
|
result = ISC_R_RANGE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
max_cache_size = (isc_uint32_t)value;
|
|
|
|
}
|
2000-08-31 12:15:17 +00:00
|
|
|
dns_cache_setcachesize(cache, max_cache_size);
|
|
|
|
|
1999-12-02 22:38:34 +00:00
|
|
|
dns_cache_detach(&cache);
|
1999-05-03 19:56:23 +00:00
|
|
|
|
1999-10-15 01:51:48 +00:00
|
|
|
/*
|
|
|
|
* Resolver.
|
|
|
|
*
|
2000-01-26 19:25:22 +00:00
|
|
|
* XXXRTH Hardwired number of tasks.
|
1999-10-15 01:51:48 +00:00
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(get_view_querysource_dispatch(maps, AF_INET, &dispatch4));
|
|
|
|
CHECK(get_view_querysource_dispatch(maps, AF_INET6, &dispatch6));
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_view_createresolver(view, ns_g_taskmgr, 31,
|
|
|
|
ns_g_socketmgr, ns_g_timermgr,
|
2000-05-10 21:34:50 +00:00
|
|
|
0, ns_g_dispatchmgr,
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
dispatch4, dispatch6));
|
|
|
|
if (dispatch4 != NULL)
|
|
|
|
dns_dispatch_detach(&dispatch4);
|
|
|
|
if (dispatch6 != NULL)
|
|
|
|
dns_dispatch_detach(&dispatch6);
|
1999-08-05 22:14:43 +00:00
|
|
|
|
2000-11-08 03:53:16 +00:00
|
|
|
/*
|
|
|
|
* Set resolver's lame-ttl.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "lame-ttl", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
lame_ttl = cfg_obj_asuint32(obj);
|
2000-11-08 03:53:16 +00:00
|
|
|
if (lame_ttl > 18000)
|
|
|
|
lame_ttl = 18000;
|
|
|
|
dns_resolver_setlamettl(view->resolver, lame_ttl);
|
|
|
|
|
2000-01-31 19:59:11 +00:00
|
|
|
/*
|
|
|
|
* Set resolver forwarding policy.
|
|
|
|
*/
|
2001-03-09 19:07:30 +00:00
|
|
|
forwardtype = NULL;
|
2001-03-04 21:21:39 +00:00
|
|
|
forwarders = NULL;
|
2001-03-09 19:07:30 +00:00
|
|
|
(void)ns_config_get(maps, "forward", &forwardtype);
|
2001-03-04 21:21:39 +00:00
|
|
|
(void)ns_config_get(maps, "forwarders", &forwarders);
|
2001-03-09 19:07:30 +00:00
|
|
|
CHECK(configure_forward(config, view, dns_rootname, forwarders,
|
|
|
|
forwardtype));
|
2000-01-31 19:59:11 +00:00
|
|
|
|
1999-10-15 01:51:48 +00:00
|
|
|
/*
|
2000-01-27 01:57:08 +00:00
|
|
|
* We have default hints for class IN if we need them.
|
1999-10-15 01:51:48 +00:00
|
|
|
*/
|
2000-01-27 01:57:08 +00:00
|
|
|
if (view->rdclass == dns_rdataclass_in && view->hints == NULL)
|
2000-04-06 17:31:33 +00:00
|
|
|
dns_view_sethints(view, ns_g_server->in_roothints);
|
1999-08-05 22:14:43 +00:00
|
|
|
|
2000-04-06 17:31:33 +00:00
|
|
|
/*
|
|
|
|
* If we still have no hints, this is a non-IN view with no
|
2001-01-22 19:21:19 +00:00
|
|
|
* "hints zone" configured. Issue a warning, except if this
|
|
|
|
* is a root server. Root servers never need to consult
|
|
|
|
* their hints, so it's no point requireing users to configure
|
|
|
|
* them.
|
2000-04-06 17:31:33 +00:00
|
|
|
*/
|
|
|
|
if (view->hints == NULL) {
|
2001-01-22 19:21:19 +00:00
|
|
|
dns_zone_t *rootzone = NULL;
|
|
|
|
dns_view_findzone(view, dns_rootname, &rootzone);
|
|
|
|
if (rootzone != NULL) {
|
|
|
|
dns_zone_detach(&rootzone);
|
|
|
|
} else {
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
|
|
|
"no root hints for view '%s'",
|
2001-03-04 21:21:39 +00:00
|
|
|
view->name);
|
2001-01-22 19:21:19 +00:00
|
|
|
}
|
2000-04-06 17:31:33 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-21 20:24:49 +00:00
|
|
|
/*
|
2000-01-21 23:55:12 +00:00
|
|
|
* Configure the view's TSIG keys.
|
2000-01-21 20:24:49 +00:00
|
|
|
*/
|
|
|
|
ring = NULL;
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(ns_tsigkeyring_fromconfig(config, vconfig, view->mctx, &ring));
|
2000-01-21 20:24:49 +00:00
|
|
|
dns_view_setkeyring(view, ring);
|
|
|
|
|
2000-02-24 21:12:16 +00:00
|
|
|
/*
|
|
|
|
* Configure the view's peer list.
|
|
|
|
*/
|
|
|
|
{
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *peers = NULL;
|
|
|
|
cfg_listelt_t *element;
|
2000-02-24 21:12:16 +00:00
|
|
|
dns_peerlist_t *newpeers = NULL;
|
2000-05-25 22:19:34 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
(void)ns_config_get(cfgmaps, "server", &peers);
|
|
|
|
CHECK(dns_peerlist_new(mctx, &newpeers));
|
|
|
|
for (element = cfg_list_first(peers);
|
|
|
|
element != NULL;
|
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
|
|
|
cfg_obj_t *cpeer = cfg_listelt_value(element);
|
|
|
|
dns_peer_t *peer;
|
2000-05-25 22:19:34 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(configure_peer(cpeer, mctx, &peer));
|
|
|
|
dns_peerlist_addpeer(newpeers, peer);
|
|
|
|
dns_peer_detach(&peer);
|
|
|
|
}
|
2000-02-24 21:12:16 +00:00
|
|
|
dns_peerlist_detach(&view->peers);
|
|
|
|
view->peers = newpeers; /* Transfer ownership. */
|
|
|
|
}
|
2000-04-06 17:31:33 +00:00
|
|
|
|
2001-03-26 21:33:07 +00:00
|
|
|
/*
|
|
|
|
* Copy the aclenv object.
|
|
|
|
*/
|
|
|
|
dns_aclenv_copy(&view->aclenv, &ns_g_server->aclenv);
|
|
|
|
|
2000-04-06 17:31:33 +00:00
|
|
|
/*
|
|
|
|
* Configure the "match-clients" ACL.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(configure_view_acl(vconfig, config, "match-clients", actx,
|
|
|
|
ns_g_mctx, &view->matchclients));
|
2000-04-06 17:31:33 +00:00
|
|
|
|
2000-04-06 20:25:48 +00:00
|
|
|
/*
|
|
|
|
* Configure other configurable data.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "recursion", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->recursion = cfg_obj_asboolean(obj);
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "auth-nxdomain", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->auth_nxdomain = cfg_obj_asboolean(obj);
|
|
|
|
|
2001-03-14 21:53:29 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "minimal-responses", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->minimalresponses = cfg_obj_asboolean(obj);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "transfer-format", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
str = cfg_obj_asstring(obj);
|
|
|
|
if (strcasecmp(str, "many-answers") == 0)
|
2000-06-23 01:08:29 +00:00
|
|
|
view->transfer_format = dns_many_answers;
|
2001-03-04 21:21:39 +00:00
|
|
|
else if (strcasecmp(str, "one-answer") == 0)
|
|
|
|
view->transfer_format = dns_one_answer;
|
|
|
|
else
|
|
|
|
INSIST(0);
|
|
|
|
|
2000-07-31 21:07:07 +00:00
|
|
|
/*
|
|
|
|
* Set sources where additional data, CNAMEs, and DNAMEs may be found.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "additional-from-auth", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->additionalfromauth = cfg_obj_asboolean(obj);
|
2000-07-31 21:07:07 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "additional-from-cache", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->additionalfromcache = cfg_obj_asboolean(obj);
|
2000-04-07 22:30:43 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(configure_view_acl(vconfig, config, "allow-query",
|
|
|
|
actx, ns_g_mctx, &view->queryacl));
|
|
|
|
|
|
|
|
CHECK(configure_view_acl(vconfig, config, "allow-recursion",
|
|
|
|
actx, ns_g_mctx, &view->recursionacl));
|
|
|
|
|
|
|
|
CHECK(configure_view_acl(vconfig, config, "allow-v6-synthesis",
|
|
|
|
actx, ns_g_mctx, &view->v6synthesisacl));
|
|
|
|
|
|
|
|
CHECK(configure_view_acl(vconfig, config, "sortlist",
|
|
|
|
actx, ns_g_mctx, &view->sortlist));
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "request-ixfr", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->requestixfr = cfg_obj_asboolean(obj);
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "provide-ixfr", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->provideixfr = cfg_obj_asboolean(obj);
|
2000-04-07 22:30:43 +00:00
|
|
|
|
2000-04-11 00:37:59 +00:00
|
|
|
/*
|
|
|
|
* For now, there is only one kind of trusted keys, the
|
|
|
|
* "security roots".
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(configure_view_dnsseckeys(vconfig, config, mctx,
|
2000-04-11 00:37:59 +00:00
|
|
|
&view->secroots));
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "max-cache-ttl", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->maxcachettl = cfg_obj_asuint32(obj);
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "max-ncache-ttl", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
view->maxncachettl = cfg_obj_asuint32(obj);
|
|
|
|
if (view->maxncachettl > 7 * 24 * 3600)
|
|
|
|
view->maxncachettl = 7 * 24 * 3600;
|
2000-05-26 23:17:56 +00:00
|
|
|
|
2000-04-07 22:37:42 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
|
1999-10-15 01:51:48 +00:00
|
|
|
cleanup:
|
2000-04-12 01:38:26 +00:00
|
|
|
if (cmctx != NULL)
|
|
|
|
isc_mem_detach(&cmctx);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
if (cache != NULL)
|
|
|
|
dns_cache_detach(&cache);
|
|
|
|
|
1999-08-05 22:14:43 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
1999-12-08 21:27:08 +00:00
|
|
|
/*
|
2000-08-02 18:13:08 +00:00
|
|
|
* Create the special view that handles queries under "bind. CH".
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-08 01:38:39 +00:00
|
|
|
create_bind_view(dns_view_t **viewp) {
|
2000-08-02 18:13:08 +00:00
|
|
|
isc_result_t result;
|
|
|
|
dns_view_t *view = NULL;
|
|
|
|
|
|
|
|
REQUIRE(viewp != NULL && *viewp == NULL);
|
|
|
|
|
|
|
|
CHECK(dns_view_create(ns_g_mctx, dns_rdataclass_ch, "_bind", &view));
|
|
|
|
|
|
|
|
/* Transfer ownership. */
|
|
|
|
*viewp = view;
|
|
|
|
view = NULL;
|
|
|
|
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (view != NULL)
|
|
|
|
dns_view_detach(&view);
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-03-04 21:21:39 +00:00
|
|
|
* Create the zone that handles queries for "version.bind. CH". The
|
2001-05-14 20:44:16 +00:00
|
|
|
* version string is returned either from the "version" configuration
|
2001-03-04 21:21:39 +00:00
|
|
|
* option or the global defaults.
|
1999-12-08 21:27:08 +00:00
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
create_version_zone(cfg_obj_t **maps, dns_zonemgr_t *zmgr, dns_view_t *view) {
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-12-08 21:27:08 +00:00
|
|
|
dns_db_t *db = NULL;
|
|
|
|
dns_zone_t *zone = NULL;
|
|
|
|
dns_dbversion_t *dbver = NULL;
|
|
|
|
dns_difftuple_t *tuple = NULL;
|
|
|
|
dns_diff_t diff;
|
|
|
|
char *versiontext;
|
2000-01-19 21:25:24 +00:00
|
|
|
unsigned char buf[256];
|
1999-12-08 21:27:08 +00:00
|
|
|
isc_region_t r;
|
|
|
|
size_t len;
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
2000-01-21 19:24:01 +00:00
|
|
|
static unsigned char origindata[] = "\007version\004bind";
|
|
|
|
dns_name_t origin;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *obj = NULL;
|
1999-12-08 21:27:08 +00:00
|
|
|
|
|
|
|
dns_diff_init(ns_g_mctx, &diff);
|
|
|
|
|
2000-01-21 19:24:01 +00:00
|
|
|
dns_name_init(&origin, NULL);
|
|
|
|
r.base = origindata;
|
|
|
|
r.length = sizeof(origindata);
|
|
|
|
dns_name_fromregion(&origin, &r);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
result = ns_config_get(maps, "version", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
versiontext = cfg_obj_asstring(obj);
|
1999-12-08 21:27:08 +00:00
|
|
|
len = strlen(versiontext);
|
|
|
|
if (len > 255)
|
|
|
|
len = 255; /* Silently truncate. */
|
|
|
|
buf[0] = len;
|
|
|
|
memcpy(buf + 1, versiontext, len);
|
|
|
|
|
|
|
|
r.base = buf;
|
|
|
|
r.length = 1 + len;
|
|
|
|
dns_rdata_fromregion(&rdata, dns_rdataclass_ch, dns_rdatatype_txt, &r);
|
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_zone_create(&zone, ns_g_mctx));
|
|
|
|
CHECK(dns_zone_setorigin(zone, &origin));
|
2000-06-01 23:11:26 +00:00
|
|
|
dns_zone_settype(zone, dns_zone_master);
|
2000-05-23 01:21:32 +00:00
|
|
|
dns_zone_setclass(zone, dns_rdataclass_ch);
|
2000-08-01 01:33:37 +00:00
|
|
|
dns_zone_setview(zone, view);
|
|
|
|
|
2000-05-17 19:45:36 +00:00
|
|
|
CHECK(dns_zonemgr_managezone(zmgr, zone));
|
1999-12-08 21:27:08 +00:00
|
|
|
|
2000-06-07 02:38:41 +00:00
|
|
|
CHECK(dns_db_create(ns_g_mctx, "rbt", &origin, dns_dbtype_zone,
|
2000-01-21 23:55:12 +00:00
|
|
|
dns_rdataclass_ch, 0, NULL, &db));
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_db_newversion(db, &dbver));
|
1999-12-08 21:27:08 +00:00
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_difftuple_create(ns_g_mctx, DNS_DIFFOP_ADD, &origin,
|
|
|
|
0, &rdata, &tuple));
|
1999-12-08 21:27:08 +00:00
|
|
|
dns_diff_append(&diff, &tuple);
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_diff_apply(&diff, db, dbver));
|
1999-12-08 21:27:08 +00:00
|
|
|
|
|
|
|
dns_db_closeversion(db, &dbver, ISC_TRUE);
|
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_zone_replacedb(zone, db, ISC_FALSE));
|
1999-12-08 21:27:08 +00:00
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_view_addzone(view, zone));
|
1999-12-08 21:27:08 +00:00
|
|
|
|
2000-08-02 18:13:08 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
1999-12-08 21:27:08 +00:00
|
|
|
|
2000-08-02 18:13:08 +00:00
|
|
|
cleanup:
|
|
|
|
if (zone != NULL)
|
|
|
|
dns_zone_detach(&zone);
|
|
|
|
if (dbver != NULL)
|
|
|
|
dns_db_closeversion(db, &dbver, ISC_FALSE);
|
|
|
|
if (db != NULL)
|
|
|
|
dns_db_detach(&db);
|
|
|
|
dns_diff_clear(&diff);
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-14 20:44:16 +00:00
|
|
|
* Create the special zone that handles queries for "authors.bind. CH".
|
|
|
|
* The strings returned list the BIND 9 authors.
|
2000-08-02 18:13:08 +00:00
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
create_authors_zone(cfg_obj_t *options, dns_zonemgr_t *zmgr, dns_view_t *view)
|
|
|
|
{
|
2000-08-02 18:13:08 +00:00
|
|
|
isc_result_t result;
|
|
|
|
dns_db_t *db = NULL;
|
|
|
|
dns_zone_t *zone = NULL;
|
|
|
|
dns_dbversion_t *dbver = NULL;
|
|
|
|
dns_difftuple_t *tuple;
|
|
|
|
dns_diff_t diff;
|
2000-08-02 20:55:40 +00:00
|
|
|
isc_constregion_t r;
|
2000-08-02 18:13:08 +00:00
|
|
|
isc_constregion_t cr;
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
2000-08-02 20:47:21 +00:00
|
|
|
static const char origindata[] = "\007authors\004bind";
|
2000-08-02 18:13:08 +00:00
|
|
|
dns_name_t origin;
|
|
|
|
int i;
|
2000-08-02 20:47:21 +00:00
|
|
|
static const char *authors[] = {
|
2000-08-02 20:44:31 +00:00
|
|
|
"\014Mark Andrews",
|
|
|
|
"\015James Brister",
|
2001-02-17 01:09:22 +00:00
|
|
|
"\014Ben Cottrell",
|
2000-08-02 20:44:31 +00:00
|
|
|
"\015Michael Graff",
|
|
|
|
"\022Andreas Gustafsson",
|
|
|
|
"\012Bob Halley",
|
|
|
|
"\016David Lawrence",
|
2001-01-18 00:14:20 +00:00
|
|
|
"\013Damien Neil",
|
2001-02-17 01:09:22 +00:00
|
|
|
"\013Matt Nelson",
|
2000-08-02 20:44:31 +00:00
|
|
|
"\016Michael Sawyer",
|
|
|
|
"\020Brian Wellington",
|
|
|
|
NULL,
|
|
|
|
};
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *obj = NULL;
|
2000-08-02 18:13:08 +00:00
|
|
|
|
2001-01-18 00:14:20 +00:00
|
|
|
/*
|
|
|
|
* If a version string is specified, disable the authors.bind zone.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
if (options != NULL &&
|
|
|
|
cfg_map_get(options, "version", &obj) == ISC_R_SUCCESS)
|
2001-01-18 00:14:20 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
2000-08-02 18:13:08 +00:00
|
|
|
dns_diff_init(ns_g_mctx, &diff);
|
|
|
|
|
|
|
|
dns_name_init(&origin, NULL);
|
|
|
|
r.base = origindata;
|
|
|
|
r.length = sizeof(origindata);
|
2000-08-02 20:55:40 +00:00
|
|
|
dns_name_fromregion(&origin, (isc_region_t *)&r);
|
2000-08-02 18:13:08 +00:00
|
|
|
|
|
|
|
CHECK(dns_zone_create(&zone, ns_g_mctx));
|
|
|
|
CHECK(dns_zone_setorigin(zone, &origin));
|
|
|
|
dns_zone_settype(zone, dns_zone_master);
|
|
|
|
dns_zone_setclass(zone, dns_rdataclass_ch);
|
|
|
|
dns_zone_setview(zone, view);
|
|
|
|
|
|
|
|
CHECK(dns_zonemgr_managezone(zmgr, zone));
|
|
|
|
|
|
|
|
CHECK(dns_db_create(ns_g_mctx, "rbt", &origin, dns_dbtype_zone,
|
|
|
|
dns_rdataclass_ch, 0, NULL, &db));
|
|
|
|
|
|
|
|
CHECK(dns_db_newversion(db, &dbver));
|
|
|
|
|
|
|
|
for (i = 0; authors[i] != NULL; i++) {
|
|
|
|
cr.base = authors[i];
|
|
|
|
cr.length = strlen(authors[i]);
|
2000-08-08 01:56:44 +00:00
|
|
|
INSIST(cr.length == ((const unsigned char *)cr.base)[0] + 1U);
|
2000-08-02 18:13:08 +00:00
|
|
|
dns_rdata_fromregion(&rdata, dns_rdataclass_ch,
|
|
|
|
dns_rdatatype_txt, (isc_region_t *)&cr);
|
|
|
|
tuple = NULL;
|
|
|
|
CHECK(dns_difftuple_create(ns_g_mctx, DNS_DIFFOP_ADD, &origin,
|
|
|
|
0, &rdata, &tuple));
|
|
|
|
dns_diff_append(&diff, &tuple);
|
2000-10-31 03:22:05 +00:00
|
|
|
dns_rdata_reset(&rdata);
|
2000-08-02 18:13:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CHECK(dns_diff_apply(&diff, db, dbver));
|
|
|
|
|
|
|
|
dns_db_closeversion(db, &dbver, ISC_TRUE);
|
|
|
|
|
|
|
|
CHECK(dns_zone_replacedb(zone, db, ISC_FALSE));
|
|
|
|
|
|
|
|
CHECK(dns_view_addzone(view, zone));
|
1999-12-08 21:27:08 +00:00
|
|
|
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (zone != NULL)
|
|
|
|
dns_zone_detach(&zone);
|
|
|
|
if (dbver != NULL)
|
|
|
|
dns_db_closeversion(db, &dbver, ISC_FALSE);
|
|
|
|
if (db != NULL)
|
|
|
|
dns_db_detach(&db);
|
|
|
|
dns_diff_clear(&diff);
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-01-27 01:57:08 +00:00
|
|
|
static isc_result_t
|
|
|
|
configure_hints(dns_view_t *view, const char *filename) {
|
|
|
|
isc_result_t result;
|
|
|
|
dns_db_t *db;
|
|
|
|
|
|
|
|
db = NULL;
|
|
|
|
result = dns_rootns_create(view->mctx, view->rdclass, filename, &db);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
dns_view_sethints(view, db);
|
|
|
|
dns_db_detach(&db);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-08-24 22:15:40 +00:00
|
|
|
static isc_result_t
|
2001-03-09 19:07:30 +00:00
|
|
|
configure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
|
|
|
|
cfg_obj_t *forwarders, cfg_obj_t *forwardtype)
|
2000-08-24 22:15:40 +00:00
|
|
|
{
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *portobj;
|
|
|
|
cfg_obj_t *faddresses;
|
|
|
|
cfg_listelt_t *element;
|
2001-03-10 06:39:47 +00:00
|
|
|
dns_fwdpolicy_t fwdpolicy = dns_fwdpolicy_none;
|
2000-08-24 22:15:40 +00:00
|
|
|
isc_sockaddrlist_t addresses;
|
|
|
|
isc_sockaddr_t *sa;
|
|
|
|
isc_result_t result;
|
|
|
|
in_port_t port;
|
2001-03-04 21:21:39 +00:00
|
|
|
|
2000-10-04 23:19:01 +00:00
|
|
|
/*
|
|
|
|
* Determine which port to send forwarded requests to.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECKM(ns_config_getport(config, &port), "port");
|
|
|
|
|
|
|
|
if (forwarders != NULL) {
|
|
|
|
portobj = cfg_tuple_get(forwarders, "port");
|
|
|
|
if (cfg_obj_isuint32(portobj)) {
|
|
|
|
isc_uint32_t val = cfg_obj_asuint32(portobj);
|
|
|
|
if (val > ISC_UINT16_MAX) {
|
|
|
|
cfg_obj_log(portobj, ns_g_lctx, ISC_LOG_ERROR,
|
|
|
|
"port '%u' out of range", val);
|
|
|
|
return (ISC_R_RANGE);
|
|
|
|
}
|
|
|
|
port = (in_port_t) val;
|
|
|
|
}
|
2000-10-04 23:19:01 +00:00
|
|
|
}
|
2000-08-24 22:15:40 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
faddresses = NULL;
|
|
|
|
if (forwarders != NULL)
|
|
|
|
faddresses = cfg_tuple_get(forwarders, "addresses");
|
|
|
|
|
2000-08-24 22:15:40 +00:00
|
|
|
ISC_LIST_INIT(addresses);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
for (element = cfg_list_first(faddresses);
|
|
|
|
element != NULL;
|
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
|
|
|
cfg_obj_t *forwarder = cfg_listelt_value(element);
|
|
|
|
sa = isc_mem_get(view->mctx, sizeof(isc_sockaddr_t));
|
|
|
|
if (sa == NULL) {
|
|
|
|
result = ISC_R_NOMEMORY;
|
|
|
|
goto cleanup;
|
2000-08-24 22:15:40 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
*sa = *cfg_obj_assockaddr(forwarder);
|
|
|
|
if (isc_sockaddr_getport(sa) == 0)
|
|
|
|
isc_sockaddr_setport(sa, port);
|
|
|
|
ISC_LINK_INIT(sa, link);
|
|
|
|
ISC_LIST_APPEND(addresses, sa, link);
|
2000-08-24 22:15:40 +00:00
|
|
|
}
|
|
|
|
|
2001-03-09 19:07:30 +00:00
|
|
|
if (ISC_LIST_EMPTY(addresses)) {
|
|
|
|
if (forwardtype != NULL)
|
|
|
|
cfg_obj_log(forwarders, ns_g_lctx, ISC_LOG_WARNING,
|
|
|
|
"no forwarders seen; disabling "
|
|
|
|
"forwarding");
|
2000-08-24 22:15:40 +00:00
|
|
|
fwdpolicy = dns_fwdpolicy_none;
|
2001-03-09 19:07:30 +00:00
|
|
|
} else {
|
|
|
|
if (forwardtype == NULL)
|
2001-03-04 21:21:39 +00:00
|
|
|
fwdpolicy = dns_fwdpolicy_first;
|
2001-03-09 19:07:30 +00:00
|
|
|
else {
|
|
|
|
char *forwardstr = cfg_obj_asstring(forwardtype);
|
|
|
|
if (strcasecmp(forwardstr, "first") == 0)
|
|
|
|
fwdpolicy = dns_fwdpolicy_first;
|
|
|
|
else if (strcasecmp(forwardstr, "only") == 0)
|
|
|
|
fwdpolicy = dns_fwdpolicy_only;
|
|
|
|
else
|
|
|
|
INSIST(0);
|
|
|
|
}
|
2000-08-24 22:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
result = dns_fwdtable_add(view->fwdtable, origin, &addresses,
|
|
|
|
fwdpolicy);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
|
|
|
while (!ISC_LIST_EMPTY(addresses)) {
|
|
|
|
sa = ISC_LIST_HEAD(addresses);
|
|
|
|
ISC_LIST_UNLINK(addresses, sa, link);
|
|
|
|
isc_mem_put(view->mctx, sa, sizeof(isc_sockaddr_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-04-06 17:31:33 +00:00
|
|
|
/*
|
2001-03-04 21:21:39 +00:00
|
|
|
* Create a new view and add it to the list.
|
2000-04-06 17:31:33 +00:00
|
|
|
*
|
2001-03-08 00:06:19 +00:00
|
|
|
* If 'vconfig' is NULL, create the default view.
|
2000-04-06 17:31:33 +00:00
|
|
|
*
|
2001-03-08 00:06:19 +00:00
|
|
|
* The view created is attached to '*viewp'.
|
2000-04-06 17:31:33 +00:00
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
create_view(cfg_obj_t *vconfig, dns_viewlist_t *viewlist, dns_view_t **viewp) {
|
2000-04-06 17:31:33 +00:00
|
|
|
isc_result_t result;
|
2000-06-01 18:49:22 +00:00
|
|
|
const char *viewname;
|
2000-04-06 17:31:33 +00:00
|
|
|
dns_rdataclass_t viewclass;
|
|
|
|
dns_view_t *view = NULL;
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
if (vconfig != NULL) {
|
|
|
|
cfg_obj_t *classobj = NULL;
|
|
|
|
|
|
|
|
viewname = cfg_obj_asstring(cfg_tuple_get(vconfig, "name"));
|
|
|
|
classobj = cfg_tuple_get(vconfig, "class");
|
|
|
|
result = ns_config_getclass(classobj, &viewclass);
|
2000-04-06 17:31:33 +00:00
|
|
|
} else {
|
|
|
|
viewname = "_default";
|
|
|
|
viewclass = dns_rdataclass_in;
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
result = dns_viewlist_find(viewlist, viewname, viewclass, &view);
|
|
|
|
if (result == ISC_R_SUCCESS)
|
|
|
|
return (ISC_R_EXISTS);
|
2000-04-06 17:31:33 +00:00
|
|
|
if (result != ISC_R_NOTFOUND)
|
|
|
|
return (result);
|
|
|
|
INSIST(view == NULL);
|
|
|
|
|
|
|
|
result = dns_view_create(ns_g_mctx, viewclass, viewname, &view);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-06 17:31:33 +00:00
|
|
|
ISC_LIST_APPEND(*viewlist, view, link);
|
|
|
|
dns_view_attach(view, viewp);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2000-01-21 19:24:01 +00:00
|
|
|
/*
|
2001-03-08 00:06:19 +00:00
|
|
|
* Configure or reconfigure a zone.
|
2000-01-21 19:24:01 +00:00
|
|
|
*/
|
1999-08-05 22:14:43 +00:00
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
|
|
|
|
isc_mem_t *mctx, dns_view_t *view,
|
|
|
|
ns_aclconfctx_t *aclconf)
|
1999-10-15 01:51:48 +00:00
|
|
|
{
|
2000-01-21 19:24:01 +00:00
|
|
|
dns_view_t *pview = NULL; /* Production view */
|
|
|
|
dns_zone_t *zone = NULL; /* New or reused zone */
|
2000-05-22 17:07:43 +00:00
|
|
|
dns_zone_t *dupzone = NULL;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *options = NULL;
|
|
|
|
cfg_obj_t *zoptions = NULL;
|
|
|
|
cfg_obj_t *typeobj = NULL;
|
|
|
|
cfg_obj_t *forwarders = NULL;
|
2001-03-09 19:07:30 +00:00
|
|
|
cfg_obj_t *forwardtype = NULL;
|
1999-10-15 01:51:48 +00:00
|
|
|
isc_result_t result;
|
2000-01-21 19:24:01 +00:00
|
|
|
isc_buffer_t buffer;
|
|
|
|
dns_fixedname_t fixorigin;
|
|
|
|
dns_name_t *origin;
|
2001-03-04 21:21:39 +00:00
|
|
|
const char *zname;
|
|
|
|
dns_rdataclass_t zclass;
|
|
|
|
const char *ztypestr;
|
|
|
|
|
|
|
|
options = NULL;
|
|
|
|
(void)cfg_map_get(config, "options", &options);
|
|
|
|
|
|
|
|
zoptions = cfg_tuple_get(zconfig, "options");
|
2000-01-27 01:00:16 +00:00
|
|
|
|
1999-08-05 22:14:43 +00:00
|
|
|
/*
|
2000-01-21 19:24:01 +00:00
|
|
|
* Get the zone origin as a dns_name_t.
|
1999-08-05 22:14:43 +00:00
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
zname = cfg_obj_asstring(cfg_tuple_get(zconfig, "name"));
|
|
|
|
isc_buffer_init(&buffer, zname, strlen(zname));
|
|
|
|
isc_buffer_add(&buffer, strlen(zname));
|
2000-01-21 19:24:01 +00:00
|
|
|
dns_fixedname_init(&fixorigin);
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_name_fromtext(dns_fixedname_name(&fixorigin),
|
|
|
|
&buffer, dns_rootname, ISC_FALSE, NULL));
|
2000-01-21 19:24:01 +00:00
|
|
|
origin = dns_fixedname_name(&fixorigin);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(ns_config_getclass(cfg_tuple_get(zconfig, "class"), &zclass));
|
|
|
|
if (zclass != view->rdclass) {
|
|
|
|
const char *vname = NULL;
|
|
|
|
if (vconfig != NULL)
|
|
|
|
vname = cfg_obj_asstring(cfg_tuple_get(vconfig,
|
|
|
|
"name"));
|
|
|
|
else
|
|
|
|
vname = "<default view>";
|
|
|
|
|
2000-04-06 17:31:33 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
2001-03-04 21:21:39 +00:00
|
|
|
"zone '%s': wrong class for view '%s'",
|
|
|
|
zname, vname);
|
2000-04-06 17:31:33 +00:00
|
|
|
result = ISC_R_FAILURE;
|
2000-01-21 19:24:01 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
(void)cfg_map_get(zoptions, "type", &typeobj);
|
|
|
|
if (typeobj == NULL) {
|
|
|
|
cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
|
|
|
|
"zone '%s' 'type' not specified", zname);
|
|
|
|
return (ISC_R_FAILURE);
|
|
|
|
}
|
|
|
|
ztypestr = cfg_obj_asstring(typeobj);
|
|
|
|
|
2000-01-27 01:57:08 +00:00
|
|
|
/*
|
|
|
|
* "hints zones" aren't zones. If we've got one,
|
|
|
|
* configure it and return.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
if (strcasecmp(ztypestr, "hint") == 0) {
|
|
|
|
cfg_obj_t *fileobj = NULL;
|
|
|
|
if (cfg_map_get(zoptions, "file", &fileobj) != ISC_R_SUCCESS) {
|
2000-01-27 01:57:08 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
|
|
|
"zone '%s': 'file' not specified",
|
2001-03-04 21:21:39 +00:00
|
|
|
zname);
|
2000-01-27 01:57:08 +00:00
|
|
|
result = ISC_R_FAILURE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (dns_name_equal(origin, dns_rootname)) {
|
2001-03-04 21:21:39 +00:00
|
|
|
result = configure_hints(view,
|
|
|
|
cfg_obj_asstring(fileobj));
|
2000-01-27 01:57:08 +00:00
|
|
|
} else {
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
|
|
|
"ignoring non-root hint zone '%s'",
|
2001-03-04 21:21:39 +00:00
|
|
|
zname);
|
2000-01-27 01:57:08 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
}
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-08-24 22:15:40 +00:00
|
|
|
* "forward zones" aren't zones either. Translate this syntax into
|
|
|
|
* the appropriate selective forwarding configuration and return.
|
2000-01-27 01:57:08 +00:00
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
if (strcasecmp(ztypestr, "forward") == 0) {
|
2001-03-09 19:07:30 +00:00
|
|
|
forwardtype = NULL;
|
2001-03-04 21:21:39 +00:00
|
|
|
forwarders = NULL;
|
|
|
|
|
2001-03-09 19:07:30 +00:00
|
|
|
(void)cfg_map_get(zoptions, "forward", &forwardtype);
|
|
|
|
(void)cfg_map_get(zoptions, "forwarders", &forwarders);
|
|
|
|
result = configure_forward(config, view, origin, forwarders,
|
|
|
|
forwardtype);
|
2000-01-27 01:57:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2000-01-21 19:24:01 +00:00
|
|
|
/*
|
|
|
|
* Check for duplicates in the new zone table.
|
|
|
|
*/
|
2000-05-22 17:07:43 +00:00
|
|
|
result = dns_view_findzone(view, origin, &dupzone);
|
2000-01-21 19:24:01 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
/*
|
|
|
|
* We already have this zone!
|
|
|
|
*/
|
2000-05-22 17:07:43 +00:00
|
|
|
dns_zone_detach(&dupzone);
|
2000-01-21 19:24:01 +00:00
|
|
|
result = ISC_R_EXISTS;
|
|
|
|
goto cleanup;
|
1999-10-15 01:51:48 +00:00
|
|
|
}
|
2000-05-22 17:07:43 +00:00
|
|
|
INSIST(dupzone == NULL);
|
1999-08-05 22:14:43 +00:00
|
|
|
|
1999-10-15 01:51:48 +00:00
|
|
|
/*
|
2000-01-21 19:24:01 +00:00
|
|
|
* See if we can reuse an existing zone. This is
|
|
|
|
* only possible if all of these are true:
|
|
|
|
* - The zone's view exists
|
|
|
|
* - A zone with the right name exists in the view
|
|
|
|
* - The zone is compatible with the config
|
2000-08-01 01:33:37 +00:00
|
|
|
* options (e.g., an existing master zone cannot
|
2000-01-21 19:24:01 +00:00
|
|
|
* be reused if the options specify a slave zone)
|
1999-10-15 01:51:48 +00:00
|
|
|
*/
|
2000-01-12 01:19:47 +00:00
|
|
|
result = dns_viewlist_find(&ns_g_server->viewlist,
|
|
|
|
view->name, view->rdclass,
|
1999-10-15 01:51:48 +00:00
|
|
|
&pview);
|
|
|
|
if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
2000-01-21 19:24:01 +00:00
|
|
|
if (pview != NULL)
|
|
|
|
result = dns_view_findzone(pview, origin, &zone);
|
|
|
|
if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
if (zone != NULL) {
|
2001-03-04 21:21:39 +00:00
|
|
|
if (! ns_zone_reusable(zone, zconfig))
|
2000-01-21 19:24:01 +00:00
|
|
|
dns_zone_detach(&zone);
|
|
|
|
}
|
1999-08-05 22:14:43 +00:00
|
|
|
|
2000-05-23 04:38:22 +00:00
|
|
|
if (zone != NULL) {
|
|
|
|
/*
|
|
|
|
* We found a reusable zone. Make it use the
|
|
|
|
* new view.
|
|
|
|
*/
|
|
|
|
dns_zone_setview(zone, view);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* We cannot reuse an existing zone, we have
|
|
|
|
* to create a new one.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(dns_zone_create(&zone, mctx));
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_zone_setorigin(zone, origin));
|
2000-05-19 02:34:23 +00:00
|
|
|
dns_zone_setview(zone, view);
|
2000-05-23 04:38:22 +00:00
|
|
|
CHECK(dns_zonemgr_managezone(ns_g_server->zonemgr, zone));
|
2000-01-21 19:24:01 +00:00
|
|
|
}
|
|
|
|
|
2000-10-18 22:13:48 +00:00
|
|
|
/*
|
2001-03-09 19:07:30 +00:00
|
|
|
* If the zone contains a 'forwarders' statement, configure
|
|
|
|
* selective forwarding.
|
2000-10-18 22:13:48 +00:00
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
forwarders = NULL;
|
2001-03-09 19:07:30 +00:00
|
|
|
if (cfg_map_get(zoptions, "forwarders", &forwarders) == ISC_R_SUCCESS)
|
|
|
|
{
|
|
|
|
forwardtype = NULL;
|
|
|
|
cfg_map_get(zoptions, "forward", &forwardtype);
|
|
|
|
CHECK(configure_forward(config, view, origin, forwarders,
|
|
|
|
forwardtype));
|
|
|
|
}
|
2000-10-18 22:13:48 +00:00
|
|
|
|
2000-01-21 19:24:01 +00:00
|
|
|
/*
|
|
|
|
* Configure the zone.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(ns_zone_configure(config, vconfig, zconfig, aclconf, zone));
|
1999-08-05 22:14:43 +00:00
|
|
|
|
2000-01-21 19:24:01 +00:00
|
|
|
/*
|
|
|
|
* Add the zone to its view in the new view list.
|
|
|
|
*/
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECK(dns_view_addzone(view, zone));
|
1999-08-05 22:14:43 +00:00
|
|
|
|
1999-10-14 01:37:00 +00:00
|
|
|
cleanup:
|
1999-10-15 01:51:48 +00:00
|
|
|
if (zone != NULL)
|
|
|
|
dns_zone_detach(&zone);
|
|
|
|
if (pview != NULL)
|
|
|
|
dns_view_detach(&pview);
|
1999-08-05 22:14:43 +00:00
|
|
|
|
|
|
|
return (result);
|
1999-05-03 19:56:23 +00:00
|
|
|
}
|
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
/*
|
|
|
|
* Configure a single server quota.
|
|
|
|
*/
|
2000-01-15 00:37:31 +00:00
|
|
|
static void
|
2001-03-04 21:21:39 +00:00
|
|
|
configure_server_quota(cfg_obj_t **maps, const char *name, isc_quota_t *quota)
|
2000-01-15 00:37:31 +00:00
|
|
|
{
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *obj = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
result = ns_config_get(maps, name, &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
quota->max = cfg_obj_asuint32(obj);
|
2000-01-15 00:37:31 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 01:30:16 +00:00
|
|
|
/*
|
2001-03-04 21:21:39 +00:00
|
|
|
* This function is called as soon as the 'directory' statement has been
|
|
|
|
* parsed. This can be extended to support other options if necessary.
|
2000-02-08 01:30:16 +00:00
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
directory_callback(const char *clausename, cfg_obj_t *obj, void *arg) {
|
2000-02-08 01:30:16 +00:00
|
|
|
isc_result_t result;
|
2001-03-04 21:21:39 +00:00
|
|
|
char *directory;
|
2000-02-08 01:30:16 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
REQUIRE(strcasecmp("directory", clausename) == 0);
|
|
|
|
|
|
|
|
UNUSED(arg);
|
2001-03-16 23:00:00 +00:00
|
|
|
UNUSED(clausename);
|
2000-02-08 01:30:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Change directory.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
directory = cfg_obj_asstring(obj);
|
2001-03-29 02:33:48 +00:00
|
|
|
|
|
|
|
if (!isc_file_isabsolute(directory) &&
|
|
|
|
!isc_file_iscurrentdir(directory))
|
|
|
|
cfg_obj_log(obj, ns_g_lctx, ISC_LOG_WARNING,
|
2001-03-29 04:25:59 +00:00
|
|
|
"option 'directory' contains relative path '%s'",
|
2001-03-29 02:33:48 +00:00
|
|
|
directory);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
result = isc_dir_chdir(directory);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
cfg_obj_log(obj, ns_g_lctx, ISC_LOG_ERROR,
|
2001-03-29 02:33:48 +00:00
|
|
|
"change directory to '%s' failed: %s",
|
|
|
|
directory, isc_result_totext(result));
|
2001-03-04 21:21:39 +00:00
|
|
|
return (result);
|
2000-02-08 01:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2000-08-01 01:33:37 +00:00
|
|
|
static void
|
2000-06-08 22:31:55 +00:00
|
|
|
scan_interfaces(ns_server_t *server, isc_boolean_t verbose) {
|
2001-03-26 21:33:07 +00:00
|
|
|
isc_boolean_t match_mapped = server->aclenv.match_mapped;
|
|
|
|
|
2000-06-08 22:31:55 +00:00
|
|
|
ns_interfacemgr_scan(server->interfacemgr, verbose);
|
2000-12-15 00:29:59 +00:00
|
|
|
/*
|
|
|
|
* Update the "localhost" and "localnets" ACLs to match the
|
|
|
|
* current set of network interfaces.
|
|
|
|
*/
|
2000-02-16 19:58:39 +00:00
|
|
|
dns_aclenv_copy(&server->aclenv,
|
|
|
|
ns_interfacemgr_getaclenv(server->interfacemgr));
|
2001-03-26 21:33:07 +00:00
|
|
|
|
|
|
|
server->aclenv.match_mapped = match_mapped;
|
2000-02-16 19:58:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This event callback is invoked to do periodic network
|
|
|
|
* interface scanning.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
interface_timer_tick(isc_task_t *task, isc_event_t *event) {
|
2001-02-14 03:54:53 +00:00
|
|
|
isc_result_t result;
|
2000-08-01 01:33:37 +00:00
|
|
|
ns_server_t *server = (ns_server_t *) event->ev_arg;
|
2001-02-14 03:54:53 +00:00
|
|
|
INSIST(task == server->task);
|
2000-02-16 19:58:39 +00:00
|
|
|
UNUSED(task);
|
|
|
|
isc_event_free(&event);
|
2001-02-14 03:54:53 +00:00
|
|
|
/*
|
|
|
|
* XXX should scan interfaces unlocked and get exclusive access
|
|
|
|
* only to replace ACLs.
|
|
|
|
*/
|
|
|
|
result = isc_task_beginexclusive(server->task);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2000-06-08 22:31:55 +00:00
|
|
|
scan_interfaces(server, ISC_FALSE);
|
2001-02-14 03:54:53 +00:00
|
|
|
isc_task_endexclusive(server->task);
|
2000-02-16 19:58:39 +00:00
|
|
|
}
|
|
|
|
|
2000-11-03 07:16:09 +00:00
|
|
|
static void
|
|
|
|
heartbeat_timer_tick(isc_task_t *task, isc_event_t *event) {
|
|
|
|
ns_server_t *server = (ns_server_t *) event->ev_arg;
|
|
|
|
dns_view_t *view;
|
|
|
|
|
|
|
|
UNUSED(task);
|
|
|
|
isc_event_free(&event);
|
|
|
|
view = ISC_LIST_HEAD(server->viewlist);
|
|
|
|
while (view != NULL) {
|
|
|
|
dns_view_dialup(view);
|
|
|
|
view = ISC_LIST_NEXT(view, link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-08 18:58:02 +00:00
|
|
|
static isc_result_t
|
2000-12-01 23:49:59 +00:00
|
|
|
setstatsfile(ns_server_t *server, const char *name) {
|
|
|
|
char *p;
|
2000-11-08 18:58:02 +00:00
|
|
|
|
2000-12-01 23:49:59 +00:00
|
|
|
REQUIRE(name != NULL);
|
2000-11-09 19:55:20 +00:00
|
|
|
|
2000-12-01 23:49:59 +00:00
|
|
|
p = isc_mem_strdup(server->mctx, name);
|
|
|
|
if (p == NULL)
|
|
|
|
return (ISC_R_NOMEMORY);
|
|
|
|
if (server->statsfile != NULL)
|
|
|
|
isc_mem_free(server->mctx, server->statsfile);
|
|
|
|
server->statsfile = p;
|
|
|
|
return (ISC_R_SUCCESS);
|
2000-11-08 18:58:02 +00:00
|
|
|
}
|
|
|
|
|
2000-12-12 21:33:21 +00:00
|
|
|
static isc_result_t
|
|
|
|
setdumpfile(ns_server_t *server, const char *name) {
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
REQUIRE(name != NULL);
|
|
|
|
|
|
|
|
p = isc_mem_strdup(server->mctx, name);
|
|
|
|
if (p == NULL)
|
|
|
|
return (ISC_R_NOMEMORY);
|
|
|
|
if (server->dumpfile != NULL)
|
|
|
|
isc_mem_free(server->mctx, server->dumpfile);
|
|
|
|
server->dumpfile = p;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2000-11-15 00:19:49 +00:00
|
|
|
static void
|
2001-03-04 21:21:39 +00:00
|
|
|
set_limit(cfg_obj_t **maps, const char *configname, const char *description,
|
|
|
|
isc_resource_t resourceid, isc_resourcevalue_t defaultvalue)
|
|
|
|
{
|
|
|
|
cfg_obj_t *obj = NULL;
|
|
|
|
char *resource;
|
2000-11-15 00:19:49 +00:00
|
|
|
isc_resourcevalue_t value;
|
|
|
|
isc_result_t result;
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
if (ns_config_get(maps, configname, &obj) != ISC_R_SUCCESS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cfg_obj_isstring(obj)) {
|
|
|
|
resource = cfg_obj_asstring(obj);
|
2001-03-05 17:20:48 +00:00
|
|
|
if (strcasecmp(resource, "unlimited") == 0)
|
2001-03-04 21:21:39 +00:00
|
|
|
value = ISC_RESOURCE_UNLIMITED;
|
2001-03-05 17:20:48 +00:00
|
|
|
else {
|
|
|
|
INSIST(strcasecmp(resource, "default") == 0);
|
|
|
|
value = defaultvalue;
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
} else
|
|
|
|
value = cfg_obj_asuint64(obj);
|
|
|
|
|
|
|
|
result = isc_resource_setlimit(resourceid, value);
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
|
|
|
result == ISC_R_SUCCESS ?
|
2001-03-26 23:02:26 +00:00
|
|
|
ISC_LOG_DEBUG(3) : ISC_LOG_WARNING,
|
2001-03-04 21:21:39 +00:00
|
|
|
"set maximum %s to %" ISC_PRINT_QUADFORMAT "d: %s",
|
|
|
|
description, value, isc_result_totext(result));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SETLIMIT(cfgvar, resource, description) \
|
|
|
|
set_limit(maps, cfgvar, description, isc_resource_ ## resource, \
|
|
|
|
ns_g_init ## resource)
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_limits(cfg_obj_t **maps) {
|
|
|
|
SETLIMIT("stacksize", stacksize, "stack size");
|
|
|
|
SETLIMIT("datasize", datasize, "data size");
|
|
|
|
SETLIMIT("coresize", coresize, "core size");
|
|
|
|
SETLIMIT("files", openfiles, "open files");
|
2000-11-15 00:19:49 +00:00
|
|
|
}
|
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
static isc_result_t
|
2000-01-29 01:38:09 +00:00
|
|
|
load_configuration(const char *filename, ns_server_t *server,
|
|
|
|
isc_boolean_t first_time)
|
|
|
|
{
|
1999-10-15 01:51:48 +00:00
|
|
|
isc_result_t result;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_parser_t *parser = NULL;
|
|
|
|
cfg_obj_t *config;
|
|
|
|
cfg_obj_t *options;
|
|
|
|
cfg_obj_t *views;
|
|
|
|
cfg_obj_t *obj;
|
|
|
|
cfg_obj_t *maps[3];
|
|
|
|
cfg_listelt_t *element;
|
2000-04-06 23:58:01 +00:00
|
|
|
dns_view_t *view = NULL;
|
2000-04-06 17:31:33 +00:00
|
|
|
dns_view_t *view_next;
|
2001-03-04 21:21:39 +00:00
|
|
|
dns_viewlist_t viewlist;
|
2000-01-21 23:55:12 +00:00
|
|
|
dns_viewlist_t tmpviewlist;
|
2000-11-27 19:42:38 +00:00
|
|
|
ns_aclconfctx_t aclconfctx;
|
2000-03-08 22:31:52 +00:00
|
|
|
dns_dispatch_t *dispatchv4 = NULL;
|
|
|
|
dns_dispatch_t *dispatchv6 = NULL;
|
2000-06-05 09:17:14 +00:00
|
|
|
isc_uint32_t interface_interval;
|
2000-11-03 07:16:09 +00:00
|
|
|
isc_uint32_t heartbeat_interval;
|
2000-06-05 19:10:13 +00:00
|
|
|
in_port_t listen_port;
|
2001-03-04 21:21:39 +00:00
|
|
|
int i;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-11-27 19:42:38 +00:00
|
|
|
ns_aclconfctx_init(&aclconfctx);
|
2001-03-04 21:21:39 +00:00
|
|
|
ISC_LIST_INIT(viewlist);
|
1999-08-05 22:14:43 +00:00
|
|
|
|
2001-02-14 03:54:53 +00:00
|
|
|
/* Ensure exclusive access to configuration data. */
|
|
|
|
result = isc_task_beginexclusive(server->task);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
/*
|
|
|
|
* Parse the global default pseudo-config file.
|
|
|
|
*/
|
|
|
|
if (first_time) {
|
|
|
|
CHECK(ns_config_parsedefaults(ns_g_parser, &ns_g_config));
|
|
|
|
RUNTIME_CHECK(cfg_map_get(ns_g_config, "options",
|
|
|
|
&ns_g_defaults) ==
|
|
|
|
ISC_R_SUCCESS);
|
|
|
|
}
|
1999-07-24 01:16:38 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
/*
|
|
|
|
* Parse the configuration file using the new config code.
|
|
|
|
*/
|
|
|
|
result = ISC_R_FAILURE;
|
|
|
|
config = NULL;
|
1999-09-24 01:42:22 +00:00
|
|
|
|
2000-01-21 19:24:01 +00:00
|
|
|
/*
|
2001-03-04 21:21:39 +00:00
|
|
|
* Unless this is lwresd with the -C option, parse the config file.
|
2000-01-21 19:24:01 +00:00
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
if (!(ns_g_lwresdonly && lwresd_g_useresolvconf)) {
|
2000-10-13 22:35:46 +00:00
|
|
|
isc_log_write(ns_g_lctx,
|
|
|
|
NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
|
|
|
ISC_LOG_INFO, "loading configuration from '%s'",
|
|
|
|
filename);
|
2001-04-19 23:38:32 +00:00
|
|
|
CHECK(cfg_parser_create(ns_g_mctx, ns_g_lctx, &parser));
|
|
|
|
cfg_parser_setcallback(parser, directory_callback, NULL);
|
2001-03-04 21:21:39 +00:00
|
|
|
result = cfg_parse_file(parser, filename, &cfg_type_namedconf,
|
|
|
|
&config);
|
2000-10-13 22:35:46 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is lwresd with the -C option, or lwresd with no -C or -c
|
|
|
|
* option where the above parsing failed, parse resolv.conf.
|
|
|
|
*/
|
|
|
|
if (ns_g_lwresdonly &&
|
|
|
|
(lwresd_g_useresolvconf ||
|
2001-04-19 23:38:32 +00:00
|
|
|
(!ns_g_conffileset && result == ISC_R_FILENOTFOUND)))
|
2000-11-01 20:59:22 +00:00
|
|
|
{
|
2000-10-13 22:35:46 +00:00
|
|
|
isc_log_write(ns_g_lctx,
|
|
|
|
NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
|
|
|
ISC_LOG_INFO, "loading configuration from '%s'",
|
|
|
|
lwresd_g_resolvconffile);
|
2001-04-19 23:38:32 +00:00
|
|
|
if (parser != NULL)
|
|
|
|
cfg_parser_destroy(&parser);
|
|
|
|
CHECK(cfg_parser_create(ns_g_mctx, ns_g_lctx, &parser));
|
2001-03-04 21:21:39 +00:00
|
|
|
result = ns_lwresd_parseeresolvconf(ns_g_mctx, parser,
|
|
|
|
&config);
|
2000-10-13 22:35:46 +00:00
|
|
|
}
|
2000-10-04 23:19:01 +00:00
|
|
|
CHECK(result);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
/*
|
|
|
|
* Check the validity of the configuration.
|
|
|
|
*/
|
2001-03-08 00:55:50 +00:00
|
|
|
CHECK(cfg_check_namedconf(config, ns_g_lctx, ns_g_mctx));
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in the maps array, used for resolving defaults.
|
|
|
|
*/
|
|
|
|
i = 0;
|
|
|
|
options = NULL;
|
|
|
|
result = cfg_map_get(config, "options", &options);
|
|
|
|
if (result == ISC_R_SUCCESS)
|
|
|
|
maps[i++] = options;
|
|
|
|
maps[i++] = ns_g_defaults;
|
|
|
|
maps[i++] = NULL;
|
|
|
|
|
2000-11-15 00:19:49 +00:00
|
|
|
/*
|
|
|
|
* Set process limits, which (usually) needs to be done as root.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
set_limits(maps);
|
2000-11-15 00:19:49 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
/*
|
|
|
|
* Configure various server options.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
configure_server_quota(maps, "transfers-out", &server->xfroutquota);
|
|
|
|
configure_server_quota(maps, "tcp-clients", &server->tcpquota);
|
|
|
|
configure_server_quota(maps, "recursive-clients",
|
|
|
|
&server->recursionquota);
|
|
|
|
|
|
|
|
CHECK(configure_view_acl(NULL, config, "blackhole", &aclconfctx,
|
|
|
|
ns_g_mctx, &server->blackholeacl));
|
2000-11-03 02:45:55 +00:00
|
|
|
if (server->blackholeacl != NULL)
|
|
|
|
dns_dispatchmgr_setblackhole(ns_g_dispatchmgr,
|
|
|
|
server->blackholeacl);
|
|
|
|
|
2001-03-26 23:03:05 +00:00
|
|
|
obj = NULL;
|
2001-03-26 21:33:07 +00:00
|
|
|
result = ns_config_get(maps, "match-mapped-addresses", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
server->aclenv.match_mapped = cfg_obj_asboolean(obj);
|
|
|
|
|
2000-02-25 00:52:11 +00:00
|
|
|
/*
|
|
|
|
* Configure the zone manager.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "transfers-in", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
dns_zonemgr_settransfersin(server->zonemgr, cfg_obj_asuint32(obj));
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "transfers-per-ns", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
dns_zonemgr_settransfersperns(server->zonemgr, cfg_obj_asuint32(obj));
|
2000-02-25 00:52:11 +00:00
|
|
|
|
2001-03-19 22:34:14 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "serial-query-rate", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
dns_zonemgr_setserialqueryrate(server->zonemgr, cfg_obj_asuint32(obj));
|
|
|
|
|
2000-06-05 19:10:13 +00:00
|
|
|
/*
|
|
|
|
* Determine which port to use for listening for incoming connections.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECKM(ns_config_getport(config, &listen_port), "port");
|
|
|
|
|
2000-01-13 23:32:41 +00:00
|
|
|
/*
|
|
|
|
* Configure the interface manager according to the "listen-on"
|
|
|
|
* statement.
|
|
|
|
*/
|
|
|
|
{
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *clistenon = NULL;
|
2000-01-13 23:32:41 +00:00
|
|
|
ns_listenlist_t *listenon = NULL;
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
clistenon = NULL;
|
2001-03-06 19:04:42 +00:00
|
|
|
/*
|
|
|
|
* Even though listen-on is present in the default
|
|
|
|
* configuration, we can't use it here, since it isn't
|
|
|
|
* used if we're in lwresd mode. This way is easier.
|
|
|
|
*/
|
|
|
|
if (options != NULL)
|
|
|
|
(void)cfg_map_get(options, "listen-on", &clistenon);
|
2000-01-13 23:32:41 +00:00
|
|
|
if (clistenon != NULL) {
|
|
|
|
result = ns_listenlist_fromconfig(clistenon,
|
2001-03-04 21:21:39 +00:00
|
|
|
config,
|
2000-01-13 23:32:41 +00:00
|
|
|
&aclconfctx,
|
2000-01-26 19:25:22 +00:00
|
|
|
ns_g_mctx,
|
|
|
|
&listenon);
|
2000-10-04 23:19:01 +00:00
|
|
|
} else if (!ns_g_lwresdonly) {
|
2000-07-10 11:35:02 +00:00
|
|
|
/*
|
|
|
|
* Not specified, use default.
|
|
|
|
*/
|
2000-06-05 19:10:13 +00:00
|
|
|
CHECK(ns_listenlist_default(ns_g_mctx, listen_port,
|
2000-06-23 01:08:29 +00:00
|
|
|
ISC_TRUE, &listenon));
|
2000-01-13 23:32:41 +00:00
|
|
|
}
|
2000-10-04 23:19:01 +00:00
|
|
|
if (listenon != NULL) {
|
|
|
|
ns_interfacemgr_setlistenon4(server->interfacemgr,
|
|
|
|
listenon);
|
|
|
|
ns_listenlist_detach(&listenon);
|
|
|
|
}
|
2000-01-13 23:32:41 +00:00
|
|
|
}
|
2000-06-05 19:10:13 +00:00
|
|
|
/*
|
|
|
|
* Ditto for IPv6.
|
|
|
|
*/
|
|
|
|
{
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *clistenon = NULL;
|
2000-06-06 18:53:02 +00:00
|
|
|
ns_listenlist_t *listenon = NULL;
|
|
|
|
|
2001-03-06 19:04:42 +00:00
|
|
|
if (options != NULL)
|
|
|
|
(void)cfg_map_get(options, "listen-on-v6", &clistenon);
|
2000-06-06 18:53:02 +00:00
|
|
|
if (clistenon != NULL) {
|
|
|
|
result = ns_listenlist_fromconfig(clistenon,
|
2001-03-04 21:21:39 +00:00
|
|
|
config,
|
2000-06-06 18:53:02 +00:00
|
|
|
&aclconfctx,
|
|
|
|
ns_g_mctx,
|
|
|
|
&listenon);
|
2000-10-04 23:19:01 +00:00
|
|
|
} else if (!ns_g_lwresdonly) {
|
2000-07-10 11:35:02 +00:00
|
|
|
/*
|
|
|
|
* Not specified, use default.
|
|
|
|
*/
|
2000-06-06 18:53:02 +00:00
|
|
|
CHECK(ns_listenlist_default(ns_g_mctx, listen_port,
|
2000-06-23 01:08:29 +00:00
|
|
|
ISC_FALSE, &listenon));
|
2000-06-06 18:53:02 +00:00
|
|
|
}
|
2000-10-04 23:19:01 +00:00
|
|
|
if (listenon != NULL) {
|
|
|
|
ns_interfacemgr_setlistenon6(server->interfacemgr,
|
|
|
|
listenon);
|
|
|
|
ns_listenlist_detach(&listenon);
|
|
|
|
}
|
2000-06-05 19:10:13 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-26 19:25:22 +00:00
|
|
|
/*
|
|
|
|
* Rescan the interface list to pick up changes in the
|
|
|
|
* listen-on option. It's important that we do this before we try
|
|
|
|
* to configure the query source, since the dispatcher we use might
|
|
|
|
* be shared with an interface.
|
|
|
|
*/
|
2000-06-08 22:31:55 +00:00
|
|
|
scan_interfaces(server, ISC_TRUE);
|
2000-02-16 19:58:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Arrange for further interface scanning to occur periodically
|
|
|
|
* as specified by the "interface-interval" option.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "interface-interval", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
interface_interval = cfg_obj_asuint32(obj);
|
2000-02-16 19:58:39 +00:00
|
|
|
if (interface_interval == 0) {
|
2000-04-06 17:31:33 +00:00
|
|
|
isc_timer_reset(server->interface_timer,
|
|
|
|
isc_timertype_inactive,
|
2000-02-16 19:58:39 +00:00
|
|
|
NULL, NULL, ISC_TRUE);
|
2001-01-29 07:08:41 +00:00
|
|
|
} else if (server->interface_interval != interface_interval) {
|
2000-02-16 19:58:39 +00:00
|
|
|
isc_interval_t interval;
|
|
|
|
isc_interval_set(&interval, interface_interval, 0);
|
|
|
|
isc_timer_reset(server->interface_timer, isc_timertype_ticker,
|
|
|
|
NULL, &interval, ISC_FALSE);
|
|
|
|
}
|
2001-01-29 07:08:41 +00:00
|
|
|
server->interface_interval = interface_interval;
|
2000-01-26 19:25:22 +00:00
|
|
|
|
2000-11-03 07:16:09 +00:00
|
|
|
/*
|
2000-11-03 17:54:52 +00:00
|
|
|
* Configure the dialup heartbeat timer.
|
2000-11-03 07:16:09 +00:00
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "heartbeat-interval", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
2001-03-05 17:20:48 +00:00
|
|
|
heartbeat_interval = cfg_obj_asuint32(obj);
|
2000-11-03 07:16:09 +00:00
|
|
|
if (heartbeat_interval == 0) {
|
|
|
|
isc_timer_reset(server->heartbeat_timer,
|
|
|
|
isc_timertype_inactive,
|
|
|
|
NULL, NULL, ISC_TRUE);
|
2001-01-29 07:08:41 +00:00
|
|
|
} else if (server->heartbeat_interval != heartbeat_interval) {
|
2000-11-03 07:16:09 +00:00
|
|
|
isc_interval_t interval;
|
|
|
|
isc_interval_set(&interval, heartbeat_interval, 0);
|
|
|
|
isc_timer_reset(server->heartbeat_timer, isc_timertype_ticker,
|
|
|
|
NULL, &interval, ISC_FALSE);
|
|
|
|
}
|
2001-01-29 07:08:41 +00:00
|
|
|
server->heartbeat_interval = heartbeat_interval;
|
2000-11-03 17:54:52 +00:00
|
|
|
|
1999-10-15 01:51:48 +00:00
|
|
|
/*
|
2000-04-08 00:49:19 +00:00
|
|
|
* Configure and freeze all explicit views. Explicit
|
|
|
|
* views that have zones were already created at parsing
|
2000-04-06 17:31:33 +00:00
|
|
|
* time, but views with no zones must be created here.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
views = NULL;
|
|
|
|
(void)cfg_map_get(config, "view", &views);
|
|
|
|
for (element = cfg_list_first(views);
|
|
|
|
element != NULL;
|
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
|
|
|
cfg_obj_t *vconfig;
|
|
|
|
|
|
|
|
view = NULL;
|
|
|
|
vconfig = cfg_listelt_value(element);
|
|
|
|
CHECK(create_view(vconfig, &viewlist, &view));
|
|
|
|
INSIST(view != NULL);
|
|
|
|
CHECK(configure_view(view, config, vconfig,
|
|
|
|
ns_g_mctx, &aclconfctx));
|
|
|
|
dns_view_freeze(view);
|
|
|
|
dns_view_detach(&view);
|
2000-04-06 17:31:33 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-06 17:31:33 +00:00
|
|
|
/*
|
2000-08-01 01:33:37 +00:00
|
|
|
* Make sure we have a default view if and only if there
|
|
|
|
* were no explicit views.
|
1999-10-15 01:51:48 +00:00
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
if (views == NULL) {
|
2000-04-08 00:49:19 +00:00
|
|
|
/*
|
|
|
|
* No explicit views; there ought to be a default view.
|
2000-12-01 08:58:10 +00:00
|
|
|
* There may already be one created as a side effect
|
2000-04-08 00:49:19 +00:00
|
|
|
* of zone statements, or we may have to create one.
|
|
|
|
* In either case, we need to configure and freeze it.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECK(create_view(NULL, &viewlist, &view));
|
|
|
|
CHECK(configure_view(view, config, NULL, ns_g_mctx,
|
|
|
|
&aclconfctx));
|
2000-04-08 00:49:19 +00:00
|
|
|
dns_view_freeze(view);
|
|
|
|
dns_view_detach(&view);
|
2000-01-21 19:24:01 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-10-15 01:51:48 +00:00
|
|
|
/*
|
2000-08-02 18:13:08 +00:00
|
|
|
* Create (or recreate) the internal _bind view.
|
1999-10-15 01:51:48 +00:00
|
|
|
*/
|
2000-08-02 18:13:08 +00:00
|
|
|
CHECK(create_bind_view(&view));
|
2001-03-04 21:21:39 +00:00
|
|
|
ISC_LIST_APPEND(viewlist, view, link);
|
|
|
|
CHECK(create_version_zone(maps, server->zonemgr, view));
|
|
|
|
CHECK(create_authors_zone(options, server->zonemgr, view));
|
2000-08-02 18:13:08 +00:00
|
|
|
dns_view_freeze(view);
|
1999-12-08 21:27:08 +00:00
|
|
|
view = NULL;
|
1999-01-31 12:31:31 +00:00
|
|
|
|
1999-10-15 01:51:48 +00:00
|
|
|
/*
|
2000-01-21 23:55:12 +00:00
|
|
|
* Swap our new view list with the production one.
|
1999-10-15 01:51:48 +00:00
|
|
|
*/
|
2000-01-21 23:55:12 +00:00
|
|
|
tmpviewlist = server->viewlist;
|
2001-03-04 21:21:39 +00:00
|
|
|
server->viewlist = viewlist;
|
|
|
|
viewlist = tmpviewlist;
|
1999-10-15 01:51:48 +00:00
|
|
|
|
|
|
|
/*
|
2000-01-25 19:05:46 +00:00
|
|
|
* Load the TKEY information from the configuration.
|
1999-10-15 01:51:48 +00:00
|
|
|
*/
|
2001-03-06 19:04:42 +00:00
|
|
|
if (options != NULL) {
|
2000-06-09 22:33:52 +00:00
|
|
|
dns_tkeyctx_t *t = NULL;
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECKM(ns_tkeyctx_fromconfig(options, ns_g_mctx, ns_g_entropy,
|
|
|
|
&t),
|
2000-01-25 19:05:46 +00:00
|
|
|
"configuring TKEY");
|
|
|
|
if (server->tkeyctx != NULL)
|
|
|
|
dns_tkeyctx_destroy(&server->tkeyctx);
|
|
|
|
server->tkeyctx = t;
|
|
|
|
}
|
2000-01-29 01:38:09 +00:00
|
|
|
|
2000-07-10 11:35:02 +00:00
|
|
|
/*
|
2001-03-27 00:44:59 +00:00
|
|
|
* Bind the control port(s).
|
2000-07-10 11:35:02 +00:00
|
|
|
*/
|
2001-05-08 03:42:34 +00:00
|
|
|
CHECKM(ns_controls_configure(ns_g_server->controls, config,
|
|
|
|
&aclconfctx),
|
2000-07-10 11:35:02 +00:00
|
|
|
"binding control channel(s)");
|
|
|
|
|
2000-10-04 23:19:01 +00:00
|
|
|
/*
|
|
|
|
* Bind the lwresd port(s).
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECKM(ns_lwresd_configure(ns_g_mctx, config),
|
2000-10-04 23:19:01 +00:00
|
|
|
"binding lightweight resolver ports");
|
|
|
|
|
2001-01-11 23:46:12 +00:00
|
|
|
/*
|
|
|
|
* Open the source of entropy.
|
|
|
|
*/
|
2001-01-12 00:37:11 +00:00
|
|
|
if (first_time) {
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "random-device", &obj);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
2001-01-11 23:46:12 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_INFO,
|
2001-01-12 00:37:11 +00:00
|
|
|
"no source of entropy found");
|
2001-03-04 21:21:39 +00:00
|
|
|
} else {
|
|
|
|
const char *randomdev = cfg_obj_asstring(obj);
|
2001-01-12 00:37:11 +00:00
|
|
|
result = isc_entropy_createfilesource(ns_g_entropy,
|
|
|
|
randomdev);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
isc_log_write(ns_g_lctx,
|
|
|
|
NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER,
|
|
|
|
ISC_LOG_INFO,
|
|
|
|
"could not open entropy source "
|
|
|
|
"%s: %s",
|
|
|
|
randomdev,
|
|
|
|
isc_result_totext(result));
|
|
|
|
}
|
2001-01-11 23:46:12 +00:00
|
|
|
}
|
|
|
|
|
2000-04-18 22:17:27 +00:00
|
|
|
/*
|
|
|
|
* Relinquish root privileges.
|
|
|
|
*/
|
|
|
|
if (first_time)
|
2000-07-01 00:48:06 +00:00
|
|
|
ns_os_changeuser();
|
2000-04-18 22:17:27 +00:00
|
|
|
|
2000-02-28 18:38:44 +00:00
|
|
|
/*
|
|
|
|
* Configure the logging system.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
|
|
|
* Do this after changing UID to make sure that any log
|
2000-04-18 22:17:27 +00:00
|
|
|
* files specified in named.conf get created by the
|
|
|
|
* unprivileged user, not root.
|
2000-02-28 18:38:44 +00:00
|
|
|
*/
|
2000-02-28 22:17:59 +00:00
|
|
|
if (ns_g_logstderr) {
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_INFO,
|
2000-05-02 18:45:08 +00:00
|
|
|
"ignoring config file logging "
|
|
|
|
"statement due to -g option");
|
2000-02-28 22:17:59 +00:00
|
|
|
} else {
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *logobj = NULL;
|
2000-02-28 18:38:44 +00:00
|
|
|
isc_logconfig_t *logc = NULL;
|
|
|
|
|
2000-03-01 00:40:54 +00:00
|
|
|
CHECKM(isc_logconfig_create(ns_g_lctx, &logc),
|
|
|
|
"creating new logging configuration");
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
logobj = NULL;
|
|
|
|
(void)cfg_map_get(config, "logging", &logobj);
|
|
|
|
if (logobj != NULL) {
|
|
|
|
CHECKM(ns_log_configure(logc, logobj),
|
2000-03-01 00:40:54 +00:00
|
|
|
"configuring logging");
|
2000-04-28 18:53:45 +00:00
|
|
|
} else {
|
|
|
|
CHECKM(ns_log_setdefaultchannels(logc),
|
|
|
|
"setting up default logging channels");
|
2001-05-28 05:17:05 +00:00
|
|
|
CHECKM(ns_log_setunmatchedcategory(logc),
|
|
|
|
"setting up default 'category unmatched'");
|
2000-04-28 18:53:45 +00:00
|
|
|
CHECKM(ns_log_setdefaultcategory(logc),
|
|
|
|
"setting up default 'category default'");
|
|
|
|
}
|
2000-02-28 18:38:44 +00:00
|
|
|
|
|
|
|
result = isc_logconfig_use(ns_g_lctx, logc);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
isc_logconfig_destroy(&logc);
|
2000-04-13 22:41:23 +00:00
|
|
|
CHECKM(result, "installing logging configuration");
|
2000-02-28 18:38:44 +00:00
|
|
|
}
|
|
|
|
|
2000-06-01 21:45:45 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_DEBUG(1),
|
|
|
|
"now using logging configuration from "
|
|
|
|
"config file");
|
|
|
|
}
|
2000-05-02 18:45:08 +00:00
|
|
|
|
2000-12-01 02:01:26 +00:00
|
|
|
/*
|
|
|
|
* Set the default value of the query logging flag depending
|
|
|
|
* whether a "queries" category has been defined. This is
|
|
|
|
* a disgusting hack, but we need to do this for BIND 8
|
|
|
|
* compatibility.
|
|
|
|
*/
|
|
|
|
if (first_time) {
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *logobj = NULL;
|
|
|
|
cfg_obj_t *categories = NULL;
|
|
|
|
(void)cfg_map_get(config, "logging", &logobj);
|
|
|
|
if (logobj != NULL)
|
|
|
|
(void)cfg_map_get(logobj, "category", &categories);
|
|
|
|
if (categories != NULL) {
|
|
|
|
cfg_listelt_t *element;
|
|
|
|
for (element = cfg_list_first(categories);
|
|
|
|
element != NULL;
|
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
|
|
|
cfg_obj_t *catobj;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
obj = cfg_listelt_value(element);
|
|
|
|
catobj = cfg_tuple_get(obj, "name");
|
|
|
|
str = cfg_obj_asstring(catobj);
|
|
|
|
if (strcasecmp(str, "queries") == 0)
|
|
|
|
server->log_queries = ISC_TRUE;
|
|
|
|
}
|
2000-12-01 02:01:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
if (ns_config_get(maps, "pid-file", &obj) == ISC_R_SUCCESS)
|
|
|
|
ns_os_writepidfile(cfg_obj_asstring(obj));
|
2000-10-04 23:19:01 +00:00
|
|
|
else if (ns_g_lwresdonly)
|
|
|
|
ns_os_writepidfile(lwresd_g_defaultpidfile);
|
2000-06-01 18:49:22 +00:00
|
|
|
else
|
|
|
|
ns_os_writepidfile(ns_g_defaultpidfile);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "statistics-file", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
CHECKM(setstatsfile(server, cfg_obj_asstring(obj)), "strdup");
|
2000-11-07 23:49:42 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = ns_config_get(maps, "dump-file", &obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
CHECKM(setdumpfile(server, cfg_obj_asstring(obj)), "strdup");
|
2000-12-12 21:33:21 +00:00
|
|
|
|
2000-11-13 23:35:24 +00:00
|
|
|
cleanup:
|
2000-11-27 19:42:38 +00:00
|
|
|
ns_aclconfctx_destroy(&aclconfctx);
|
1999-12-17 00:19:29 +00:00
|
|
|
|
2001-03-15 19:39:50 +00:00
|
|
|
if (parser != NULL) {
|
|
|
|
if (config != NULL)
|
|
|
|
cfg_obj_destroy(parser, &config);
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_parser_destroy(&parser);
|
2001-03-15 19:39:50 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-11-13 23:35:24 +00:00
|
|
|
if (view != NULL)
|
|
|
|
dns_view_detach(&view);
|
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
/*
|
|
|
|
* This cleans up either the old production view list
|
|
|
|
* or our temporary list depending on whether they
|
|
|
|
* were swapped above or not.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
for (view = ISC_LIST_HEAD(viewlist);
|
2000-01-21 23:55:12 +00:00
|
|
|
view != NULL;
|
|
|
|
view = view_next) {
|
|
|
|
view_next = ISC_LIST_NEXT(view, link);
|
2001-03-04 21:21:39 +00:00
|
|
|
ISC_LIST_UNLINK(viewlist, view, link);
|
2000-01-21 23:55:12 +00:00
|
|
|
dns_view_detach(&view);
|
2000-01-27 01:00:16 +00:00
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
}
|
2000-01-27 01:00:16 +00:00
|
|
|
|
2000-03-08 22:31:52 +00:00
|
|
|
if (dispatchv4 != NULL)
|
|
|
|
dns_dispatch_detach(&dispatchv4);
|
|
|
|
if (dispatchv6 != NULL)
|
|
|
|
dns_dispatch_detach(&dispatchv6);
|
|
|
|
|
2001-02-14 03:54:53 +00:00
|
|
|
/* Relinquish exclusive access to configuration data. */
|
|
|
|
isc_task_endexclusive(server->task);
|
2000-08-24 19:02:06 +00:00
|
|
|
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
|
|
|
ISC_LOG_DEBUG(1), "load_configuration: %s",
|
|
|
|
isc_result_totext(result));
|
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
return (result);
|
1999-07-24 01:16:38 +00:00
|
|
|
}
|
1999-01-19 06:32:53 +00:00
|
|
|
|
2000-01-22 01:36:34 +00:00
|
|
|
static isc_result_t
|
|
|
|
load_zones(ns_server_t *server, isc_boolean_t stop) {
|
|
|
|
isc_result_t result;
|
|
|
|
dns_view_t *view;
|
2000-01-27 01:00:16 +00:00
|
|
|
|
2001-02-14 03:54:53 +00:00
|
|
|
result = isc_task_beginexclusive(server->task);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-22 01:36:34 +00:00
|
|
|
/*
|
|
|
|
* Load zone data from disk.
|
|
|
|
*/
|
|
|
|
for (view = ISC_LIST_HEAD(server->viewlist);
|
|
|
|
view != NULL;
|
|
|
|
view = ISC_LIST_NEXT(view, link))
|
|
|
|
{
|
|
|
|
CHECK(dns_view_load(view, stop));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Force zone maintenance. Do this after loading
|
|
|
|
* so that we know when we need to force AXFR of
|
|
|
|
* slave zones whose master files are missing.
|
|
|
|
*/
|
|
|
|
CHECK(dns_zonemgr_forcemaint(server->zonemgr));
|
|
|
|
cleanup:
|
2001-02-14 03:54:53 +00:00
|
|
|
isc_task_endexclusive(server->task);
|
2000-01-22 01:36:34 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2001-05-07 23:34:24 +00:00
|
|
|
static isc_result_t
|
|
|
|
load_new_zones(ns_server_t *server, isc_boolean_t stop) {
|
|
|
|
isc_result_t result;
|
|
|
|
dns_view_t *view;
|
|
|
|
|
|
|
|
result = isc_task_beginexclusive(server->task);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load zone data from disk.
|
|
|
|
*/
|
|
|
|
for (view = ISC_LIST_HEAD(server->viewlist);
|
|
|
|
view != NULL;
|
|
|
|
view = ISC_LIST_NEXT(view, link))
|
|
|
|
{
|
|
|
|
CHECK(dns_view_loadnew(view, stop));
|
|
|
|
}
|
|
|
|
cleanup:
|
|
|
|
isc_task_endexclusive(server->task);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
1999-07-24 01:16:38 +00:00
|
|
|
static void
|
|
|
|
run_server(isc_task_t *task, isc_event_t *event) {
|
2000-01-18 18:09:47 +00:00
|
|
|
isc_result_t result;
|
2000-04-17 19:22:44 +00:00
|
|
|
ns_server_t *server = (ns_server_t *)event->ev_arg;
|
2000-01-29 01:38:09 +00:00
|
|
|
|
2000-02-16 18:21:17 +00:00
|
|
|
UNUSED(task);
|
1999-10-15 01:51:48 +00:00
|
|
|
|
1999-10-22 19:35:19 +00:00
|
|
|
isc_event_free(&event);
|
1999-01-19 06:32:53 +00:00
|
|
|
|
2000-06-21 22:12:02 +00:00
|
|
|
CHECKFATAL(dns_dispatchmgr_create(ns_g_mctx, ns_g_entropy,
|
|
|
|
&ns_g_dispatchmgr),
|
|
|
|
"creating dispatch manager");
|
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECKFATAL(ns_interfacemgr_create(ns_g_mctx, ns_g_taskmgr,
|
2000-05-10 21:34:50 +00:00
|
|
|
ns_g_socketmgr, ns_g_dispatchmgr,
|
2000-01-21 23:55:12 +00:00
|
|
|
&server->interfacemgr),
|
|
|
|
"creating interface manager");
|
2000-01-18 18:09:47 +00:00
|
|
|
|
2000-02-16 19:58:39 +00:00
|
|
|
CHECKFATAL(isc_timer_create(ns_g_timermgr, isc_timertype_inactive,
|
|
|
|
NULL, NULL, server->task,
|
|
|
|
interface_timer_tick,
|
|
|
|
server, &server->interface_timer),
|
|
|
|
"creating interface timer");
|
|
|
|
|
2000-11-03 07:16:09 +00:00
|
|
|
CHECKFATAL(isc_timer_create(ns_g_timermgr, isc_timertype_inactive,
|
|
|
|
NULL, NULL, server->task,
|
|
|
|
heartbeat_timer_tick,
|
|
|
|
server, &server->heartbeat_timer),
|
|
|
|
"creating heartbeat timer");
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
CHECKFATAL(cfg_parser_create(ns_g_mctx, NULL, &ns_g_parser),
|
|
|
|
"creating default configuration parser");
|
|
|
|
|
2000-10-04 23:19:01 +00:00
|
|
|
if (ns_g_lwresdonly)
|
|
|
|
CHECKFATAL(load_configuration(lwresd_g_conffile, server,
|
|
|
|
ISC_TRUE),
|
|
|
|
"loading configuration");
|
|
|
|
else
|
|
|
|
CHECKFATAL(load_configuration(ns_g_conffile, server, ISC_TRUE),
|
|
|
|
"loading configuration");
|
1999-10-15 01:51:48 +00:00
|
|
|
|
2000-10-03 23:56:26 +00:00
|
|
|
CHECKFATAL(load_zones(server, ISC_FALSE),
|
2000-01-22 01:36:34 +00:00
|
|
|
"loading zones");
|
|
|
|
|
1999-10-22 19:35:19 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
1999-10-23 00:02:23 +00:00
|
|
|
ISC_LOG_INFO, "running");
|
1999-07-24 01:16:38 +00:00
|
|
|
}
|
1999-01-28 05:52:20 +00:00
|
|
|
|
2000-10-05 10:42:40 +00:00
|
|
|
void
|
2000-10-05 23:48:49 +00:00
|
|
|
ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush) {
|
|
|
|
|
|
|
|
REQUIRE(NS_SERVER_VALID(server));
|
|
|
|
|
|
|
|
server->flushonshutdown = flush;
|
2000-10-05 10:42:40 +00:00
|
|
|
}
|
|
|
|
|
1999-07-24 01:16:38 +00:00
|
|
|
static void
|
|
|
|
shutdown_server(isc_task_t *task, isc_event_t *event) {
|
2001-02-14 03:54:53 +00:00
|
|
|
isc_result_t result;
|
1999-08-05 22:14:43 +00:00
|
|
|
dns_view_t *view, *view_next;
|
2000-04-17 19:22:44 +00:00
|
|
|
ns_server_t *server = (ns_server_t *)event->ev_arg;
|
2000-10-05 10:42:40 +00:00
|
|
|
isc_boolean_t flush = server->flushonshutdown;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-27 01:00:16 +00:00
|
|
|
UNUSED(task);
|
2001-02-14 03:54:53 +00:00
|
|
|
INSIST(task == server->task);
|
2000-01-27 01:00:16 +00:00
|
|
|
|
2001-02-14 03:54:53 +00:00
|
|
|
result = isc_task_beginexclusive(server->task);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
1999-08-05 22:14:43 +00:00
|
|
|
|
1999-10-22 19:35:19 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
2000-10-05 10:42:40 +00:00
|
|
|
ISC_LOG_INFO, "shutting down%s",
|
|
|
|
flush ? ": flushing changes" : "");
|
1999-08-05 22:14:43 +00:00
|
|
|
|
2001-05-08 03:42:34 +00:00
|
|
|
ns_controls_shutdown(server->controls);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_destroy(ns_g_parser, &ns_g_config);
|
|
|
|
cfg_parser_destroy(&ns_g_parser);
|
|
|
|
|
1999-12-22 18:45:56 +00:00
|
|
|
for (view = ISC_LIST_HEAD(server->viewlist);
|
1999-08-05 22:14:43 +00:00
|
|
|
view != NULL;
|
|
|
|
view = view_next) {
|
|
|
|
view_next = ISC_LIST_NEXT(view, link);
|
1999-12-22 18:45:56 +00:00
|
|
|
ISC_LIST_UNLINK(server->viewlist, view, link);
|
2000-10-05 10:42:40 +00:00
|
|
|
if (flush)
|
|
|
|
dns_view_flushanddetach(&view);
|
|
|
|
else
|
|
|
|
dns_view_detach(&view);
|
1999-08-05 22:14:43 +00:00
|
|
|
}
|
1999-10-15 01:51:48 +00:00
|
|
|
|
2000-02-16 19:58:39 +00:00
|
|
|
isc_timer_detach(&server->interface_timer);
|
2000-11-03 07:16:09 +00:00
|
|
|
isc_timer_detach(&server->heartbeat_timer);
|
2000-05-17 19:45:36 +00:00
|
|
|
|
2000-01-12 01:17:34 +00:00
|
|
|
ns_interfacemgr_shutdown(server->interfacemgr);
|
2000-08-01 01:33:37 +00:00
|
|
|
ns_interfacemgr_detach(&server->interfacemgr);
|
2000-05-17 19:45:36 +00:00
|
|
|
|
2000-06-21 22:12:02 +00:00
|
|
|
dns_dispatchmgr_destroy(&ns_g_dispatchmgr);
|
|
|
|
|
2000-01-19 22:02:18 +00:00
|
|
|
dns_zonemgr_shutdown(server->zonemgr);
|
Merge the mlg-20000518 branch onto the mainline. Change summary:
dns_dispatch_create() no longer exists. dns_dispatch_createtcp()
and dns_dispatch_getudp() are the replacements. _createtcp() takes
a bound, connected TCP socket, while _getudp() will search for
a sharable UDP socket, and if found, attach to it and return a
pointer to it. If one is not found, it will create a udp socket,
bind it to a supplied local address, and create a new dispatcher
around it.
dns_dispatch_remove{request,response}() no longer take the dispatch
as an argument.
query-source can now be set per view.
The dispatch manager holds onto three memory pools, one for
allocating dispatchers from, one for events, and one for
requests/replies. The free list on these pools is hard-coded,
but set to 1024. This keeps us from having to dig into the
isc_mem_t the pools draw from as often.
dns_resolver_create() and dns_view_createresolver() require that
valid dispatchers be passed in; dispatchers are no longer created
for the caller.
2000-05-19 21:46:46 +00:00
|
|
|
|
2000-11-03 02:45:55 +00:00
|
|
|
if (server->blackholeacl != NULL)
|
|
|
|
dns_acl_detach(&server->blackholeacl);
|
|
|
|
|
2001-02-14 03:54:53 +00:00
|
|
|
isc_task_endexclusive(server->task);
|
|
|
|
|
2000-01-13 22:07:24 +00:00
|
|
|
isc_task_detach(&server->task);
|
2000-01-27 01:00:16 +00:00
|
|
|
|
1999-07-24 01:16:38 +00:00
|
|
|
isc_event_free(&event);
|
|
|
|
}
|
1999-01-19 06:32:53 +00:00
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
void
|
1999-12-16 23:11:07 +00:00
|
|
|
ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) {
|
1999-12-22 18:45:56 +00:00
|
|
|
isc_result_t result;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
ns_server_t *server = isc_mem_get(mctx, sizeof(*server));
|
|
|
|
if (server == NULL)
|
2000-01-21 23:55:12 +00:00
|
|
|
fatal("allocating server object", ISC_R_NOMEMORY);
|
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
server->mctx = mctx;
|
2000-01-13 22:07:24 +00:00
|
|
|
server->task = NULL;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-12-22 18:45:56 +00:00
|
|
|
/* Initialize configuration data with default values. */
|
2000-01-27 01:00:16 +00:00
|
|
|
|
2000-01-13 21:17:08 +00:00
|
|
|
result = isc_quota_init(&server->xfroutquota, 10);
|
2000-08-01 01:33:37 +00:00
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2000-01-13 21:17:08 +00:00
|
|
|
result = isc_quota_init(&server->tcpquota, 10);
|
2000-08-01 01:33:37 +00:00
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2000-01-13 21:17:08 +00:00
|
|
|
result = isc_quota_init(&server->recursionquota, 100);
|
2000-08-01 01:33:37 +00:00
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2000-02-09 22:59:40 +00:00
|
|
|
|
|
|
|
result = dns_aclenv_init(mctx, &server->aclenv);
|
2000-03-20 21:06:27 +00:00
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-12-22 18:45:56 +00:00
|
|
|
/* Initialize server data structures. */
|
2000-01-18 18:09:47 +00:00
|
|
|
server->zonemgr = NULL;
|
|
|
|
server->interfacemgr = NULL;
|
1999-12-22 18:45:56 +00:00
|
|
|
ISC_LIST_INIT(server->viewlist);
|
2000-04-06 17:31:33 +00:00
|
|
|
server->in_roothints = NULL;
|
2000-11-03 02:45:55 +00:00
|
|
|
server->blackholeacl = NULL;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-27 01:57:08 +00:00
|
|
|
CHECKFATAL(dns_rootns_create(mctx, dns_rdataclass_in, NULL,
|
2000-04-06 17:31:33 +00:00
|
|
|
&server->in_roothints),
|
2000-01-21 23:55:12 +00:00
|
|
|
"setting up root hints");
|
2000-01-24 22:21:47 +00:00
|
|
|
|
|
|
|
CHECKFATAL(isc_mutex_init(&server->reload_event_lock),
|
|
|
|
"initializing reload event lock");
|
|
|
|
server->reload_event =
|
|
|
|
isc_event_allocate(ns_g_mctx, server,
|
|
|
|
NS_EVENT_RELOAD,
|
|
|
|
ns_server_reload,
|
|
|
|
server,
|
|
|
|
sizeof(isc_event_t));
|
|
|
|
CHECKFATAL(server->reload_event == NULL ?
|
|
|
|
ISC_R_NOMEMORY : ISC_R_SUCCESS,
|
|
|
|
"allocating reload event");
|
2000-01-25 19:05:46 +00:00
|
|
|
|
2000-08-08 18:15:18 +00:00
|
|
|
CHECKFATAL(dst_lib_init(ns_g_mctx, ns_g_entropy, ISC_ENTROPY_GOODONLY),
|
2000-06-09 22:33:52 +00:00
|
|
|
"initializing DST");
|
2000-06-07 01:44:33 +00:00
|
|
|
|
2000-01-25 19:05:46 +00:00
|
|
|
server->tkeyctx = NULL;
|
2000-06-21 22:12:02 +00:00
|
|
|
CHECKFATAL(dns_tkeyctx_create(ns_g_mctx, ns_g_entropy,
|
2000-06-09 22:33:52 +00:00
|
|
|
&server->tkeyctx),
|
2000-01-25 19:05:46 +00:00
|
|
|
"creating TKEY context");
|
|
|
|
|
2000-01-13 22:07:24 +00:00
|
|
|
/*
|
|
|
|
* Setup the server task, which is responsible for coordinating
|
|
|
|
* startup and shutdown of the server.
|
|
|
|
*/
|
2000-04-12 01:38:26 +00:00
|
|
|
CHECKFATAL(isc_task_create(ns_g_taskmgr, 0, &server->task),
|
2000-01-21 23:55:12 +00:00
|
|
|
"creating server task");
|
2000-01-25 19:31:23 +00:00
|
|
|
isc_task_setname(server->task, "server", server);
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECKFATAL(isc_task_onshutdown(server->task, shutdown_server, server),
|
|
|
|
"isc_task_onshutdown");
|
|
|
|
CHECKFATAL(isc_app_onrun(ns_g_mctx, server->task, run_server, server),
|
|
|
|
"isc_app_onrun");
|
|
|
|
|
2000-02-16 19:58:39 +00:00
|
|
|
server->interface_timer = NULL;
|
2000-11-03 07:16:09 +00:00
|
|
|
server->heartbeat_timer = NULL;
|
2001-01-29 07:08:41 +00:00
|
|
|
|
|
|
|
server->interface_interval = 0;
|
2001-01-29 17:25:12 +00:00
|
|
|
server->heartbeat_interval = 0;
|
2000-09-06 20:52:05 +00:00
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
CHECKFATAL(dns_zonemgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
|
|
|
|
ns_g_socketmgr, &server->zonemgr),
|
|
|
|
"dns_zonemgr_create");
|
2000-01-19 22:02:18 +00:00
|
|
|
|
2000-12-01 23:49:59 +00:00
|
|
|
server->statsfile = isc_mem_strdup(server->mctx, "named.stats");
|
|
|
|
CHECKFATAL(server->statsfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS,
|
|
|
|
"isc_mem_strdup");
|
|
|
|
server->querystats = NULL;
|
|
|
|
CHECKFATAL(dns_stats_alloccounters(ns_g_mctx, &server->querystats),
|
|
|
|
"dns_stats_alloccounters");
|
2000-11-28 19:58:14 +00:00
|
|
|
|
2001-03-27 18:17:09 +00:00
|
|
|
server->dumpfile = isc_mem_strdup(server->mctx, "named_dump.db");
|
2000-12-12 21:33:21 +00:00
|
|
|
CHECKFATAL(server->dumpfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS,
|
|
|
|
"isc_mem_strdup");
|
|
|
|
|
2000-10-05 10:42:40 +00:00
|
|
|
server->flushonshutdown = ISC_FALSE;
|
2000-11-30 00:25:49 +00:00
|
|
|
server->log_queries = ISC_FALSE;
|
|
|
|
|
2001-05-08 03:42:34 +00:00
|
|
|
server->controls = NULL;
|
|
|
|
CHECKFATAL(ns_controls_create(server, &server->controls),
|
|
|
|
"ns_controls_create");
|
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
server->magic = NS_SERVER_MAGIC;
|
|
|
|
*serverp = server;
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
void
|
|
|
|
ns_server_destroy(ns_server_t **serverp) {
|
|
|
|
ns_server_t *server = *serverp;
|
|
|
|
REQUIRE(NS_SERVER_VALID(server));
|
|
|
|
|
2001-05-08 03:42:34 +00:00
|
|
|
ns_controls_destroy(&server->controls);
|
|
|
|
|
2000-12-01 23:49:59 +00:00
|
|
|
dns_stats_freecounters(server->mctx, &server->querystats);
|
|
|
|
isc_mem_free(server->mctx, server->statsfile);
|
2000-11-08 18:58:02 +00:00
|
|
|
|
2000-12-12 21:33:21 +00:00
|
|
|
isc_mem_free(server->mctx, server->dumpfile);
|
|
|
|
|
2000-06-15 17:40:22 +00:00
|
|
|
dns_zonemgr_detach(&server->zonemgr);
|
|
|
|
|
2000-01-25 19:05:46 +00:00
|
|
|
if (server->tkeyctx != NULL)
|
|
|
|
dns_tkeyctx_destroy(&server->tkeyctx);
|
|
|
|
|
2000-06-07 01:44:33 +00:00
|
|
|
dst_lib_destroy();
|
|
|
|
|
2000-01-24 22:21:47 +00:00
|
|
|
isc_event_free(&server->reload_event);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-12-22 18:45:56 +00:00
|
|
|
INSIST(ISC_LIST_EMPTY(server->viewlist));
|
2000-01-18 23:38:42 +00:00
|
|
|
|
2000-04-06 17:31:33 +00:00
|
|
|
dns_db_detach(&server->in_roothints);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-02-09 22:59:40 +00:00
|
|
|
dns_aclenv_destroy(&server->aclenv);
|
|
|
|
|
2000-01-11 21:18:22 +00:00
|
|
|
isc_quota_destroy(&server->recursionquota);
|
|
|
|
isc_quota_destroy(&server->tcpquota);
|
|
|
|
isc_quota_destroy(&server->xfroutquota);
|
2000-01-26 19:25:22 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
server->magic = 0;
|
|
|
|
isc_mem_put(server->mctx, server, sizeof(*server));
|
|
|
|
}
|
2000-01-18 22:49:55 +00:00
|
|
|
|
2000-01-21 23:55:12 +00:00
|
|
|
static void
|
2000-06-01 18:49:22 +00:00
|
|
|
fatal(const char *msg, isc_result_t result) {
|
2000-01-21 23:55:12 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
2000-03-14 21:19:31 +00:00
|
|
|
ISC_LOG_CRITICAL, "%s: %s", msg,
|
|
|
|
isc_result_totext(result));
|
1999-10-23 00:02:23 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
|
|
|
ISC_LOG_CRITICAL, "exiting (due to fatal error)");
|
|
|
|
exit(1);
|
|
|
|
}
|
2000-01-24 22:21:47 +00:00
|
|
|
|
2001-05-07 23:34:24 +00:00
|
|
|
static isc_result_t
|
|
|
|
loadconfig(ns_server_t *server) {
|
2000-01-24 22:21:47 +00:00
|
|
|
isc_result_t result;
|
2001-05-07 23:34:24 +00:00
|
|
|
result = load_configuration(ns_g_lwresdonly ?
|
|
|
|
lwresd_g_conffile : ns_g_conffile,
|
|
|
|
server,
|
|
|
|
ISC_FALSE);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
|
|
|
"reloading configuration failed: %s",
|
|
|
|
isc_result_totext(result));
|
|
|
|
return (result);
|
|
|
|
}
|
2001-02-14 03:54:53 +00:00
|
|
|
|
2001-05-07 23:34:24 +00:00
|
|
|
static void
|
|
|
|
reload(ns_server_t *server) {
|
|
|
|
isc_result_t result;
|
|
|
|
CHECK(loadconfig(server));
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-05-07 23:34:24 +00:00
|
|
|
result = load_zones(server, ISC_FALSE);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-01-24 22:21:47 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
2001-05-07 23:34:24 +00:00
|
|
|
"reloading zones failed: %s",
|
2000-01-24 22:21:47 +00:00
|
|
|
isc_result_totext(result));
|
|
|
|
}
|
2001-05-07 23:34:24 +00:00
|
|
|
cleanup: ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
reconfig(ns_server_t *server) {
|
|
|
|
isc_result_t result;
|
|
|
|
CHECK(loadconfig(server));
|
|
|
|
|
|
|
|
result = load_new_zones(server, ISC_FALSE);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-01-24 22:21:47 +00:00
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
2001-05-07 23:34:24 +00:00
|
|
|
"loading new zones failed: %s",
|
2000-01-24 22:21:47 +00:00
|
|
|
isc_result_totext(result));
|
|
|
|
}
|
2001-05-07 23:34:24 +00:00
|
|
|
cleanup: ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle a reload event (from SIGHUP).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ns_server_reload(isc_task_t *task, isc_event_t *event) {
|
|
|
|
ns_server_t *server = (ns_server_t *)event->ev_arg;
|
|
|
|
|
|
|
|
INSIST(task = server->task);
|
|
|
|
UNUSED(task);
|
|
|
|
|
|
|
|
reload(server);
|
|
|
|
|
2000-01-24 22:21:47 +00:00
|
|
|
LOCK(&server->reload_event_lock);
|
|
|
|
INSIST(server->reload_event == NULL);
|
|
|
|
server->reload_event = event;
|
|
|
|
UNLOCK(&server->reload_event_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ns_server_reloadwanted(ns_server_t *server) {
|
|
|
|
LOCK(&server->reload_event_lock);
|
|
|
|
if (server->reload_event != NULL)
|
|
|
|
isc_task_send(server->task, &server->reload_event);
|
|
|
|
UNLOCK(&server->reload_event_lock);
|
|
|
|
}
|
2000-01-25 21:21:05 +00:00
|
|
|
|
2000-10-12 21:52:00 +00:00
|
|
|
static char *
|
|
|
|
next_token(char **stringp, const char *delim) {
|
|
|
|
char *res;
|
2000-10-11 21:21:47 +00:00
|
|
|
|
2000-10-12 21:52:00 +00:00
|
|
|
do {
|
|
|
|
res = strsep(stringp, delim);
|
|
|
|
if (res == NULL)
|
|
|
|
break;
|
|
|
|
} while (*res == '\0');
|
|
|
|
return (res);
|
|
|
|
}
|
|
|
|
|
2000-11-30 19:38:04 +00:00
|
|
|
/*
|
|
|
|
* Find the zone specified in the control channel command 'args',
|
|
|
|
* if any. If a zone is specified, point '*zonep' at it, otherwise
|
|
|
|
* set '*zonep' to NULL.
|
|
|
|
*/
|
2000-10-12 21:52:00 +00:00
|
|
|
static isc_result_t
|
2000-11-30 19:38:04 +00:00
|
|
|
zone_from_args(ns_server_t *server, char *args, dns_zone_t **zonep) {
|
2000-10-12 21:52:00 +00:00
|
|
|
char *input, *ptr;
|
2000-11-30 19:38:04 +00:00
|
|
|
const char *zonetxt;
|
2000-11-30 20:47:53 +00:00
|
|
|
char *classtxt;
|
|
|
|
const char *viewtxt = NULL;
|
2000-10-12 21:52:00 +00:00
|
|
|
dns_fixedname_t name;
|
|
|
|
isc_result_t result;
|
|
|
|
isc_buffer_t buf;
|
2000-11-25 03:27:54 +00:00
|
|
|
dns_view_t *view = NULL;
|
2000-11-30 20:47:53 +00:00
|
|
|
dns_rdataclass_t rdclass;
|
2000-10-12 21:52:00 +00:00
|
|
|
|
2000-11-30 19:38:04 +00:00
|
|
|
REQUIRE(zonep != NULL && *zonep == NULL);
|
|
|
|
|
2000-10-12 21:52:00 +00:00
|
|
|
input = args;
|
2000-11-30 19:38:04 +00:00
|
|
|
|
|
|
|
/* Skip the command name. */
|
2000-10-12 21:52:00 +00:00
|
|
|
ptr = next_token(&input, " \t");
|
2000-11-30 19:38:04 +00:00
|
|
|
if (ptr == NULL)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
|
|
|
|
/* Look for the zone name. */
|
|
|
|
zonetxt = next_token(&input, " \t");
|
|
|
|
if (zonetxt == NULL) {
|
|
|
|
*zonep = NULL;
|
|
|
|
return (ISC_R_SUCCESS);
|
2000-10-12 21:52:00 +00:00
|
|
|
}
|
2000-11-30 19:38:04 +00:00
|
|
|
|
2000-11-30 20:47:53 +00:00
|
|
|
/* Look for the optional class name. */
|
|
|
|
classtxt = next_token(&input, " \t");
|
|
|
|
if (classtxt != NULL) {
|
|
|
|
/* Look for the optional view name. */
|
|
|
|
viewtxt = next_token(&input, " \t");
|
|
|
|
}
|
2000-11-30 19:38:04 +00:00
|
|
|
|
2000-10-12 21:52:00 +00:00
|
|
|
isc_buffer_init(&buf, zonetxt, strlen(zonetxt));
|
|
|
|
isc_buffer_add(&buf, strlen(zonetxt));
|
|
|
|
dns_fixedname_init(&name);
|
2000-11-30 20:47:53 +00:00
|
|
|
result = dns_name_fromtext(dns_fixedname_name(&name),
|
|
|
|
&buf, dns_rootname, ISC_FALSE, NULL);
|
2000-10-12 21:52:00 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto fail1;
|
2000-11-30 20:47:53 +00:00
|
|
|
|
|
|
|
if (classtxt != NULL) {
|
|
|
|
isc_textregion_t r;
|
|
|
|
r.base = classtxt;
|
|
|
|
r.length = strlen(classtxt);
|
|
|
|
result = dns_rdataclass_fromtext(&rdclass, &r);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto fail1;
|
|
|
|
} else {
|
|
|
|
rdclass = dns_rdataclass_in;
|
|
|
|
}
|
|
|
|
|
2000-11-30 19:38:04 +00:00
|
|
|
if (viewtxt == NULL)
|
2000-10-12 21:52:00 +00:00
|
|
|
viewtxt = "_default";
|
2000-11-30 19:38:04 +00:00
|
|
|
result = dns_viewlist_find(&server->viewlist, viewtxt,
|
2000-11-30 20:47:53 +00:00
|
|
|
rdclass, &view);
|
2000-10-12 21:52:00 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto fail1;
|
2000-11-30 20:47:53 +00:00
|
|
|
|
2000-11-30 19:38:04 +00:00
|
|
|
result = dns_zt_find(view->zonetable, dns_fixedname_name(&name),
|
|
|
|
0, NULL, zonep);
|
2000-10-12 21:52:00 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto fail2;
|
|
|
|
fail2:
|
|
|
|
dns_view_detach(&view);
|
|
|
|
fail1:
|
|
|
|
return (result);
|
2000-10-11 21:21:47 +00:00
|
|
|
}
|
|
|
|
|
2000-11-30 19:38:04 +00:00
|
|
|
/*
|
|
|
|
* Act on a "reload" command from the command channel.
|
|
|
|
*/
|
2000-10-12 21:52:00 +00:00
|
|
|
isc_result_t
|
2000-11-30 19:38:04 +00:00
|
|
|
ns_server_reloadcommand(ns_server_t *server, char *args) {
|
2000-10-12 21:52:00 +00:00
|
|
|
isc_result_t result;
|
|
|
|
dns_zone_t *zone = NULL;
|
2000-12-13 07:18:44 +00:00
|
|
|
dns_zonetype_t type;
|
2000-10-12 21:52:00 +00:00
|
|
|
|
2000-11-30 19:38:04 +00:00
|
|
|
result = zone_from_args(server, args, &zone);
|
2000-10-12 21:52:00 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
2000-11-30 19:38:04 +00:00
|
|
|
if (zone == NULL) {
|
2001-05-07 23:34:24 +00:00
|
|
|
reload(server);
|
2000-11-30 19:38:04 +00:00
|
|
|
} else {
|
2000-12-13 07:18:44 +00:00
|
|
|
type = dns_zone_gettype(zone);
|
|
|
|
if (type == dns_zone_slave || type == dns_zone_stub)
|
|
|
|
dns_zone_refresh(zone);
|
|
|
|
else
|
|
|
|
dns_zone_load(zone);
|
2000-10-12 21:52:00 +00:00
|
|
|
dns_zone_detach(&zone);
|
|
|
|
}
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2001-05-07 23:34:24 +00:00
|
|
|
/*
|
|
|
|
* Act on a "reconfig" command from the command channel.
|
|
|
|
*/
|
|
|
|
isc_result_t
|
|
|
|
ns_server_reconfigcommand(ns_server_t *server, char *args) {
|
|
|
|
UNUSED(args);
|
|
|
|
|
|
|
|
reconfig(server);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2000-11-30 19:38:04 +00:00
|
|
|
/*
|
|
|
|
* Act on a "refresh" command from the command channel.
|
|
|
|
*/
|
2000-10-12 21:52:00 +00:00
|
|
|
isc_result_t
|
2000-11-30 19:38:04 +00:00
|
|
|
ns_server_refreshcommand(ns_server_t *server, char *args) {
|
2000-10-12 21:52:00 +00:00
|
|
|
isc_result_t result;
|
|
|
|
dns_zone_t *zone = NULL;
|
|
|
|
|
2000-11-30 19:38:04 +00:00
|
|
|
result = zone_from_args(server, args, &zone);
|
2000-10-12 21:52:00 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
2000-11-30 19:38:04 +00:00
|
|
|
if (zone == NULL)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
|
|
|
|
dns_zone_refresh(zone);
|
|
|
|
dns_zone_detach(&zone);
|
|
|
|
|
2000-10-12 21:52:00 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2000-11-30 00:25:49 +00:00
|
|
|
isc_result_t
|
|
|
|
ns_server_togglequerylog(ns_server_t *server) {
|
2000-12-06 01:21:04 +00:00
|
|
|
server->log_queries = server->log_queries ? ISC_FALSE : ISC_TRUE;
|
2000-11-30 00:25:49 +00:00
|
|
|
|
|
|
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
|
|
|
NS_LOGMODULE_SERVER, ISC_LOG_INFO,
|
|
|
|
"query logging is now %s",
|
|
|
|
server->log_queries ? "on" : "off");
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2000-01-31 22:06:09 +00:00
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
ns_listenlist_fromconfig(cfg_obj_t *listenlist, cfg_obj_t *config,
|
|
|
|
ns_aclconfctx_t *actx,
|
|
|
|
isc_mem_t *mctx, ns_listenlist_t **target)
|
2000-01-25 21:21:05 +00:00
|
|
|
{
|
|
|
|
isc_result_t result;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_listelt_t *element;
|
2000-01-25 21:21:05 +00:00
|
|
|
ns_listenlist_t *dlist = NULL;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-25 21:21:05 +00:00
|
|
|
REQUIRE(target != NULL && *target == NULL);
|
|
|
|
|
|
|
|
result = ns_listenlist_create(mctx, &dlist);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
for (element = cfg_list_first(listenlist);
|
|
|
|
element != NULL;
|
|
|
|
element = cfg_list_next(element))
|
2000-01-25 21:21:05 +00:00
|
|
|
{
|
|
|
|
ns_listenelt_t *delt = NULL;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *listener = cfg_listelt_value(element);
|
|
|
|
result = ns_listenelt_fromconfig(listener, config, actx,
|
|
|
|
mctx, &delt);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2000-01-25 21:21:05 +00:00
|
|
|
goto cleanup;
|
|
|
|
ISC_LIST_APPEND(dlist->elts, delt, link);
|
|
|
|
}
|
|
|
|
*target = dlist;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ns_listenlist_detach(&dlist);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a listen list from the corresponding configuration
|
|
|
|
* data structure.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2001-03-04 21:21:39 +00:00
|
|
|
ns_listenelt_fromconfig(cfg_obj_t *listener, cfg_obj_t *config,
|
|
|
|
ns_aclconfctx_t *actx,
|
|
|
|
isc_mem_t *mctx, ns_listenelt_t **target)
|
2000-01-25 21:21:05 +00:00
|
|
|
{
|
|
|
|
isc_result_t result;
|
2001-03-04 21:21:39 +00:00
|
|
|
cfg_obj_t *portobj;
|
|
|
|
in_port_t port;
|
2000-01-25 21:21:05 +00:00
|
|
|
ns_listenelt_t *delt = NULL;
|
|
|
|
REQUIRE(target != NULL && *target == NULL);
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
portobj = cfg_tuple_get(listener, "port");
|
|
|
|
if (!cfg_obj_isuint32(portobj)) {
|
|
|
|
result = ns_config_getport(config, &port);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
} else {
|
|
|
|
if (cfg_obj_asuint32(portobj) >= ISC_UINT16_MAX) {
|
|
|
|
cfg_obj_log(portobj, ns_g_lctx, ISC_LOG_ERROR,
|
|
|
|
"port value '%u' is out of range",
|
|
|
|
cfg_obj_asuint32(portobj));
|
|
|
|
return (ISC_R_RANGE);
|
|
|
|
}
|
|
|
|
port = (in_port_t)cfg_obj_asuint32(portobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = ns_listenelt_create(mctx, port, NULL, &delt);
|
2000-01-25 21:21:05 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
result = ns_acl_fromconfig(cfg_tuple_get(listener, "acl"),
|
|
|
|
config, actx, mctx, &delt->acl);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-01-25 21:21:05 +00:00
|
|
|
ns_listenelt_destroy(delt);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
*target = delt;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2000-11-07 23:49:42 +00:00
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
ns_server_dumpstats(ns_server_t *server) {
|
|
|
|
isc_result_t result;
|
2000-12-05 17:23:45 +00:00
|
|
|
dns_zone_t *zone, *next;
|
2000-11-07 23:49:42 +00:00
|
|
|
isc_stdtime_t now;
|
2000-12-01 23:49:59 +00:00
|
|
|
FILE *fp = NULL;
|
2000-11-09 19:55:20 +00:00
|
|
|
int i;
|
2000-12-01 23:49:59 +00:00
|
|
|
int ncounters;
|
2000-11-07 23:49:42 +00:00
|
|
|
|
|
|
|
isc_stdtime_get(&now);
|
2000-12-01 23:49:59 +00:00
|
|
|
|
|
|
|
CHECKM(isc_stdio_open(server->statsfile, "a", &fp),
|
|
|
|
"could not open statistics dump file");
|
|
|
|
|
2001-01-23 01:50:29 +00:00
|
|
|
ncounters = DNS_STATS_NCOUNTERS;
|
2000-12-01 23:49:59 +00:00
|
|
|
fprintf(fp, "+++ Statistics Dump +++ (%lu)\n", (unsigned long)now);
|
|
|
|
|
|
|
|
for (i = 0; i < ncounters; i++)
|
|
|
|
fprintf(fp, "%s %" ISC_PRINT_QUADFORMAT "d\n",
|
|
|
|
dns_statscounter_names[i],
|
|
|
|
server->querystats[i]);
|
|
|
|
|
2000-12-05 01:41:29 +00:00
|
|
|
zone = NULL;
|
2000-12-01 23:49:59 +00:00
|
|
|
for (result = dns_zone_first(server->zonemgr, &zone);
|
|
|
|
result == ISC_R_SUCCESS;
|
2000-12-05 17:23:45 +00:00
|
|
|
next = NULL, result = dns_zone_next(zone, &next), zone = next)
|
2000-12-01 23:49:59 +00:00
|
|
|
{
|
|
|
|
isc_uint64_t *zonestats = dns_zone_getstatscounters(zone);
|
|
|
|
if (zonestats != NULL) {
|
|
|
|
char zonename[DNS_NAME_FORMATSIZE];
|
|
|
|
dns_view_t *view;
|
|
|
|
char *viewname;
|
|
|
|
|
|
|
|
dns_name_format(dns_zone_getorigin(zone),
|
|
|
|
zonename, sizeof(zonename));
|
|
|
|
view = dns_zone_getview(zone);
|
|
|
|
viewname = view->name;
|
|
|
|
for (i = 0; i < ncounters; i++) {
|
|
|
|
fprintf(fp, "%s %" ISC_PRINT_QUADFORMAT
|
|
|
|
"d %s",
|
|
|
|
dns_statscounter_names[i],
|
|
|
|
zonestats[i],
|
|
|
|
zonename);
|
|
|
|
if (strcmp(viewname, "_default") != 0)
|
|
|
|
fprintf(fp, " %s", viewname);
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
}
|
2000-11-07 23:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
2000-12-01 23:49:59 +00:00
|
|
|
if (result == ISC_R_NOMORE)
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
CHECK(result);
|
|
|
|
|
|
|
|
fprintf(fp, "--- Statistics Dump --- (%lu)\n", (unsigned long)now);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (fp != NULL)
|
|
|
|
(void)isc_stdio_close(fp);
|
|
|
|
return (result);
|
2000-11-07 23:49:42 +00:00
|
|
|
}
|
2000-12-12 21:33:21 +00:00
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
ns_server_dumpdb(ns_server_t *server) {
|
|
|
|
FILE *fp = NULL;
|
|
|
|
dns_view_t *view;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
CHECKM(isc_stdio_open(server->dumpfile, "w", &fp),
|
|
|
|
"could not open dump file");
|
2000-12-15 19:38:07 +00:00
|
|
|
|
|
|
|
for (view = ISC_LIST_HEAD(server->viewlist);
|
|
|
|
view != NULL;
|
|
|
|
view = ISC_LIST_NEXT(view, link))
|
|
|
|
{
|
2000-12-12 21:33:21 +00:00
|
|
|
if (view->cachedb != NULL)
|
2000-12-15 21:11:38 +00:00
|
|
|
CHECKM(dns_view_dumpdbtostream(view, fp),
|
|
|
|
"could not dump view databases");
|
2000-12-12 21:33:21 +00:00
|
|
|
}
|
|
|
|
cleanup:
|
|
|
|
if (fp != NULL)
|
|
|
|
(void)isc_stdio_close(fp);
|
|
|
|
return (result);
|
|
|
|
}
|
2001-02-07 00:50:44 +00:00
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
ns_server_setdebuglevel(ns_server_t *server, char *args) {
|
|
|
|
char *ptr;
|
|
|
|
char *levelstr;
|
|
|
|
char *endp;
|
2001-02-08 18:01:33 +00:00
|
|
|
long newlevel;
|
|
|
|
|
|
|
|
UNUSED(server);
|
2001-02-07 00:50:44 +00:00
|
|
|
|
|
|
|
/* Skip the command name. */
|
|
|
|
ptr = next_token(&args, " \t");
|
|
|
|
if (ptr == NULL)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
|
|
|
|
/* Look for the new level name. */
|
|
|
|
levelstr = next_token(&args, " \t");
|
2001-05-08 04:30:32 +00:00
|
|
|
if (levelstr == NULL) {
|
|
|
|
if (ns_g_debuglevel < 99)
|
|
|
|
ns_g_debuglevel++;
|
|
|
|
} else {
|
2001-02-07 00:50:44 +00:00
|
|
|
newlevel = strtol(levelstr, &endp, 10);
|
|
|
|
if (*endp != '\0' || newlevel < 0 || newlevel > 99)
|
|
|
|
return (ISC_R_RANGE);
|
2001-02-08 18:01:33 +00:00
|
|
|
ns_g_debuglevel = (unsigned int)newlevel;
|
2001-02-07 00:50:44 +00:00
|
|
|
}
|
|
|
|
isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2001-04-11 20:37:50 +00:00
|
|
|
|
|
|
|
isc_result_t
|
2001-05-31 01:21:12 +00:00
|
|
|
ns_server_flushcache(ns_server_t *server, char *args) {
|
|
|
|
char *ptr, *viewname;
|
2001-04-11 20:37:50 +00:00
|
|
|
dns_view_t *view;
|
2001-05-31 01:21:12 +00:00
|
|
|
isc_boolean_t flushed = ISC_FALSE;
|
2001-04-11 20:37:50 +00:00
|
|
|
isc_result_t result;
|
|
|
|
|
2001-05-31 01:21:12 +00:00
|
|
|
/* Skip the command name. */
|
|
|
|
ptr = next_token(&args, " \t");
|
|
|
|
if (ptr == NULL)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
|
|
|
|
/* Look for the view name. */
|
|
|
|
viewname = next_token(&args, " \t");
|
|
|
|
|
2001-04-11 20:37:50 +00:00
|
|
|
result = isc_task_beginexclusive(server->task);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
|
|
|
for (view = ISC_LIST_HEAD(server->viewlist);
|
|
|
|
view != NULL;
|
|
|
|
view = ISC_LIST_NEXT(view, link))
|
|
|
|
{
|
2001-05-31 01:21:12 +00:00
|
|
|
if (viewname != NULL && strcasecmp(viewname, view->name) != 0)
|
|
|
|
continue;
|
2001-04-11 20:37:50 +00:00
|
|
|
result = dns_view_flushcache(view);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto out;
|
2001-05-31 01:21:12 +00:00
|
|
|
flushed = ISC_TRUE;
|
2001-04-11 20:37:50 +00:00
|
|
|
}
|
2001-05-31 01:21:12 +00:00
|
|
|
if (flushed)
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
else
|
|
|
|
result = ISC_R_FAILURE;
|
2001-04-11 20:37:50 +00:00
|
|
|
out:
|
|
|
|
isc_task_endexclusive(server->task);
|
|
|
|
return (result);
|
|
|
|
}
|
2001-05-08 04:09:41 +00:00
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
ns_server_status(ns_server_t *server, isc_buffer_t *text) {
|
2001-05-14 20:44:16 +00:00
|
|
|
int zonecount, xferrunning, xferdeferred, soaqueries;
|
2001-05-08 04:09:41 +00:00
|
|
|
int n;
|
|
|
|
|
2001-05-14 19:06:47 +00:00
|
|
|
zonecount = dns_zonemgr_getcount(server->zonemgr, DNS_ZONESTATE_ANY);
|
|
|
|
xferrunning = dns_zonemgr_getcount(server->zonemgr,
|
|
|
|
DNS_ZONESTATE_XFERRUNNING);
|
|
|
|
xferdeferred = dns_zonemgr_getcount(server->zonemgr,
|
|
|
|
DNS_ZONESTATE_XFERDEFERRED);
|
2001-05-14 20:44:16 +00:00
|
|
|
soaqueries = dns_zonemgr_getcount(server->zonemgr,
|
|
|
|
DNS_ZONESTATE_SOAQUERY);
|
2001-05-08 04:09:41 +00:00
|
|
|
n = snprintf((char *)isc_buffer_used(text),
|
|
|
|
isc_buffer_availablelength(text),
|
|
|
|
"number of zones: %d\n"
|
|
|
|
"debug level: %d\n"
|
|
|
|
"xfers running: %d\n"
|
|
|
|
"xfers deferred: %d\n"
|
|
|
|
"soa queries in progress: %d\n"
|
|
|
|
"query logging is %s\n"
|
|
|
|
"server is up and running",
|
2001-05-14 19:06:47 +00:00
|
|
|
zonecount, ns_g_debuglevel, xferrunning, xferdeferred,
|
2001-05-14 20:44:16 +00:00
|
|
|
soaqueries, server->log_queries ? "ON" : "OFF");
|
2001-05-08 04:09:41 +00:00
|
|
|
if (n < 0)
|
|
|
|
return (ISC_R_NOSPACE);
|
|
|
|
isc_buffer_add(text, n);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|