server.c revision ad5bc22a819190839bdcc4d102d023782dc23660
/*
* Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.
*/
/* $Id: server.c,v 1.435 2005/01/11 03:46:08 marka Exp $ */
#include <config.h>
#include <stdlib.h>
#include <isc/parseint.h>
#include <isc/resource.h>
#include <isccfg/namedconf.h>
#include <dns/dispatch.h>
#include <dns/keytable.h>
#include <dns/masterdump.h>
#include <dns/portlist.h>
#include <dns/rdataclass.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/resolver.h>
#include <named/interfacemgr.h>
#include <named/tkeyconf.h>
#include <named/tsigconf.h>
#include <named/zoneconf.h>
/*
* Check an operation for failure. Assumes that the function
* using it has a 'result' variable and a 'cleanup' label.
*/
} while (0)
if (result != ISC_R_SUCCESS) { \
"%s: %s", msg, \
isc_result_totext(result)); \
goto cleanup; \
} \
} while (0) \
if (result != ISC_R_SUCCESS) { \
isc_result_totext(result)); \
goto cleanup; \
} \
} while (0) \
if (result != ISC_R_SUCCESS) \
} while (0) \
struct ns_dispatch {
unsigned int dispatchgen;
};
struct dumpcontext {
struct viewlistentry *view;
struct zonelistentry *zone;
};
struct viewlistentry {
};
struct zonelistentry {
};
static void
static void
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
static void
/*
* 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
{
int i = 0;
}
/*
* No value available. *aclp == NULL.
*/
return (ISC_R_SUCCESS);
return (result);
}
static isc_result_t
{
char *keystr, *keynamestr;
unsigned char keydata[4096];
unsigned char rrdata[4096];
isc_region_t r;
else {
&viewclass));
}
/*
* The key data in keystruct is not dynamically allocated.
*/
if (flags > 0xffff)
if (proto > 0xff)
if (alg > 0xff)
isc_buffer_usedregion(&keydatabuf, &r);
NULL));
return (ISC_R_SUCCESS);
if (result == DST_R_NOCRYPTO) {
"ignoring trusted key for '%s': no crypto support",
} else {
"configuring trusted key for '%s': %s",
}
return (result);
}
/*
* Configure DNSSEC keys for a view. Currently used only for
* the security roots.
*
* The per-view configuration values and the server-global defaults are read
* from 'vconfig' and 'config'. The variable to be configured is '*target'.
*/
static isc_result_t
{
{
{
}
}
return (result);
}
static isc_result_t
{
const char *str;
isc_buffer_t b;
{
}
return (result);
}
/*
* Get a dispatch appropriate for the resolver of a given view.
*/
static isc_result_t
{
/*
* Make compiler happy.
*/
switch (af) {
case AF_INET:
break;
case AF_INET6:
break;
default:
INSIST(0);
}
/*
* 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;
switch (af) {
case AF_INET:
break;
case AF_INET6:
break;
}
attrmask = 0;
1000, 32768, 16411, 16433,
if (result != ISC_R_SUCCESS) {
char buf[ISC_SOCKADDR_FORMATSIZE];
switch (af) {
case AF_INET:
break;
case AF_INET6:
break;
}
return (ISC_R_SUCCESS);
"could not get query source dispatcher (%s)",
buf);
return (result);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned int mode = 0;
const char *str;
isc_buffer_t b;
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
if (cfg_obj_isstring(obj))
else
str = "*";
if (result != ISC_R_SUCCESS)
return (result);
mode = 0;
else
INSIST(0);
/*
* "*" should match everything including the root (BIND 8 compat).
* As dns_name_matcheswildcard(".", "*.") returns FALSE add a
* explict entry for "." when the name is "*".
*/
if (addroot) {
if (result != ISC_R_SUCCESS)
return (result);
}
}
static isc_result_t
char *str;
if (result != ISC_R_SUCCESS)
return (result);
else
INSIST(0);
}
if (result != ISC_R_SUCCESS)
goto cleanup;
}
else
if (result != ISC_R_SUCCESS)
goto cleanup;
}
return (ISC_R_SUCCESS);
return (result);
}
static isc_result_t
const char *str;
isc_buffer_t b;
{
if (result != ISC_R_SUCCESS) {
}
if (result != ISC_R_SUCCESS) {
"invalid algorithm");
}
}
return (result);
}
/*
* Configure 'view' according to 'vconfig', taking defaults from 'config'
* where values are missing in 'vconfig'.
*
* When configuring the default view, 'vconfig' will be NULL and the
* global defaults in 'config' used exclusively.
*/
static isc_result_t
{
int i;
const char *str;
unsigned int check = 0;
i = 0;
}
maps[i++] = ns_g_defaults;
i = 0;
/*
* Set the view's port number for outgoing queries.
*/
/*
* Create additional cache for this view and zones under the view
* unless explicitly disabled.
*/
}
if (cfg_obj_isstring(obj)) {
} else {
if (value > ISC_UINT32_MAX) {
"'max-acache-size "
"d' is too large",
value);
goto cleanup;
}
}
}
/*
* Configure the zones.
*/
else
{
actx));
}
/*
* 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.
*
* XXX Determining when it is safe to reuse a cache is
* 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.
*/
&pview);
goto cleanup;
"reusing existing cache");
} else {
}
/*
* cache-file cannot be inherited if views are present, but this
* should be caught by the configuration checking stage.
*/
if (!reused_cache)
}
if (cfg_obj_isstring(obj)) {
} else {
if (value > ISC_UINT32_MAX) {
"'max-cache-size "
value);
goto cleanup;
}
}
/*
* Check-names.
*/
check = 0;
} else
INSIST(0);
/*
* Resolver.
*
* XXXRTH Hardwired number of tasks.
*/
"unable to obtain neither an IPv4 nor"
" an IPv6 dispatch");
goto cleanup;
}
/*
* Set the ADB cache size to 1/8th of the max-cache-size.
*/
max_adb_size = 0;
if (max_cache_size != 0) {
if (max_adb_size == 0)
}
/*
* Set resolver's lame-ttl.
*/
if (lame_ttl > 1800)
lame_ttl = 1800;
/*
* Set the resolver's EDNS UDP size.
*/
if (udpsize < 512)
udpsize = 512;
if (udpsize > 4096)
udpsize = 4096;
/*
* Set supported DNSSEC algorithms.
*/
}
/*
* A global or view "forwarders" option, if present,
* creates an entry for "." in the forwarding table.
*/
forwardtype = NULL;
forwarders = NULL;
if (forwarders != NULL)
/*
* Dual Stack Servers.
*/
alternates = NULL;
if (alternates != NULL)
/*
* We have default hints for class IN if we need them.
*/
/*
* If we still have no hints, this is a non-IN view with no
* "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 requiring users to configure
* them.
*/
}
if (need_hints)
"no root hints for view '%s'",
}
/*
* Configure the view's TSIG keys.
*/
/*
* Configure the view's peer list.
*/
{
{
}
}
/*
* Configure the views rrset-order.
*/
{
{
}
}
/*
* Copy the aclenv object.
*/
/*
* Configure the "match-clients" and "match-destinations" ACL.
*/
/*
* Configure the "match-recursive-only" option.
*/
else
/*
* Configure other configurable data.
*/
else
INSIST(0);
/*
* targets for authoritative answers may be found.
*/
"'additional-from-auth no' is only supported "
"with 'recursion no'");
}
"'additional-from-cache no' is only supported "
"with 'recursion no'");
}
/*
* Warning if both "recursion no;" and allow-recursion are active
* except for "allow-recursion { none; };".
*/
const char *forview = " for view ";
forview = "";
viewname = "";
}
"both \"recursion no;\" and \"allow-recursion\" "
}
if (result == ISC_R_SUCCESS) {
{
const char *str;
isc_buffer_t b;
#if 0
/*
* When we support multiple dnssec-lookaside
* entries this is how to find the domain to be
* checked. XXXMPA
*/
"domain"));
#endif
"trust-anchor"));
}
} else
/*
* For now, there is only one kind of trusted keys, the
* "security roots".
*/
if (view->enablednssec) {
if (result == ISC_R_SUCCESS)
}
if (result == ISC_R_SUCCESS) {
else
view->preferred_glue = 0;
} else
view->preferred_glue = 0;
if (result == ISC_R_SUCCESS) {
if (!cfg_obj_isvoid(obj)) {
isc_buffer_t b;
char *str;
name));
}
}
} else
return (result);
}
static isc_result_t
if (result == ISC_R_SUCCESS) {
dns_db_detach(&db);
}
return (result);
}
static isc_result_t
{
/*
* Determine which port to send requests to.
*/
if (ns_g_lwresdonly && ns_g_port != 0)
else
if (alternates != NULL) {
if (cfg_obj_isuint32(portobj)) {
if (val > ISC_UINT16_MAX) {
"port '%u' out of range", val);
return (ISC_R_RANGE);
}
}
}
if (alternates != NULL)
{
if (!cfg_obj_issockaddr(alternate)) {
"name"));
if (cfg_obj_isuint32(portobj)) {
if (val > ISC_UINT16_MAX) {
"port '%u' out of range",
val);
return (ISC_R_RANGE);
}
}
continue;
}
if (isc_sockaddr_getport(&sa) == 0)
NULL, 0));
}
return (result);
}
static isc_result_t
{
/*
* Determine which port to send forwarded requests to.
*/
if (ns_g_lwresdonly && ns_g_port != 0)
else
if (forwarders != NULL) {
if (cfg_obj_isuint32(portobj)) {
if (val > ISC_UINT16_MAX) {
"port '%u' out of range", val);
return (ISC_R_RANGE);
}
}
}
faddresses = NULL;
if (forwarders != NULL)
{
goto cleanup;
}
if (isc_sockaddr_getport(sa) == 0)
}
if (ISC_LIST_EMPTY(addresses)) {
if (forwardtype != NULL)
"no forwarders seen; disabling "
"forwarding");
} else {
if (forwardtype == NULL)
else {
else
INSIST(0);
}
}
if (result != ISC_R_SUCCESS) {
char namebuf[DNS_NAME_FORMATSIZE];
"could not set up forwarding for domain '%s': %s",
goto cleanup;
}
while (!ISC_LIST_EMPTY(addresses)) {
}
return (result);
}
/*
* Create a new view and add it to the list.
*
* If 'vconfig' is NULL, create the default view.
*
* The view created is attached to '*viewp'.
*/
static isc_result_t
const char *viewname;
&viewclass);
} else {
viewname = "_default";
}
if (result == ISC_R_SUCCESS)
return (ISC_R_EXISTS);
if (result != ISC_R_NOTFOUND)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_SUCCESS);
}
/*
* Configure or reconfigure a zone.
*/
static isc_result_t
{
const char *zname;
const char *ztypestr;
/*
* Get the zone origin as a dns_name_t.
*/
"name"));
else
vname = "<default view>";
"zone '%s': wrong class for view '%s'",
goto cleanup;
}
"zone '%s' 'type' not specified", zname);
return (ISC_R_FAILURE);
}
/*
* "hints zones" aren't zones. If we've got one,
* configure it and return.
*/
"zone '%s': 'file' not specified",
zname);
goto cleanup;
}
if (result != ISC_R_SUCCESS) {
"could not configure root hints "
"from '%s': %s", hintsfile,
goto cleanup;
}
/*
* Hint zones may also refer to delegation only points.
*/
&only);
} else {
"ignoring non-root hint zone '%s'",
zname);
}
/* Skip ordinary zone processing. */
goto cleanup;
}
/*
* "forward zones" aren't zones either. Translate this syntax into
* the appropriate selective forwarding configuration and return.
*/
forwardtype = NULL;
forwarders = NULL;
goto cleanup;
}
/*
* "delegation-only zones" aren't zones either.
*/
goto cleanup;
}
/*
* Check for duplicates in the new zone table.
*/
if (result == ISC_R_SUCCESS) {
/*
* We already have this zone!
*/
"zone '%s' already exists", zname);
goto cleanup;
}
/*
* 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
* options (e.g., an existing master zone cannot
* be reused if the options specify a slave zone)
*/
&pview);
goto cleanup;
goto cleanup;
}
/*
* We found a reusable zone. Make it use the
* new view.
*/
} else {
/*
* We cannot reuse an existing zone, we have
* to create a new one.
*/
}
/*
* If the zone contains a 'forwarders' statement, configure
* selective forwarding.
*/
forwarders = NULL;
{
forwardtype = NULL;
forwardtype));
}
/*
* Stub and forward zones may also refer to delegation only points.
*/
{
if (cfg_obj_asboolean(only))
}
/*
* Configure the zone.
*/
/*
* Add the zone to its view in the new view list.
*/
return (result);
}
/*
* Configure a single server quota.
*/
static void
{
}
/*
* This function is called as soon as the 'directory' statement has been
* parsed. This can be extended to support other options if necessary.
*/
static isc_result_t
char *directory;
/*
* Change directory.
*/
if (! isc_file_ischdiridempotent(directory))
"option 'directory' contains relative path '%s'",
if (result != ISC_R_SUCCESS) {
"change directory to '%s' failed: %s",
return (result);
}
return (ISC_R_SUCCESS);
}
static void
/*
* Update the "localhost" and "localnets" ACLs to match the
* current set of network interfaces.
*/
}
static isc_result_t
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
goto clean;
if (result != ISC_R_SUCCESS)
goto clean;
}
return (ISC_R_SUCCESS);
return (result);
}
/*
* Make a list of xxx-source addresses and call ns_interfacemgr_adjust()
* to update the listening interfaces accordingly.
* We currently only consider IPv6, because this only affects IPv6 wildcard
* sockets.
*/
static void
if (result != ISC_R_SUCCESS)
return;
continue;
if (result != ISC_R_SUCCESS)
goto fail;
if (result != ISC_R_SUCCESS)
goto fail;
}
result == ISC_R_SUCCESS;
/*
* At this point the zone list may contain a stale zone
* just removed from the configuration. To see the validity,
* check if the corresponding view is in our current view list.
*/
;
continue;
if (result != ISC_R_SUCCESS)
goto fail;
if (result != ISC_R_SUCCESS)
goto fail;
}
return;
fail:
/*
* Even when we failed the procedure, most of other interfaces
* should work correctly. We therefore just warn it.
*/
"could not adjust the listen-on list; "
"some interfaces may not work");
goto clean;
}
/*
* This event callback is invoked to do periodic network
* interface scanning.
*/
static void
/*
* XXX should scan interfaces unlocked and get exclusive access
* only to replace ACLs.
*/
}
static void
}
}
/*
* Replace the current value of '*field', a dynamically allocated
* string or NULL, with a dynamically allocated copy of the
* null-terminated string pointed to by 'value', or NULL.
*/
static isc_result_t
char *copy;
return (ISC_R_NOMEMORY);
} else {
}
return (ISC_R_SUCCESS);
}
/*
* Replace the current value of '*field', a dynamically allocated
* string or NULL, with another dynamically allocated string
* or NULL if whether 'obj' is a string or void value, respectively.
*/
static isc_result_t
if (cfg_obj_isvoid(obj))
else
}
static void
{
char *resource;
return;
if (cfg_obj_isstring(obj)) {
else {
}
} else
result == ISC_R_SUCCESS ?
}
static void
}
static isc_result_t
{
if (result != ISC_R_SUCCESS)
break;
}
return (result);
}
static isc_result_t
{
int i;
/* Ensure exclusive access to configuration data. */
/*
* Parse the global default pseudo-config file.
*/
if (first_time) {
&ns_g_defaults) ==
}
/*
* Parse the configuration file using the new config code.
*/
/*
* Unless this is lwresd with the -C option, parse the config file.
*/
if (!(ns_g_lwresdonly && lwresd_g_useresolvconf)) {
ISC_LOG_INFO, "loading configuration from '%s'",
filename);
&config);
}
/*
* 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 &&
{
ISC_LOG_INFO, "loading configuration from '%s'",
&config);
}
/*
* Check the validity of the configuration.
*/
/*
* Fill in the maps array, used for resolving defaults.
*/
i = 0;
if (result == ISC_R_SUCCESS)
maps[i++] = ns_g_defaults;
/*
* Set process limits, which (usually) needs to be done as root.
*/
/*
* Configure various server options.
*/
&server->recursionquota);
if (result == ISC_R_SUCCESS)
} else
/*
* Set the EDNS UDP size when we don't match a view.
*/
if (udpsize < 512)
udpsize = 512;
if (udpsize > 4096)
udpsize = 4096;
/*
* Configure the zone manager.
*/
/*
* Determine which port to use for listening for incoming connections.
*/
if (ns_g_port != 0)
else
/*
* Find the listen queue depth.
*/
if (ns_g_listen < 3)
ns_g_listen = 3;
/*
* Configure the interface manager according to the "listen-on"
* statement.
*/
{
/*
* 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.
*/
&listenon);
} else if (!ns_g_lwresdonly) {
/*
* Not specified, use default.
*/
}
listenon);
}
}
/*
* Ditto for IPv6.
*/
{
&listenon);
} else if (!ns_g_lwresdonly) {
/*
* Not specified, use default.
*/
}
listenon);
}
}
/*
* 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.
*/
/*
* Arrange for further interface scanning to occur periodically
* as specified by the "interface-interval" option.
*/
if (interface_interval == 0) {
}
/*
* Configure the dialup heartbeat timer.
*/
if (heartbeat_interval == 0) {
}
/*
* Configure and freeze all explicit views. Explicit
* views that have zones were already created at parsing
* time, but views with no zones must be created here.
*/
{
}
/*
* Make sure we have a default view if and only if there
* were no explicit views.
*/
/*
* No explicit views; there ought to be a default view.
* There may already be one created as a side effect
* of zone statements, or we may have to create one.
* In either case, we need to configure and freeze it.
*/
&aclconfctx, ISC_TRUE));
}
/*
* Create (or recreate) the built-in views. Currently
* there is only one, the _bind view.
*/
&builtin_views) == ISC_R_SUCCESS);
{
&aclconfctx, ISC_FALSE));
}
/*
* Swap our new view list with the production one.
*/
/*
* Load the TKEY information from the configuration.
*/
dns_tkeyctx_t *t = NULL;
&t),
"configuring TKEY");
}
/*
* Bind the control port(s).
*/
&aclconfctx),
"binding control channel(s)");
/*
* Bind the lwresd port(s).
*/
"binding lightweight resolver ports");
/*
* Open the source of entropy.
*/
if (first_time) {
if (result != ISC_R_SUCCESS) {
"no source of entropy found");
} else {
if (result != ISC_R_SUCCESS)
"could not open entropy source "
"%s: %s",
#ifdef PATH_RANDOMDEV
if (ns_g_fallbackentropy != NULL) {
if (result != ISC_R_SUCCESS) {
"using pre-chroot entropy source "
"%s",
&ns_g_entropy);
}
}
#endif
}
}
/*
* Relinquish root privileges.
*/
if (first_time)
/*
* Configure the logging system.
*
* Do this after changing UID to make sure that any log
* files specified in named.conf get created by the
* unprivileged user, not root.
*/
if (ns_g_logstderr) {
"ignoring config file logging "
"statement due to -g option");
} else {
"creating new logging configuration");
"configuring logging");
} else {
"setting up default logging channels");
"setting up default 'category unmatched'");
"setting up default 'category default'");
}
if (result != ISC_R_SUCCESS) {
}
"now using logging configuration from "
"config file");
}
/*
* 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) {
} else {
&categories);
if (categories != NULL) {
{
char *str;
}
}
}
}
if (cfg_obj_isvoid(obj))
else
else if (ns_g_lwresdonly)
else
else
"strdup");
"strdup");
"strdup");
if (result == ISC_R_SUCCESS) {
} else {
}
if (result == ISC_R_SUCCESS) {
} else {
}
} else if (result == ISC_R_SUCCESS) {
} else {
}
if (result == ISC_R_SUCCESS) {
} else {
}
}
/*
* This cleans up either the old production view list
* or our temporary list depending on whether they
* were swapped above or not.
*/
}
/*
* Adjust the listening interfaces in accordance with the source
* addresses specified in views and zones.
*/
if (isc_net_probeipv6() == ISC_R_SUCCESS)
/* Relinquish exclusive access to configuration data. */
return (result);
}
static isc_result_t
/*
* Load zone data from disk.
*/
{
}
/*
* 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.
*/
return (result);
}
static isc_result_t
/*
* Load zone data from disk.
*/
{
}
/*
* 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.
*/
return (result);
}
static void
"creating dispatch manager");
&server->interfacemgr),
"creating interface manager");
"creating interface timer");
"creating heartbeat timer");
"creating default configuration parser");
if (ns_g_lwresdonly)
ISC_TRUE),
"loading configuration");
else
"loading configuration");
ISC_LOG_NOTICE, "running");
}
void
}
static void
ISC_LOG_INFO, "shutting down%s",
if (flush)
else
}
}
void
/* Initialize configuration data with default values. */
/* Initialize server data structures. */
&server->in_roothints),
"setting up root hints");
"initializing reload event lock");
sizeof(isc_event_t));
"allocating reload event");
"initializing DST");
"creating TKEY context");
/*
* Setup the server task, which is responsible for coordinating
* startup and shutdown of the server.
*/
"creating server task");
"isc_task_onshutdown");
"isc_app_onrun");
server->interface_interval = 0;
server->heartbeat_interval = 0;
"dns_zonemgr_create");
"isc_mem_strdup");
"isc_mem_strdup");
"isc_mem_strdup");
"dns_stats_alloccounters");
"ns_controls_create");
server->dispatchgen = 0;
}
void
}
static void
ISC_LOG_CRITICAL, "exiting (due to fatal error)");
exit(1);
}
static void
server->dispatchgen++;
}
static void
dispatch = nextdispatch) {
continue;
}
}
void
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
return;
break;
}
return;
}
goto cleanup;
}
attrs = 0;
switch (isc_sockaddr_pf(addr)) {
case AF_INET:
break;
case AF_INET6:
break;
default:
goto cleanup;
}
attrmask = 0;
1000, 32768, 16411, 16433,
if (result != ISC_R_SUCCESS)
goto cleanup;
return;
"unable to create dispatch for reserved port %s: %s",
}
static isc_result_t
if (result == ISC_R_SUCCESS)
else
"reloading configuration failed: %s",
return (result);
}
static isc_result_t
if (result != ISC_R_SUCCESS) {
"reloading zones failed: %s",
}
return (result);
}
static void
if (result != ISC_R_SUCCESS) {
"loading new zones failed: %s",
}
cleanup: ;
}
/*
* Handle a reload event (from SIGHUP).
*/
static void
}
void
}
static char *
char *res;
do {
break;
} while (*res == '\0');
return (res);
}
/*
* 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.
*/
static isc_result_t
const char *zonetxt;
char *classtxt;
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* Look for the zone name. */
return (ISC_R_SUCCESS);
/* Look for the optional class name. */
/* Look for the optional view name. */
}
if (result != ISC_R_SUCCESS)
goto fail1;
if (result != ISC_R_SUCCESS)
goto fail1;
} else {
}
viewtxt = "_default";
if (result != ISC_R_SUCCESS)
goto fail1;
/* Partial match? */
return (result);
}
/*
* Act on a "retransfer" command from the command channel.
*/
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_UNEXPECTEDEND);
else
return (result);
}
/*
* Act on a "reload" command from the command channel.
*/
if (result != ISC_R_SUCCESS)
return (result);
if (result == ISC_R_SUCCESS)
msg = "server reload successful";
} else {
msg = "zone refresh queued";
} else {
switch (result) {
case ISC_R_SUCCESS:
msg = "zone reload successful";
break;
case DNS_R_CONTINUE:
msg = "zone reload queued";
break;
case DNS_R_UPTODATE:
msg = "zone reload up-to-date";
break;
default:
/* failure message will be generated by rndc */
break;
}
}
}
return (result);
}
/*
* Act on a "reconfig" command from the command channel.
*/
return (ISC_R_SUCCESS);
}
/*
* Act on a "notify" command from the command channel.
*/
const unsigned char msg[] = "zone notify queued";
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
}
/*
* Act on a "refresh" command from the command channel.
*/
const unsigned char msg[] = "zone refresh queued";
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
}
"query logging is now %s",
return (ISC_R_SUCCESS);
}
static isc_result_t
{
if (result != ISC_R_SUCCESS)
return (result);
{
if (result != ISC_R_SUCCESS)
goto cleanup;
}
return (ISC_R_SUCCESS);
return (result);
}
/*
* Create a listen list from the corresponding configuration
* data structure.
*/
static isc_result_t
{
if (!cfg_obj_isuint32(portobj)) {
if (ns_g_port != 0) {
} else {
if (result != ISC_R_SUCCESS)
return (result);
}
} else {
"port value '%u' is out of range",
return (ISC_R_RANGE);
}
}
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS) {
return (result);
}
return (ISC_R_SUCCESS);
}
int i;
int ncounters;
for (i = 0; i < ncounters; i++)
server->querystats[i]);
result == ISC_R_SUCCESS;
{
char zonename[DNS_NAME_FORMATSIZE];
char *viewname;
for (i = 0; i < ncounters; i++) {
"u %s",
zonestats[i],
zonename);
}
}
}
if (result == ISC_R_NOMORE)
(void)isc_stdio_close(fp);
return (result);
}
static isc_result_t
struct zonelistentry *zle;
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static isc_result_t
struct viewlistentry *vle;
return (ISC_R_NOMEMORY);
return (result);
}
static void
struct viewlistentry *vle;
struct zonelistentry *zle;
}
}
}
static void
const dns_master_style_t *style;
if (result != ISC_R_SUCCESS)
goto cleanup;
goto done;
}
/* start cache dump */
if (result == DNS_R_CONTINUE)
return;
if (result == ISC_R_NOTIMPLEMENTED)
else if (result != ISC_R_SUCCESS)
goto cleanup;
}
}
}
else
/* start zone dump */
if (result != ISC_R_SUCCESS) {
goto nextzone;
}
if (result == DNS_R_CONTINUE)
return;
if (result == ISC_R_NOTIMPLEMENTED)
if (result != ISC_R_SUCCESS)
goto cleanup;
}
}
goto nextview;
done:
if (result == ISC_R_SUCCESS)
"dumpdb complete");
if (result != ISC_R_SUCCESS)
}
char *ptr;
const char *sep;
return (ISC_R_NOMEMORY);
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
}
{
continue;
}
return (ISC_R_SUCCESS);
return (result);
}
return (result);
}
char *ptr;
char *levelstr;
char *endp;
long newlevel;
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* Look for the new level name. */
if (ns_g_debuglevel < 99)
} else {
return (ISC_R_RANGE);
ns_g_debuglevel = (unsigned int)newlevel;
}
return (ISC_R_SUCCESS);
}
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* Look for the view name. */
{
continue;
if (result != ISC_R_SUCCESS)
goto out;
}
if (flushed)
else
out:
return (result);
}
isc_buffer_t b;
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* Find the domain name to flush. */
return (ISC_R_UNEXPECTEDEND);
if (result != ISC_R_SUCCESS)
return (result);
/* Look for the view name. */
{
continue;
if (result != ISC_R_SUCCESS)
}
if (flushed)
else
return (result);
}
unsigned int n;
"number of zones: %u\n"
"debug level: %d\n"
"xfers running: %u\n"
"xfers deferred: %u\n"
"soa queries in progress: %u\n"
"query logging is %s\n"
"recursive clients: %d/%d\n"
"tcp clients: %d/%d\n"
"server is up and running",
if (n >= isc_buffer_availablelength(text))
return (ISC_R_NOSPACE);
isc_buffer_add(text, n);
return (ISC_R_SUCCESS);
}
/*
* Act on a "freeze" or "unfreeze" command from the command channel.
*/
char zonename[DNS_NAME_FORMATSIZE];
char *journal;
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_UNEXPECTEDEND);
if (type != dns_zone_master) {
return (ISC_R_NOTFOUND);
}
if (freeze) {
if (frozen)
if (result == ISC_R_SUCCESS)
if (result == ISC_R_SUCCESS) {
(void)isc_file_remove(journal);
}
} else {
if (frozen) {
if (result == DNS_R_CONTINUE ||
result == DNS_R_UPTODATE)
}
}
if (result == ISC_R_SUCCESS)
{
vname = "";
sep = "";
} else {
sep = " ";
}
sizeof(classstr));
"%s zone '%s/%s'%s%s: %s",
return (result);
}