server.c revision 2d13af354aa50ad491714cdf928f2c812ca6e923
/*
* Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* 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.547 2009/09/04 00:49:50 marka Exp $ */
/*! \file */
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <isc/parseint.h>
#include <isc/resource.h>
#include <isccfg/namedconf.h>
#include <dns/dispatch.h>
#ifdef DLZ
#endif
#include <dns/keytable.h>
#include <dns/keyvalues.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/statschannel.h>
#include <named/tkeyconf.h>
#include <named/tsigconf.h>
#include <named/zoneconf.h>
#ifdef HAVE_LIBSCF
#include <named/ns_smf_globals.h>
#include <stdlib.h>
#endif
/*%
* 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) \
/*%
* Maximum ADB size for views that share a cache. Use this limit to suppress
* the total of memory footprint, which should be the main reason for sharing
* a cache. Only effective when a finite max-cache-size is specified.
* This is currently defined to be 8MB.
*/
#define MAX_ADB_SIZE_FOR_CACHESHARE 8388608
struct ns_dispatch {
unsigned int dispatchgen;
};
struct ns_cache {
};
struct dumpcontext {
struct viewlistentry *view;
struct zonelistentry *zone;
};
struct viewlistentry {
};
struct zonelistentry {
};
/*
* These zones should not leak onto the Internet.
*/
static const struct {
const char *zone;
} empty_zones[] = {
#ifdef notyet
/* RFC 1918 */
{ "10.IN-ADDR.ARPA", ISC_TRUE },
{ "16.172.IN-ADDR.ARPA", ISC_TRUE },
{ "17.172.IN-ADDR.ARPA", ISC_TRUE },
{ "18.172.IN-ADDR.ARPA", ISC_TRUE },
{ "19.172.IN-ADDR.ARPA", ISC_TRUE },
{ "20.172.IN-ADDR.ARPA", ISC_TRUE },
{ "21.172.IN-ADDR.ARPA", ISC_TRUE },
{ "22.172.IN-ADDR.ARPA", ISC_TRUE },
{ "23.172.IN-ADDR.ARPA", ISC_TRUE },
{ "24.172.IN-ADDR.ARPA", ISC_TRUE },
{ "25.172.IN-ADDR.ARPA", ISC_TRUE },
{ "26.172.IN-ADDR.ARPA", ISC_TRUE },
{ "27.172.IN-ADDR.ARPA", ISC_TRUE },
{ "28.172.IN-ADDR.ARPA", ISC_TRUE },
{ "29.172.IN-ADDR.ARPA", ISC_TRUE },
{ "30.172.IN-ADDR.ARPA", ISC_TRUE },
{ "31.172.IN-ADDR.ARPA", ISC_TRUE },
{ "168.192.IN-ADDR.ARPA", ISC_TRUE },
#endif
/* RFC 3330 */
/* Local IPv6 Unicast Addresses */
{ "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA", ISC_FALSE },
{ "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA", ISC_FALSE },
/* LOCALLY ASSIGNED LOCAL ADDRESS SCOPE */
{ "D.F.IP6.ARPA", ISC_FALSE },
};
static void
static void
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
const cfg_obj_t *alternates);
static isc_result_t
static isc_result_t
static void
/*%
* Configure a single view ACL at '*aclp'. Get its configuration from
* 'vconfig' (for per-view configuration) and maybe from 'config'
*/
static isc_result_t
const char *aclname, const char *acltuplename,
{
int i = 0;
}
/*
* No value available. *aclp == NULL.
*/
return (ISC_R_SUCCESS);
if (acltuplename != NULL) {
/*
* If the ACL is given in an optional tuple, retrieve it.
* The parser should have ensured that a valid object be
* returned.
*/
}
return (result);
}
/*%
* Configure a sortlist at '*aclp'. Essentially the same as
* configure_view_acl() except it calls cfg_acl_fromconfig with a
* nest_level value of 2.
*/
static isc_result_t
{
int i = 0;
}
return (ISC_R_SUCCESS);
/*
* Use a nest level of 3 for the "top level" of the sortlist;
* this means each entry in the top three levels will be stored
* as lists of separate, nested ACLs, rather than merged together
* into IP tables as is usually done with ACLs.
*/
return (result);
}
static isc_result_t
const char *confname, const char *conftuplename,
{
const cfg_listelt_t *element;
int i = 0;
isc_buffer_t b;
const char *str;
}
/*
* No value available. *rbtp == NULL.
*/
return (ISC_R_SUCCESS);
if (conftuplename != NULL) {
if (cfg_obj_isvoid(obj))
return (ISC_R_SUCCESS);
}
if (result != ISC_R_SUCCESS)
return (result);
/*
* We don't need the node data, but need to set dummy data to
* avoid a partial match with an empty node. For example, if
* we have foo.example.com and bar.example.com, we'd get a match
* for baz.example.com, which is not the expected result.
* We simply use (void *)1 as the dummy data.
*/
if (result != ISC_R_SUCCESS) {
"failed to add %s for %s: %s",
goto cleanup;
}
}
return (result);
return (result);
}
static isc_result_t
{
const char *keystr, *keynamestr;
unsigned char keydata[4096];
unsigned char rrdata[4096];
isc_region_t r;
if (managed) {
const char *initmethod;
"managed key '%s': "
"invalid initialization method '%s'",
goto cleanup;
}
}
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);
"%s key '%s' has a weak exponent",
return (ISC_R_SUCCESS);
if (result == DST_R_NOCRYPTO) {
"ignoring %s key for '%s': no crypto support",
} else {
"configuring %s key for '%s': %s",
}
return (result);
}
static isc_result_t
{
&dstkey));
}
}
return (result);
}
/*%
* Configure DNSSEC keys for a view.
*
* The per-view configuration values and the server-global defaults are read
* from 'vconfig' and 'config'.
*/
static isc_result_t
{
int i = 0;
/* We don't need trust anchors for the _bind view */
return (ISC_R_SUCCESS);
}
&view_keys);
}
}
}
}
maps[i++] = ns_g_defaults;
if (result != ISC_R_SUCCESS) {
"couldn't create keytable");
return (ISC_R_UNEXPECTED);
}
if (global_managed_keys != NULL)
if (auto_dlv) {
"using built-in trusted-keys for view %s",
/*
* If bind.keys exists, it overrides the managed-keys
* clause hard-coded in ns_g_config.
*/
&builtin_keys);
} else {
&builtin_keys);
}
if (builtin_managed_keys != NULL)
}
return (result);
}
static isc_result_t
{
const cfg_listelt_t *element;
const char *str;
isc_buffer_t b;
{
}
return (result);
}
/*%
* Get a dispatch appropriate for the resolver of a given view.
*/
static isc_result_t
{
unsigned int maxdispatchbuffers;
/*
* 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;
}
if (isc_sockaddr_getport(&sa) == 0) {
maxdispatchbuffers = 4096;
} else {
if (is_firstview) {
"using specific query-source port "
"suppresses port randomization and can be "
"insecure.");
}
maxdispatchbuffers = 1000;
}
attrmask = 0;
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 = "*";
dns_rootname, 0, NULL);
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
* explicit entry for "." when the name is "*".
*/
if (addroot) {
if (result != ISC_R_SUCCESS)
return (result);
}
}
static isc_result_t
const char *str;
unsigned int prefixlen;
if (result != ISC_R_SUCCESS)
return (result);
if (udpsize < 512)
udpsize = 512;
if (udpsize > 4096)
udpsize = 4096;
}
if (udpsize < 512)
udpsize = 512;
if (udpsize > 4096)
udpsize = 4096;
}
else
INSIST(0);
}
if (result != ISC_R_SUCCESS)
goto cleanup;
}
else
if (result != ISC_R_SUCCESS)
goto cleanup;
}
else
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 cfg_obj_t *algorithms;
const cfg_listelt_t *element;
const char *str;
isc_buffer_t b;
{
if (result != ISC_R_SUCCESS) {
}
if (result != ISC_R_SUCCESS) {
"invalid algorithm");
}
}
return (result);
}
static isc_boolean_t
const cfg_listelt_t *element;
const char *str;
isc_buffer_t b;
{
0, NULL);
return (ISC_TRUE);
}
return (ISC_FALSE);
}
static void
{
unsigned int i;
if (result != ISC_R_SUCCESS) {
return;
}
/*
* Check that all the arguments match.
*/
for (i = 0; i < dbtypec; i++)
break;
}
/*
* Check that there are not extra arguments.
*/
}
static isc_result_t
zoneqrystats = NULL;
if (on) {
if (result != ISC_R_SUCCESS)
return (result);
}
if (zoneqrystats != NULL)
return (ISC_R_SUCCESS);
}
static ns_cache_t *
return (nsc);
}
return (NULL);
}
static isc_boolean_t
{
return (ISC_FALSE);
}
return (ISC_TRUE);
}
static isc_boolean_t
unsigned int new_cleaning_interval,
{
/*
* If the cache cannot even reused for the same view, it cannot be
* shared with other views.
*/
return (ISC_FALSE);
/*
* Check other cache related parameters that must be consistent among
* the sharing views.
*/
return (ISC_FALSE);
}
return (ISC_TRUE);
}
/*
* 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
{
const cfg_obj_t *forwardtype;
const cfg_obj_t *forwarders;
const cfg_obj_t *alternates;
#ifdef DLZ
unsigned int dlzargc;
char **dlzargv;
#endif
const cfg_listelt_t *element;
unsigned int cleaning_interval;
int i = 0, j = 0, k = 0;
const char *str;
unsigned int resopts = 0;
const char *sep = ": view ";
const char *forview = " for view ";
/*
* maps: view options, options, defaults
* cfgmaps: view options, config
* optionmaps: view options, options
*/
optionmaps[j++] = voptions;
}
optionmaps[j++] = options;
}
maps[i++] = ns_g_defaults;
optionmaps[j] = NULL;
sep = "";
viewname = "";
forview = "";
}
/*
* Set the view's port number for outgoing queries.
*/
/*
* Create additional cache for this view and zones under the view
* if explicitly enabled.
* XXX950 default to on.
*/
}
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));
}
#ifdef DLZ
/*
* Create Dynamically Loadable Zone driver.
*/
else
"database", &obj);
if (s == NULL) {
goto cleanup;
}
if (result != ISC_R_SUCCESS) {
isc_mem_free(mctx, s);
goto cleanup;
}
&view->dlzdatabase);
isc_mem_free(mctx, s);
if (result != ISC_R_SUCCESS)
goto cleanup;
}
}
#endif
/*
* Obtain configuration parameters that affect the decision of whether
*/
if (cfg_obj_isstring(obj)) {
} else {
if (value > ISC_UINT32_MAX) {
"'max-cache-size "
value);
goto cleanup;
}
}
/* Check-names. */
} else
INSIST(0);
/*
* Configure the view's cache.
*
* First, check to see if there are any attach-cache options. If yes,
* attempt to lookup an existing cache at attach it to the view. If
* there is not one, then try to reuse an existing cache if possible;
* otherwise create a new cache.
*
* Note that the ADB is not preserved or shared in either case.
*
* When a matching view is found, the associated statistics are also
* retrieved and reused.
*
* XXX Determining when it is safe to reuse or share 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. We check
* some of the configuration parameters that could invalidate the cache
* or otherwise make it unsharable, but there are other configuration
* options that should be checked. For example, if a view uses a
* forwarder, changes in the forwarder configuration may invalidate
* the cache. At the moment, it's the administrator's responsibility to
*/
if (result == ISC_R_SUCCESS)
else
"views %s and %s can't share the cache "
"due to configuration parameter mismatch",
goto cleanup;
}
} else {
&pview);
goto cleanup;
zero_no_soattl)) {
ISC_LOG_DEBUG(1),
"cache cannot be reused "
"for view %s due to "
"configuration parameter "
} else {
ISC_LOG_DEBUG(3),
"reusing existing cache");
}
}
}
/*
* Create a cache with the desired name. This normally
* equals the view name, but may also be a forward
* reference to a view that share the cache with this
* view but is not yet configured. If it is not the
* view name but not a forward reference either, then it
* is simply a named cache that is not shared.
*/
&cache));
}
goto cleanup;
}
}
/*
* cache-file cannot be inherited if views are present, but this
* should be caught by the configuration checking stage.
*/
if (!reused_cache && !shared_cache)
}
/*
* Resolver.
*
* XXXRTH Hardwired number of tasks.
*/
== NULL)));
== NULL)));
"unable to obtain neither an IPv4 nor"
" an IPv6 dispatch");
goto cleanup;
}
}
if (resquerystats == NULL)
/*
* Set the ADB cache size to 1/8th of the max-cache-size or
* MAX_ADB_SIZE_FOR_CACHESHARE when the cache is shared.
*/
max_adb_size = 0;
if (max_cache_size != 0) {
if (max_adb_size == 0)
if (!nsc->adbsizeadjusted) {
}
}
}
/*
* Set resolver's lame-ttl.
*/
if (lame_ttl > 1800)
lame_ttl = 1800;
/* Specify whether to use 0-TTL for negative response for SOA query */
/*
* Set the resolver's EDNS UDP size.
*/
if (udpsize < 512)
udpsize = 512;
if (udpsize > 4096)
udpsize = 4096;
/*
* Set the maximum UDP response 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.
*/
{
const cfg_listelt_t *element;
{
}
}
/*
* Configure the views rrset-order.
*/
{
const cfg_listelt_t *element;
{
}
}
/*
* 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'");
}
/*
* Set "allow-query-cache", "allow-query-cache-on",
* "allow-recursion", and "allow-recursion-on" acls if
* configured in named.conf.
*/
&view->recursionacl));
&view->recursiononacl));
}
/*
* "allow-query-cache" inherits from "allow-recursion" if set,
* otherwise from "allow-query" if set.
* "allow-recursion" inherits from "allow-query-cache" if set,
* otherwise from "allow-query" if set.
*/
/*
* Set default "allow-recursion", "allow-recursion-on" and
* "allow-query-cache" acls.
*/
"allow-recursion", NULL,
&view->recursionacl));
"allow-recursion-on", NULL,
&view->recursiononacl));
"allow-query-cache", NULL,
else {
}
}
/*
* Filter setting on addresses in the answer section.
*/
"except-from", ns_g_mctx,
&view->answeracl_exclude));
/*
*/
"name", ns_g_mctx,
&view->denyanswernames));
"except-from", ns_g_mctx,
&view->answernames_exclude));
/*
* Configure sortlist, if set
*/
/*
* Configure default allow-transfer, allow-notify, allow-update
* and allow-update-forwarding ACLs, if set, so they can be
* inherited by zones.
*/
if (result == ISC_R_SUCCESS) {
/* If set to "auto", use the version from the defaults */
"auto") &&
"dnssec-lookaside", &obj);
}
}
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"));
0, NULL));
#endif
"trust-anchor"));
}
} else
/*
* For now, there is only one kind of trusted keys, the
* "security roots".
*/
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;
const char *str;
0, NULL));
name));
}
}
} else
/*
* Setup automatic empty zones. If recursion is off then
* they are disabled by default.
*/
else
} else {
}
if (empty_zones_enable) {
const char *empty;
int empty_zone = 0;
const char *str;
const char *empty_dbtype[4] =
int empty_dbtypec = 4;
if (result == ISC_R_SUCCESS) {
NULL));
} else
if (result == ISC_R_SUCCESS) {
NULL));
} else
{
/*
* Look for zone on drop list.
*/
NULL));
if (disablelist != NULL &&
continue;
/*
* This zone already exists.
*/
continue;
}
/*
* If we would forward this name don't add a
* empty zone for it.
*/
&forwarders);
if (result == ISC_R_SUCCESS &&
continue;
if (logit) {
"Warning%s%s: "
"'empty-zones-enable/"
"disable-empty-zone' "
"not set: disabling "
"RFC 1918 empty zones",
}
continue;
}
/*
* See if we can re-use a existing zone.
*/
&pview);
if (result != ISC_R_NOTFOUND &&
result != ISC_R_SUCCESS)
goto cleanup;
empty_dbtype, mctx);
zonestats_on));
continue;
}
}
empty_dbtype));
ISC_TRUE);
"automatic empty zone%s%s: %s",
}
}
if (resquerystats != NULL)
return (result);
}
static isc_result_t
if (result == ISC_R_SUCCESS) {
dns_db_detach(&db);
}
return (result);
}
static isc_result_t
const cfg_obj_t *alternates)
{
const cfg_listelt_t *element;
/*
* 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)) {
alternate, "name"));
NULL));
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
{
const cfg_obj_t *faddresses;
const cfg_listelt_t *element;
/*
* 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
dns_view_t **viewp)
{
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 built-in zone for storing managed-key data.
*/
#define KEYZONE "managed-keys.bind"
static isc_result_t
if (!ns_g_server->managedkeys)
return (ISC_R_SUCCESS);
"set up %s meta-zone", KEYZONE);
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
const 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;
/*
* We always add non-wildcard address regardless of whether
* the port is 'any' (the fourth arg is TRUE): if the port is
* specific, we need to add it since it may conflict with a
* listening interface; if it's zero, we'll dynamically open
* query ports, and some of them may override an existing
* wildcard IPv6 port.
*/
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.
* There may also be old zones that are still in the process
* of shutting down and have detached from their old view
* (zoneview == NULL).
*/
continue;
;
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
}
}
static void
static unsigned int oldrequests = 0;
unsigned int requests = ns_client_requests;
/*
* Don't worry about wrapping as the overflow result will be right.
*/
}
/*
* 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
{
const char *resource;
return;
if (cfg_obj_isstring(obj)) {
else {
}
} else
result == ISC_R_SUCCESS ?
}
static void
}
static void
{
const cfg_listelt_t *element;
if (cfg_obj_isuint32(obj)) {
if (positive)
else
} else {
if (positive)
else {
hiport);
}
}
}
}
static isc_result_t
const char *type;
return (ISC_R_SUCCESS);
switch (dns_zone_gettype(zone)) {
case dns_zone_master:
type = "master";
break;
case dns_zone_slave:
type = "slave";
break;
case dns_zone_stub:
type = "stub";
break;
default:
type = "other";
break;
}
return (ISC_R_SUCCESS);
}
static void
}
}
server->session_keybits = 0;
}
static isc_result_t
{
char key_txtsecret[256];
char key_rawsecret[64];
"generating session key for dynamic DNS");
/* generate key */
if (result != ISC_R_SUCCESS)
return (result);
/*
* Dump the key to the buffer for later use. Should be done before
* we transfer the ownership of key to tsigkey.
*/
/* Store the key in tsigkey. */
&tsigkey));
/* Dump the key to the key file. */
"could not create %s", filename);
goto cleanup;
}
"\talgorithm %s;\n"
(int) isc_buffer_usedlength(&key_txtbuffer),
(char*) isc_buffer_base(&key_txtbuffer));
return (ISC_R_SUCCESS);
"failed to generate session key "
dst_key_free(&key);
return (result);
}
static isc_result_t
{
unsigned int algtype;
if (result == ISC_R_SUCCESS) {
if (cfg_obj_isvoid(obj))
else
} else
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS) {
const char *s = " (keeping current key)";
"unsupported or unknown algorithm '%s'%s",
return (result);
}
/* See if we need to (re)generate a new key. */
}
if (need_deleteold) {
}
if (need_createnew) {
goto cleanup;
goto cleanup;
&server->sessionkey));
}
return (result);
return (result);
}
static isc_result_t
{
const cfg_listelt_t *element;
const cfg_obj_t *builtin_views;
int i;
unsigned int maxsocks;
/* Ensure exclusive access to configuration data. */
/*
* Parse the global default pseudo-config file.
*/
if (first_time) {
&ns_g_defaults) == ISC_R_SUCCESS);
}
/*
* 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);
&cfg_type_namedconf, &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'",
if (conf_parser != NULL)
&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;
/*
* If bind.keys exists, load it. If "dnssec-lookaside auto"
* is turned on, the keys found there will be used as default
* trust anchors.
*/
"reading built-in trusted "
&bindkeys_parser));
}
/*
* Set process limits, which (usually) needs to be done as root.
*/
/*
* Check if max number of open sockets that the system allows is
* sufficiently large. Failing this condition is not necessarily fatal,
* but may cause subsequent runtime failures for a busy recursive
* server.
*/
if (result != ISC_R_SUCCESS)
maxsocks = 0;
" is smaller than max sockets (%u)",
}
/*
* Set the number of socket reserved for TCP, stdio etc.
*/
if (maxsocks != 0) {
reserved = 0;
}
if (reserved < 128U)
reserved = 128;
"less than 128 UDP sockets available after "
"applying 'reserved-sockets' and 'maxsockets'");
}
/*
* Configure various server options.
*/
&server->recursionquota);
else
"configuring statistics server(s)");
/*
* Configure sets of UDP query source ports.
*/
"creating UDP port set");
"creating UDP port set");
usev4ports = NULL;
usev6ports = NULL;
avoidv4ports = NULL;
avoidv6ports = NULL;
if (usev4ports != NULL)
else {
&udpport_high),
if (udpport_low == udpport_high)
else {
}
}
if (avoidv4ports != NULL)
if (usev6ports != NULL)
else {
&udpport_high),
if (udpport_low == udpport_high)
else {
}
}
if (avoidv6ports != NULL)
/*
* 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) {
}
/*
* Write the PID file.
*/
if (cfg_obj_isvoid(obj))
else
else if (ns_g_lwresdonly)
else
/*
* Configure the server-wide session key. This must be done before
* configure views because zone configuration may need to know
* session-keyname.
*
* Failure of session key generation isn't fatal at this time; if it
* turns out that a session key is really needed but doesn't exist,
* we'll treat it as a fatal error then.
*/
/*
* 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.
*/
}
/*
* Create (or recreate) the built-in views. Currently
* there is only one, the _bind view, but allow for others.
*/
&builtin_views) == ISC_R_SUCCESS);
{
}
}
/* Now combine the two viewlists into one */
/* Swap our new view list with the production one. */
/* Make the view list available to each of the views */
}
/* Swap our new cache 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)
/*
* Check that the working directory is writable.
*/
"the working directory is not writable");
}
/*
* 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) {
const cfg_listelt_t *element;
{
const char *str;
}
}
}
}
else
else if (ns_g_memstatistics)
ns_main_setmemstats("named.memstats");
else
"strdup");
"strdup");
"strdup");
if (result == ISC_R_SUCCESS) {
} else {
}
if (result == ISC_R_SUCCESS) {
} else {
}
/* The parser translates "hostname" to ISC_TRUE */
} else if (result == ISC_R_SUCCESS) {
/* Found a quoted string */
} else {
}
if (result == ISC_R_SUCCESS) {
} else {
}
if (conf_parser != NULL) {
}
if (bindkeys_parser != NULL) {
}
/*
* This cleans up either the old production view list
* or our temporary list depending on whether they
* were swapped above or not.
*/
if (result == ISC_R_SUCCESS &&
}
/* Same cleanup for cache list. */
}
/*
* 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 pps 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
}
}
if (ns_g_sessionkey != NULL) {
}
}
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_stats_create");
"isc_mem_strdup");
"isc_mem_strdup");
"isc_mem_strdup");
"dns_stats_create (server)");
&server->rcvquerystats),
"dns_stats_create (rcvquery)");
"dns_stats_create (opcode)");
"dns_stats_create (zone)");
"dns_stats_create (resolver)");
"ns_controls_create");
server->dispatchgen = 0;
server->session_keybits = 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) {
"reloading configuration succeeded");
} else {
"reloading configuration failed: %s",
}
return (result);
}
static isc_result_t
if (result == ISC_R_SUCCESS)
"reloading zones succeeded");
else
"reloading zones failed: %s",
return (result);
}
static void
if (result == ISC_R_SUCCESS)
"any newly configured zones are now loaded");
else
"loading new zones failed: %s",
cleanup: ;
}
/*
* Handle a reload event (from SIGHUP).
*/
static void
"received SIGHUP signal to reload zones");
}
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
} else {
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 msg1[] = "zone refresh queued";
const unsigned char msg2[] = "not a slave or stub zone";
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
}
return (ISC_R_FAILURE);
}
"query logging is now %s",
return (ISC_R_SUCCESS);
}
static isc_result_t
{
const cfg_listelt_t *element;
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);
}
(void)isc_stdio_close(fp);
if (result == ISC_R_SUCCESS)
"dumpstats complete");
else
"dumpstats failed: %s",
return (result);
}
static isc_result_t
struct zonelistentry *zle;
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static isc_result_t
struct viewlistentry *vle;
/*
* Prevent duplicate views.
*/
return (ISC_R_SUCCESS);
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;
} else
goto resume;
";\n; Cache of view '%s' is shared as '%s'\n",
{
/* start cache dump */
";\n; Cache dump of view '%s' (cache %s)\n;\n",
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) {
goto nextzone;
}
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;
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_NOMEMORY);
}
{
continue;
}
goto nextview;
}
return (ISC_R_SUCCESS);
return (result);
}
if (result == ISC_R_SUCCESS)
"dumprecursing complete");
else
"dumprecursing failed: %s",
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;
}
"debug level is now %d", ns_g_debuglevel);
return (ISC_R_SUCCESS);
}
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* Find out what we are to do. */
return (ISC_R_UNEXPECTEDEND);
else
return (DNS_R_SYNTAX);
/* Look for the view name. */
{
continue;
if (result != ISC_R_SUCCESS)
goto out;
}
if (changed)
else
out:
return (result);
}
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* Look for the view name. */
/*
* Flushing a cache is tricky when caches are shared by multiple views.
* We first identify which caches should be flushed in the local cache
* list, flush these caches, and then update other views that refer to
* the flushed cache DB.
*/
/*
* Mark caches that need to be flushed. This is an O(#view^2)
* operation in the very worst case, but should be normally
* much more lightweight because only a few (most typically just
* one) views will match.
*/
{
continue;
break;
}
}
} else
/* Perform flush */
continue;
if (result != ISC_R_SUCCESS) {
"flushing cache in view '%s' failed: %s",
}
}
/*
* Fix up views that share a flushed cache: let the views update the
* cache DB they're referring to. This could also be an expensive
* operation, but should typically be marginal: the inner loop is only
* necessary for views that share a cache, and if there are many such
* views the number of shared cache should normally be small.
* A worst case is that we have n views and n/2 caches, each shared by
* two views. Then this will be a O(n^2/4) operation.
*/
{
if (!dns_view_iscacheshared(view))
continue;
continue;
if (result != ISC_R_SUCCESS) {
"fixing cache in view '%s' "
}
}
}
/* Cleanup the cache list. */
}
"flushing cache in view '%s' succeeded",
viewname);
else
"flushing caches in all views succeeded");
} else {
if (!found) {
"flushing cache in view '%s' failed: "
"view not found", viewname);
} else
}
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;
/*
* It's a little inefficient to try flushing name for all views
* if some of the views share a single cache. But since the
* operation is lightweight we prefer simplicity here.
*/
if (result != ISC_R_SUCCESS) {
"flushing name '%s' in cache view '%s' "
}
}
"flushing name '%s' in cache view '%s' "
else
"flushing name '%s' in all cache views "
"succeeded", target);
} else {
if (!found)
"flushing name '%s' in cache view '%s' "
"failed: view not found", target,
viewname);
}
return (result);
}
unsigned int n;
if (ns_g_server->version_set) {
ob = " (";
cb = ")";
alt = "version.bind/txt/ch disabled";
else
}
"version: %s%s%s%s\n"
#ifdef ISC_PLATFORM_USETHREADS
"CPUs found: %u\n"
"worker threads: %u\n"
#endif
"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/%d\n"
"tcp clients: %d/%d\n"
"server is up and running",
#ifdef ISC_PLATFORM_USETHREADS
#endif
if (n >= isc_buffer_availablelength(text))
return (ISC_R_NOSPACE);
isc_buffer_add(text, n);
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned int *foundkeys)
{
char namestr[DNS_NAME_FORMATSIZE];
origin);
if (result == ISC_R_NOTFOUND) {
return (ISC_R_SUCCESS);
}
return (result);
}
for (;;) {
goto nextkey;
(*foundkeys)++;
goto again;
}
}
if (result == ISC_R_NOMORE)
break;
return (result);
}
}
return (ISC_R_SUCCESS);
}
unsigned int n;
unsigned int foundkeys = 0;
char *target;
char *viewname;
return (ISC_R_UNEXPECTEDEND);
&foundkeys);
if (result != ISC_R_SUCCESS) {
return (result);
}
}
}
"%d tsig keys deleted.\n", foundkeys);
if (n >= isc_buffer_availablelength(text)) {
return (ISC_R_NOSPACE);
}
isc_buffer_add(text, n);
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned int *foundkeys)
{
char namestr[DNS_NAME_FORMATSIZE];
char creatorstr[DNS_NAME_FORMATSIZE];
unsigned int n;
const char *viewname;
else
viewname = "(global)";
origin);
if (result == ISC_R_NOTFOUND) {
return (ISC_R_SUCCESS);
}
return (result);
}
for (;;) {
(*foundkeys)++;
sizeof(creatorstr));
"view \"%s\"; type \"dynamic\"; key \"%s\"; creator \"%s\";\n",
} else {
"view \"%s\"; type \"static\"; key \"%s\";\n",
}
if (n >= isc_buffer_availablelength(text)) {
return (ISC_R_NOSPACE);
}
isc_buffer_add(text, n);
}
if (result == ISC_R_NOMORE)
break;
return (result);
}
}
return (ISC_R_SUCCESS);
}
unsigned int n;
unsigned int foundkeys = 0;
&foundkeys);
if (result != ISC_R_SUCCESS) {
return (result);
}
&foundkeys);
if (result != ISC_R_SUCCESS) {
return (result);
}
}
if (foundkeys == 0) {
"no tsig keys found.\n");
if (n >= isc_buffer_availablelength(text)) {
return (ISC_R_NOSPACE);
}
isc_buffer_add(text, n);
}
return (ISC_R_SUCCESS);
}
/*
* Act on a "freeze" or "thaw" command from the command channel.
*/
{
char zonename[DNS_NAME_FORMATSIZE];
char *journal;
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS &&
tresult == ISC_R_SUCCESS)
}
"%s all zones: %s",
return (tresult);
}
if (type != dns_zone_master) {
return (ISC_R_NOTFOUND);
}
if (freeze) {
if (frozen) {
msg = "WARNING: The zone was already frozen.\n"
"Someone else may be editing it or "
"it may still be re-loading.";
}
if (result == ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
msg = "Flushing the zone updates to "
"disk failed.";
}
if (result == ISC_R_SUCCESS) {
(void)isc_file_remove(journal);
}
if (result == ISC_R_SUCCESS)
} else {
if (frozen) {
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_UPTODATE:
msg = "The zone reload and thaw was "
"successful.";
break;
case DNS_R_CONTINUE:
msg = "A zone reload and thaw was started.\n"
"Check the logs to see the result.";
break;
}
}
}
{
vname = "";
sep = "";
} else {
sep = " ";
}
sizeof(classstr));
"%s zone '%s/%s'%s%s: %s",
return (result);
}
#ifdef HAVE_LIBSCF
/*
* This function adds a message for rndc to echo if named
* is managed by smf and is also running chroot.
*/
unsigned int n;
"use svcadm(1M) to manage named");
if (n >= isc_buffer_availablelength(text))
return (ISC_R_NOSPACE);
isc_buffer_add(text, n);
return (ISC_R_SUCCESS);
}
#endif /* HAVE_LIBSCF */