server.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1999-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*! \file */
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <ctype.h>
#include <isc/commandline.h>
#include <isc/parseint.h>
#include <isc/refcount.h>
#include <isc/resource.h>
#include <isccfg/namedconf.h>
#include <dns/badcache.h>
#include <dns/dispatch.h>
#include <dns/keytable.h>
#include <dns/keyvalues.h>
#include <dns/masterdump.h>
#include <dns/portlist.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/resolver.h>
#include <dns/rriterator.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
#ifdef HAVE_GEOIP
#endif /* HAVE_GEOIP */
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
#ifndef SIZE_MAX
#endif
#ifndef SIZE_AS_PERCENT
#endif
#ifdef TUNE_LARGE
#define RESOLVER_NTASKS 523
#define UDPBUFFERS 32768
#define EXCLBUFFERS 32768
#else
#define RESOLVER_NTASKS 31
#define UDPBUFFERS 1000
#define EXCLBUFFERS 4096
#endif /* TUNE_LARGE */
/*%
* Check an operation for failure. Assumes that the function
* using it has a 'result' variable and a 'cleanup' label.
*/
} while (0)
if (tresult != ISC_R_SUCCESS) { \
isc_buffer_clear(*text); \
goto cleanup; \
} \
} 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 8388608U
struct ns_dispatch {
unsigned int dispatchgen;
};
struct ns_cache {
};
struct dumpcontext {
struct viewlistentry *view;
struct zonelistentry *zone;
};
struct viewlistentry {
};
struct zonelistentry {
};
/*%
* Configuration context to retain for each view that allows
* new zones to be added at runtime.
*/
typedef struct ns_cfgctx {
} ns_cfgctx_t;
/*%
* Holds state information for the initial zone loading process.
* Uses the isc_refcount structure to count the number of views
* with pending zone loads, dereferencing as each view finishes.
*/
typedef struct {
typedef struct {
typedef struct catz_chgzone_event {
ISC_EVENT_COMMON(struct catz_chgzone_event);
/*
* These zones should not leak onto the Internet.
*/
const char *empty_zones[] = {
/* RFC 1918 */
"10.IN-ADDR.ARPA",
"16.172.IN-ADDR.ARPA",
"17.172.IN-ADDR.ARPA",
"18.172.IN-ADDR.ARPA",
"19.172.IN-ADDR.ARPA",
"20.172.IN-ADDR.ARPA",
"21.172.IN-ADDR.ARPA",
"22.172.IN-ADDR.ARPA",
"23.172.IN-ADDR.ARPA",
"24.172.IN-ADDR.ARPA",
"25.172.IN-ADDR.ARPA",
"26.172.IN-ADDR.ARPA",
"27.172.IN-ADDR.ARPA",
"28.172.IN-ADDR.ARPA",
"29.172.IN-ADDR.ARPA",
"30.172.IN-ADDR.ARPA",
"31.172.IN-ADDR.ARPA",
"168.192.IN-ADDR.ARPA",
/* RFC 6598 */
"64.100.IN-ADDR.ARPA",
"65.100.IN-ADDR.ARPA",
"66.100.IN-ADDR.ARPA",
"67.100.IN-ADDR.ARPA",
"68.100.IN-ADDR.ARPA",
"69.100.IN-ADDR.ARPA",
"70.100.IN-ADDR.ARPA",
"71.100.IN-ADDR.ARPA",
"72.100.IN-ADDR.ARPA",
"73.100.IN-ADDR.ARPA",
"74.100.IN-ADDR.ARPA",
"75.100.IN-ADDR.ARPA",
"76.100.IN-ADDR.ARPA",
"77.100.IN-ADDR.ARPA",
"78.100.IN-ADDR.ARPA",
"79.100.IN-ADDR.ARPA",
"80.100.IN-ADDR.ARPA",
"81.100.IN-ADDR.ARPA",
"82.100.IN-ADDR.ARPA",
"83.100.IN-ADDR.ARPA",
"84.100.IN-ADDR.ARPA",
"85.100.IN-ADDR.ARPA",
"86.100.IN-ADDR.ARPA",
"87.100.IN-ADDR.ARPA",
"88.100.IN-ADDR.ARPA",
"89.100.IN-ADDR.ARPA",
"90.100.IN-ADDR.ARPA",
"91.100.IN-ADDR.ARPA",
"92.100.IN-ADDR.ARPA",
"93.100.IN-ADDR.ARPA",
"94.100.IN-ADDR.ARPA",
"95.100.IN-ADDR.ARPA",
"96.100.IN-ADDR.ARPA",
"97.100.IN-ADDR.ARPA",
"98.100.IN-ADDR.ARPA",
"99.100.IN-ADDR.ARPA",
"100.100.IN-ADDR.ARPA",
"101.100.IN-ADDR.ARPA",
"102.100.IN-ADDR.ARPA",
"103.100.IN-ADDR.ARPA",
"104.100.IN-ADDR.ARPA",
"105.100.IN-ADDR.ARPA",
"106.100.IN-ADDR.ARPA",
"107.100.IN-ADDR.ARPA",
"108.100.IN-ADDR.ARPA",
"109.100.IN-ADDR.ARPA",
"110.100.IN-ADDR.ARPA",
"111.100.IN-ADDR.ARPA",
"112.100.IN-ADDR.ARPA",
"113.100.IN-ADDR.ARPA",
"114.100.IN-ADDR.ARPA",
"115.100.IN-ADDR.ARPA",
"116.100.IN-ADDR.ARPA",
"117.100.IN-ADDR.ARPA",
"118.100.IN-ADDR.ARPA",
"119.100.IN-ADDR.ARPA",
"120.100.IN-ADDR.ARPA",
"121.100.IN-ADDR.ARPA",
"122.100.IN-ADDR.ARPA",
"123.100.IN-ADDR.ARPA",
"124.100.IN-ADDR.ARPA",
"125.100.IN-ADDR.ARPA",
"126.100.IN-ADDR.ARPA",
"127.100.IN-ADDR.ARPA",
/* RFC 5735 and RFC 5737 */
"0.IN-ADDR.ARPA", /* THIS NETWORK */
"127.IN-ADDR.ARPA", /* LOOPBACK */
"254.169.IN-ADDR.ARPA", /* LINK LOCAL */
"2.0.192.IN-ADDR.ARPA", /* TEST NET */
"100.51.198.IN-ADDR.ARPA", /* TEST NET 2 */
"113.0.203.IN-ADDR.ARPA", /* TEST NET 3 */
"255.255.255.255.IN-ADDR.ARPA", /* BROADCAST */
/* 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",
"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",
/* LOCALLY ASSIGNED LOCAL ADDRESS SCOPE */
"D.F.IP6.ARPA",
"8.E.F.IP6.ARPA", /* LINK LOCAL */
"9.E.F.IP6.ARPA", /* LINK LOCAL */
"A.E.F.IP6.ARPA", /* LINK LOCAL */
"B.E.F.IP6.ARPA", /* LINK LOCAL */
/* Example Prefix, RFC 3849. */
"8.B.D.0.1.0.0.2.IP6.ARPA",
/* RFC 7534 */
"EMPTY.AS112.ARPA",
};
ISC_PLATFORM_NORETURN_PRE 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
static void
newzone_cfgctx_destroy(void **cfgp);
static inline isc_result_t
static isc_result_t
static isc_result_t
static inline isc_result_t
putnull(isc_buffer_t **b);
static isc_result_t
/*%
* 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 if (result == DST_R_UNSUPPORTEDALG) {
"skipping %s key for '%s': %s",
} else {
"configuring %s key for '%s': %s",
}
return (result);
}
static isc_result_t
{
if (result == DST_R_UNSUPPORTEDALG) {
continue;
}
if (result != ISC_R_SUCCESS)
goto cleanup;
/*
* If keyname was specified, we only add that key.
*/
{
continue;
}
}
}
if (result == DST_R_NOCRYPTO)
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
{
const char *directory;
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 (result != ISC_R_SUCCESS) {
"couldn't create NTA table");
return (ISC_R_UNEXPECTED);
}
"using built-in DLV key 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_keys != NULL)
if (builtin_managed_keys != NULL)
}
"using built-in root key 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_keys != NULL)
if (builtin_managed_keys != NULL)
mctx));
}
}
/*
* Add key zone for managed-keys.
*/
if (result != ISC_R_SUCCESS) {
"invalid managed-keys-directory %s: %s",
goto cleanup;
}
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 = UDPBUFFERS;
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) {
} else {
if (is_firstview) {
"using specific query-source port "
"suppresses port randomization and can be "
"insecure.");
}
}
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);
#else
mode = 0;
#endif /* DNS_RDATASET_FIXED */
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 (ednsversion > 255)
ednsversion = 255;
}
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;
if (result != ISC_R_SUCCESS)
goto cleanup;
}
else
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != ISC_R_SUCCESS)
goto cleanup;
}
else
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != ISC_R_SUCCESS)
goto cleanup;
}
return (ISC_R_SUCCESS);
return (result);
}
static isc_result_t
const dns_dyndbctx_t *dctx)
{
/* Get the name of the dyndb instance and the library path . */
if (result != ISC_R_SUCCESS)
"dynamic database '%s' configuration failed: %s",
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_result_t
const cfg_listelt_t *element;
const char *str;
isc_buffer_t b;
{
/* disable_ds_digests handles numeric values. */
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 isc_result_t
{
unsigned int i;
/*
* Check that all the arguments match.
*/
for (i = 0; i < dbtypec; i++)
/*
* Check that there are not extra arguments.
*/
return (result);
}
static isc_result_t
zoneqrystats = NULL;
if (level == dns_zonestat_full) {
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);
}
/*
* Callback from DLZ configure when the driver sets up a writeable zone
*/
static isc_result_t
if (result != ISC_R_SUCCESS)
return (result);
}
static isc_result_t
const char *contact)
{
char *cp;
const char *sep = ": view ";
const unsigned char *s6;
int dns64_dbtypec = 4;
isc_buffer_t b;
sep = "";
viewname = "";
}
/*
* Construct the reverse name of the zone.
*/
while (prefixlen > 0) {
prefixlen -= 8;
cp += 4;
}
/*
* Create the actual zone.
*/
return (result);
}
static isc_result_t
{
if (result != ISC_R_SUCCESS)
return (result);
}
static isc_result_t
{
if (result != ISC_R_SUCCESS)
"invalid zone '%s'", str);
return (result);
}
static isc_result_t
{
const char *str;
"limit of %d response policy zones exceeded",
return (ISC_R_FAILURE);
}
"no memory for response policy zones");
return (ISC_R_NOMEMORY);
}
if (result != ISC_R_SUCCESS) {
return (result);
}
} else {
}
} else {
}
if (cfg_obj_isuint32(obj)) {
} else {
}
*old_rpz_okp = ISC_FALSE;
if (result != ISC_R_SUCCESS)
return (result);
"invalid zone name '%s'", str);
return (DNS_R_EMPTYLABEL);
}
"duplicate '%s'", str);
return (result);
}
}
*old_rpz_okp = ISC_FALSE;
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
DNS_RPZ_PASSTHRU_NAME, "name");
if (result != ISC_R_SUCCESS)
return (result);
DNS_RPZ_DROP_NAME, "name");
if (result != ISC_R_SUCCESS)
return (result);
DNS_RPZ_TCP_ONLY_NAME, "name");
if (result != ISC_R_SUCCESS)
return (result);
if (cfg_obj_isvoid(obj)) {
} else {
str, "cname");
if (result != ISC_R_SUCCESS)
return (result);
}
}
*old_rpz_okp = ISC_FALSE;
return (ISC_R_SUCCESS);
}
static isc_result_t
{
const cfg_listelt_t *zone_element;
const dns_rpz_zones_t *old;
const dns_rpz_zone_t *old_zone;
int i;
*old_rpz_okp = ISC_FALSE;
if (zone_element == NULL)
return (ISC_R_SUCCESS);
if (result != ISC_R_SUCCESS)
return (result);
if (!cfg_obj_isvoid(sub_obj) &&
else
if (!cfg_obj_isvoid(sub_obj) &&
else
if (cfg_obj_isuint32(sub_obj))
else
if (cfg_obj_isuint32(sub_obj))
else
else
else
if (result == ISC_R_SUCCESS) {
} else {
}
*old_rpz_okp = ISC_FALSE;
else
*old_rpz_okp = ISC_TRUE;
for (i = 0;
zone_element != NULL;
} else {
*old_rpz_okp = ISC_FALSE;
}
if (result != ISC_R_SUCCESS) {
return (result);
}
}
/*
* If this is a reloading and the parameters and list of policy
* zones are unchanged, then use the same policy data.
* Data for individual zones that must be reloaded will be merged.
*/
*old_rpz_okp = ISC_FALSE;
if (*old_rpz_okp) {
"updated RPZ policy: version %d",
}
return (ISC_R_SUCCESS);
}
static void
char nameb[DNS_NAME_FORMATSIZE];
"catz: allow-new-zones statement missing from "
"config; cannot add zone from the catalog");
goto cleanup;
}
isc_buffer_putuint8(&namebuf, 0);
/* Zone shouldn't already exist */
if (result != ISC_R_SUCCESS) {
"catz: error \"%s\" while trying to "
"modify zone \"%s\"",
nameb);
goto cleanup;
} else {
if (!dns_zone_getadded(zone)) {
"catz: catz_addmodzone_taskaction: "
"zone '%s' is not a dynamically "
"added zone",
nameb);
goto cleanup;
}
"catz: catz_delzone_taskaction: "
"zone '%s' exists in multiple "
"catalog zones",
nameb);
goto cleanup;
}
}
} else {
"catz: error \"%s\" while trying to "
"add zone \"%s\"",
nameb);
goto cleanup;
} else { /* this can happen in case of DNS_R_PARTIALMATCH */
}
}
/* Create a config for new zone */
if (result != ISC_R_SUCCESS) {
"catz: error \"%s\" while trying to generate "
"config for zone \"%s\"",
goto cleanup;
}
if (!cfg_obj_islist(zlist))
/* For now we only support adding one zone at a time */
/* Mark view unfrozen so that zone can be added */
if (result != ISC_R_SUCCESS) {
"catz: failed to configure zone \"%s\" - %d",
goto cleanup;
}
/* Is it there yet? */
/*
* Load the zone from the master file. If this fails, we'll
* need to undo the configuration we've done already.
*/
if (result != ISC_R_SUCCESS) {
"catz: dns_zone_loadnew() failed "
"with %s; reverting.",
/* If the zone loaded partially, unload it */
dns_db_detach(&dbp);
}
/* Remove the zone from the zone table */
goto cleanup;
}
/* Flag the zone as having been added at runtime */
}
static void
char cname[DNS_NAME_FORMATSIZE];
const char * file;
if (result != ISC_R_SUCCESS) {
"catz: catz_delzone_taskaction: "
"zone '%s' not found", cname);
goto cleanup;
}
if (!dns_zone_getadded(zone)) {
"catz: catz_delzone_taskaction: "
"zone '%s' is not a dynamically added zone",
cname);
goto cleanup;
}
"catz: catz_delzone_taskaction: zone "
"'%s' exists in multiple catalog zones",
cname);
goto cleanup;
}
/* Stop answering for this zone */
dns_db_detach(&dbp);
}
"catz: catz_delzone_taskaction: "
"zone '%s' deleted", cname);
}
static isc_result_t
{
switch (type) {
case DNS_EVENT_CATZADDZONE:
case DNS_EVENT_CATZMODZONE:
break;
case DNS_EVENT_CATZDELZONE:
break;
default:
REQUIRE(0);
}
sizeof(*event));
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static isc_result_t
{
}
static isc_result_t
{
}
static isc_result_t
{
}
static isc_result_t
const cfg_listelt_t *element)
{
const char *str;
if (result != ISC_R_SUCCESS) {
"catz: invalid zone name '%s'", str);
goto cleanup;
}
"catz: unable to create catalog zone '%s', "
"error %s",
goto cleanup;
}
if (result == ISC_R_EXISTS) {
/*
* xxxwpk todo: reconfigure the zone!!!!
*/
"catz: catalog zone '%s' will not be reconfigured",
str);
/*
* We have to walk through all the member zones and attach
* them to current view
*/
if (result != ISC_R_SUCCESS) {
"catz: unable to create iterator");
goto cleanup;
}
result == ISC_R_SUCCESS;
{
}
}
"catz: zone-directory '%s' "
"not found; zone files will not be "
}
}
return (result);
}
static catz_cb_data_t ns_catz_cbdata;
static dns_catz_zonemodmethods_t ns_catz_zonemodmethods = {
};
static isc_result_t
{
const cfg_listelt_t *zone_element;
/* xxxwpk TODO do it cleaner, once, somewhere */
if (zone_element == NULL)
return (ISC_R_SUCCESS);
if (result == ISC_R_SUCCESS)
}
while (zone_element != NULL) {
}
return (result);
}
do { \
if (!(cond)) { \
result = ISC_R_RANGE; \
goto cleanup; \
} \
} while (0)
do { \
if (result == ISC_R_SUCCESS) { \
name" %d > %d", \
} else { \
} \
} while (0)
static isc_result_t
int min_entries, i, j;
/*
* Most DNS servers have few clients, but intentinally open
* recursive and authoritative servers often have many.
* So start with a small number of entries unless told otherwise
* to reduce cold-start costs.
*/
min_entries = 500;
if (result == ISC_R_SUCCESS) {
if (min_entries < 1)
min_entries = 1;
}
if (result != ISC_R_SUCCESS)
return (result);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
CHECK_RRL(i >= min_entries,
"max-table-size %d < min-table-size %d",
i, min_entries);
}
rrl->max_entries = i;
"responses-per-second");
"referrals-per-second");
"nodata-per-second");
"nxdomains-per-second");
"errors-per-second");
"all-per-second");
"slip");
i = 15;
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
"window %d < 1 or > %d", i, DNS_RRL_MAX_WINDOW);
}
i = 0;
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
}
i = 24;
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
"invalid 'ipv4-prefix-length %d'%s", i, "");
}
rrl->ipv4_prefixlen = i;
if (i == 32)
else
i = 56;
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
"ipv6-prefix-length %d < 16 or > %d",
i, DNS_RRL_MAX_PREFIX);
}
rrl->ipv6_prefixlen = i;
for (j = 0; j < 4; ++j) {
if (i <= 0) {
} else if (i < 32) {
} else {
}
i -= 32;
}
if (result == ISC_R_SUCCESS) {
"invalid %s%s", "address match list", "");
}
else
return (ISC_R_SUCCESS);
return (result);
}
static isc_result_t
{
unsigned char buf[DNS_SOA_BUFFERSIZE];
return (result);
}
static isc_result_t
{
isc_buffer_t b;
unsigned char buf[DNS_NAME_MAXWIRE];
&ns, &b));
return (result);
}
static isc_result_t
{
char namebuf[DNS_NAME_FORMATSIZE];
const cfg_listelt_t *element;
const char *sep = ": view ";
const char *str;
dns_name_t *ns;
int rbt_dbtypec = 1;
int order;
unsigned int nlabels;
/*
* Look for forward "zones" beneath this empty zone and if so
* create a custom db for the empty zone.
*/
if (namereln != dns_namereln_subdomain)
continue;
continue;
continue;
}
else
0, NULL));
0, NULL));
}
}
/*
* Is the existing zone the ok to use?
*/
unsigned int typec;
const char **dbargv;
typec = rbt_dbtypec;
dbargv = rbt_dbtype;
} else {
}
if (result != ISC_R_SUCCESS)
}
}
}
empty_dbtype));
}
else
else
else
}
sep = "";
viewname = "";
}
ISC_LOG_INFO, "automatic empty zone%s%s: %s",
dns_db_detach(&db);
return (result);
}
#ifdef HAVE_DNSTAP
static isc_result_t
const cfg_listelt_t *element;
const char *dpath = ns_g_defaultdnstap;
dns_dtmsgtype_t dttypes = 0;
if (result != ISC_R_SUCCESS)
return (ISC_R_SUCCESS);
{
const char *str;
dns_dtmsgtype_t dt = 0;
}
continue;
}
dt &= ~DNS_DTTYPE_RESPONSE;
dt &= ~DNS_DTTYPE_QUERY;
}
}
"'dnstap-output' must be set if 'dnstap' is set");
else
&ns_g_server->dtenv),
"unable to create dnstap environment");
}
return (ISC_R_SUCCESS);
if (result != ISC_R_SUCCESS) {
/* not specified; use the product and version */
/* Quoted string */
}
/* "hostname" is interpreted as boolean ISC_TRUE */
char buf[256];
if (result == ISC_R_SUCCESS)
/* Quoted string */
}
return (result);
}
#endif /* HAVE_DNSTAP */
/*
* 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;
unsigned int dlzargc;
char **dlzargv;
const cfg_obj_t *dyndb_list;
const cfg_listelt_t *element;
unsigned int cleaning_interval;
int i = 0, j = 0, k = 0;
const char *str;
unsigned int resopts = 0;
unsigned int query_timeout, ndisp;
/*
* 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;
/*
* 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)) {
max_acache_size = 0;
} else {
"'max-acache-size "
"is too large for this "
"system; reducing to %lu",
}
}
}
}
/*
* Make the list of response policy zone names for a view that
* is used for real lookups and so cares about hints.
*/
}
}
/*
* Configure the zones.
*/
else
/*
* Load zone configuration
*/
{
ISC_FALSE));
}
/*
* Check that a master or slave zone was found for each
* zone named in the response policy statement.
*/
{
char namebuf[DNS_NAME_FORMATSIZE];
"'%s' is not a master or slave zone",
namebuf);
goto cleanup;
}
}
}
/*
* If we're allowing added zones, then load zone configuration
* from the newzone file for zones that were added during previous
* runs.
*/
"loading additional zones for view '%s'",
{
}
}
/*
* Create Dynamically Loadable Zone driver.
*/
else
{
if (s == NULL) {
goto cleanup;
}
&dlzargv, 0);
if (result != ISC_R_SUCCESS) {
isc_mem_free(mctx, s);
goto cleanup;
}
&dlzdb);
isc_mem_free(mctx, s);
if (result != ISC_R_SUCCESS)
goto cleanup;
/*
* If the DLZ backend supports configuration,
* and is searchable, then call its configure
* method now. If not searchable, we'll take
* care of it when we process the zone statement.
*/
if (result != ISC_R_SUCCESS)
goto cleanup;
} else {
}
}
}
/*
* Obtain configuration parameters that affect the decision of whether
*/
if (cfg_obj_isstring(obj)) {
max_cache_size = 0;
} else if (cfg_obj_ispercentage(obj)) {
} else {
"'max-cache-size "
"is too large for this "
"system; reducing to %lu",
}
}
if (max_cache_size == SIZE_AS_PERCENT) {
if (totalphys == 0) {
"Unable to determine amount of physical "
"memory, setting 'max-cache-size' to "
"unlimited");
} else {
"'max-cache-size %d%%' "
"- setting to %zuMB (out of %zuMB)",
}
}
/* Check-names. */
} else
INSIST(0);
unsigned int prefixlen;
if (result == ISC_R_SUCCESS)
else
if (result == ISC_R_SUCCESS)
else
{
unsigned int dns64options = 0;
&prefixlen);
} else
if (result != ISC_R_SUCCESS)
goto cleanup;
}
if (result != ISC_R_SUCCESS)
goto cleanup;
}
if (result != ISC_R_SUCCESS)
goto cleanup;
}
dns64options, &dns64);
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != ISC_R_SUCCESS)
goto cleanup;
}
}
if (cfg_obj_isboolean(obj)) {
} else {
/* If dnssec-validation is not boolean, it must be "auto" */
}
/*
* 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.
*
* We use two separate memory contexts for the
* cache, for the main cache memory and the heap
* memory.
*/
&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)
if (dscp4 == -1)
if (dscp6 == -1)
if (dscp4 != -1)
if (dscp6 != -1)
/*
* 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 != 0U) {
if (max_adb_size == 0U)
if (!nsc->adbsizeadjusted) {
}
}
}
/*
* Set up ADB quotas
*/
{
if (!cfg_obj_isvoid(obj2)) {
isc_result_t r;
r = DNS_R_DROP;
r = DNS_R_SERVFAIL;
else
INSIST(0);
dns_quotatype_server, r);
}
}
/*
* Set resolver's lame-ttl.
*/
if (lame_ttl > 1800)
lame_ttl = 1800;
/*
* Set the resolver's query timeout.
*/
/* 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 the maximum UDP when a COOKIE is not provided.
*/
if (udpsize < 128)
udpsize = 128;
/*
* Set the maximum rsa exponent bits.
*/
maxbits = 35;
if (maxbits > 4096)
maxbits = 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.
*/
}
/*
* See if we can re-use a dynamic key ring.
*/
goto cleanup;
} else
/*
* 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'");
}
/*
* 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.
*/
/*
* XXXEACH: This call to configure_view_acl() is redundant. We
* are leaving it as it is because we are making a minimal change
* for a patch release. In the future this should be changed to
* dns_acl_attach(view->queryacl, &view->cacheacl).
*/
/*
* 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
}
/*
* Ignore case when compressing responses to the specified
* clients. This causes case not always to be preserved,
* and is needed by some broken clients.
*/
/*
* Disable name compression completely, this is a tradeoff
* between CPU and network usage.
*/
/*
* 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 (!cfg_obj_isvoid(obj2)) {
isc_result_t r;
r = DNS_R_DROP;
r = DNS_R_SERVFAIL;
else
INSIST(0);
dns_quotatype_zone, r);
}
#ifdef ALLOW_FILTER_AAAA
if (cfg_obj_isboolean(obj)) {
if (cfg_obj_asboolean(obj))
else
} else {
else
INSIST(0);
}
if (cfg_obj_isboolean(obj)) {
if (cfg_obj_asboolean(obj))
else
} else {
else
INSIST(0);
}
#endif
if (result == ISC_R_SUCCESS) {
if (cfg_obj_isvoid(eligible)) {
int m;
"prefetch", &obj);
if (cfg_obj_isuint32(eligible))
break;
}
}
}
if (result == ISC_R_SUCCESS) {
/* If set to "auto", use the version from the defaults */
const char *dom;
/* If "no", skip; if "auto", use global default */
"dnssec-lookaside", &obj);
}
}
}
if (result == ISC_R_SUCCESS) {
dns_fixedname_init(&f);
iscdlv = dns_fixedname_name(&f);
{
if (auto_dlv)
"WARNING: the DLV server at "
"'dlv.isc.org' is expected to "
"cease operation by the end "
"of 2017");
}
}
} 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)
{
0, NULL));
}
} else
/*
* Load DynDB modules.
*/
dyndb_list = NULL;
else
{
const void *hashinit = isc_hash_get_initializer();
ns_g_timermgr, &dctx));
}
}
/*
* Setup automatic empty zones. If recursion is off then
* they are disabled by default.
*/
else
} else {
}
if (empty_zones_enable && !lwresd_g_useresolvconf) {
const char *empty;
int empty_zone = 0;
const char *empty_dbtype[4] =
int empty_dbtypec = 4;
if (result == ISC_R_SUCCESS) {
0, NULL));
} else
if (result == ISC_R_SUCCESS) {
0, NULL));
} else
if (cfg_obj_isboolean(obj)) {
if (cfg_obj_asboolean(obj))
else
} else {
else
INSIST(0);
}
{
/*
* Look for zone on drop list.
*/
if (disablelist != NULL &&
continue;
/*
* This zone already exists.
*/
continue;
}
/*
* If we would forward this name don't add a
* empty zone for it.
*/
if (result == ISC_R_SUCCESS &&
continue;
/*
* See if we can re-use a existing zone.
*/
&pview);
if (result != ISC_R_NOTFOUND &&
result != ISC_R_SUCCESS)
goto cleanup;
}
statlevel));
}
}
if (result == ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto cleanup;
}
/*
* Set the servfail-ttl.
*/
if (fail_ttl > 30)
fail_ttl = 30;
/*
* Name space to look up redirect information in.
*/
if (result == ISC_R_SUCCESS) {
NULL));
} else
#ifdef HAVE_DNSTAP
/*
* Set up the dnstap environment and configure message
* types to log.
*/
#endif /* HAVE_DNSTAP */
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);
}
}
}
/*
* DSCP value for forwarded requests.
*/
if (forwarders != NULL) {
if (cfg_obj_isuint32(dscpobj)) {
"dscp value '%u' is out of range",
return (ISC_R_RANGE);
}
}
}
faddresses = NULL;
if (forwarders != NULL)
{
goto cleanup;
}
}
if (ISC_LIST_EMPTY(fwdlist)) {
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(fwdlist)) {
}
return (result);
}
static isc_result_t
{
const char *viewname;
&viewclass));
if (dns_rdataclass_ismeta(viewclass)) {
"view '%s': class must not be meta",
viewname);
}
} else {
viewname = "_default";
}
return (result);
}
/*
* Find a view based on its configuration info and attach to it.
*
* If 'vconfig' is NULL, attach to the default view.
*/
static isc_result_t
dns_view_t **viewp)
{
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_SUCCESS);
}
/*
* 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)
{
if (result != ISC_R_SUCCESS)
return (result);
if (result == ISC_R_SUCCESS)
return (ISC_R_EXISTS);
if (result != ISC_R_NOTFOUND)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS) {
return (result);
}
#ifdef HAVE_GEOIP
#endif
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;
}
"'in-view' option is not permitted in "
"dynamically added zones");
goto cleanup;
}
&otherview);
if (result != ISC_R_SUCCESS) {
"view '%s' is not yet defined.", inview);
goto cleanup;
}
if (result != ISC_R_SUCCESS) {
"zone '%s' not defined in view '%s'",
goto cleanup;
}
/*
* If the zone contains a 'forwarders' statement, configure
* selective forwarding. Note: this is not inherited from the
* other view.
*/
forwarders = NULL;
if (result == ISC_R_SUCCESS) {
forwardtype = NULL;
}
goto cleanup;
}
"zone '%s' 'type' not specified", zname);
goto cleanup;
}
/*
* "hints zones" aren't zones. If we've got one,
* configure it and return.
*/
"zone '%s': 'file' not specified",
zname);
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;
forwardtype));
/*
* Forward zones may also set delegation only.
*/
goto cleanup;
}
/*
* "delegation-only zones" aren't zones either.
*/
goto cleanup;
}
/*
* Redirect zones only require minimal configuration.
*/
"redirect zone already exists");
goto cleanup;
}
goto cleanup;
} else {
&zone));
zone));
}
goto cleanup;
}
if (!modify) {
/*
* 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;
}
}
/*
* Note whether this is a response policy zone and which one if so.
*/
break;
}
break;
}
/*
* 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)
* - The zone was not and is still not a response policy zone
* or the zone is a policy zone with an unchanged number
* and we are using the old policy zone summary data.
*/
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 (rpz_num != DNS_RPZ_INVALID_NUM) {
if (result != ISC_R_SUCCESS) {
"zone '%s': incompatible"
" masterfile-format or database"
" for a response policy zone",
zname);
goto cleanup;
}
}
if (zone_is_catz)
/*
* 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))
}
/*
* Mark whether the zone was originally added at runtime or not
*/
{
}
}
/*
* Configure the zone.
*/
/*
* Add the zone to its view in the new view list.
*/
if (!modify)
if (zone_is_catz) {
/*
* force catz reload if the zone is loaded;
* if it's not it'll get reloaded on zone load
*/
if (tresult == ISC_R_SUCCESS) {
dns_db_detach(&db);
}
}
/*
* Ensure that zone keys are reloaded on reconfig
*/
return (result);
}
/*
* Configure built-in zone for storing managed-key data.
*/
static isc_result_t
/* See if we can re-use an existing keydata zone. */
&pview);
if (result != ISC_R_NOTFOUND &&
result != ISC_R_SUCCESS)
return (result);
return (ISC_R_SUCCESS);
}
/* No existing keydata zone was found; create one */
"set up managed keys zone for view %s, file '%s'",
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 isc_result_t
#ifdef HAVE_GEOIP
#endif
/*
* Update the "localhost" and "localnets" ACLs to match the
* current set of network interfaces.
*/
#ifdef HAVE_GEOIP
#endif
return (result);
}
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.
*/
/* XXXMPA fix dscp */
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. It is also called by ns_server_scan_interfaces(),
* invoked by "rndc scan"
*/
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;
case dns_zone_staticstub:
type = "static-stub";
break;
case dns_zone_redirect:
type = "redirect";
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));
dst_key_free(&key);
return (ISC_R_SUCCESS);
"failed to generate session key "
(void)isc_stdio_close(fp);
(void)isc_file_remove(filename);
}
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
{
int i = 0;
if (result == ISC_R_SUCCESS)
maps[i++] = ns_g_defaults;
if (result == ISC_R_SUCCESS)
/*
* A non-empty catalog-zones statement implies allow-new-zones
*/
if (!allow) {
if (result == ISC_R_SUCCESS) {
const cfg_listelt_t *e =
if (e != NULL)
}
}
if (!allow) {
return (ISC_R_SUCCESS);
}
return (ISC_R_NOMEMORY);
}
/*
* We attach the parser that was used for config as well
* as the one that will be used for added zones, to avoid
* a shutdown race later.
*/
/*
* This may be called in multiple views, so we reset
* the parser each time.
*/
if (result == ISC_R_FILENOTFOUND)
return (result);
}
static int
const cfg_listelt_t *element;
int n = 0;
n++;
return (n);
}
static isc_result_t
{
int i;
i = 0;
if (result == ISC_R_SUCCESS)
maps[i++] = ns_g_defaults;
if (!first_time) {
"changing 'lock-file' "
"has no effect until the "
"server is restarted");
return (ISC_R_SUCCESS);
}
if (cfg_obj_isvoid(obj)) {
"skipping lock-file check ");
return (ISC_R_SUCCESS);
} else if (ns_g_forcelock) {
"'lock-file' has no effect "
"because the server was run with -X");
} else {
filename);
}
return (ISC_R_NOMEMORY);
}
}
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
"could not lock %s; another named "
return (ISC_R_FAILURE);
}
static isc_result_t
{
const cfg_listelt_t *element;
const cfg_obj_t *builtin_views;
int i;
int num_zones = 0;
unsigned int maxsocks;
isc_uint32_t softquota = 0;
/* Create the ACL configuration context */
if (ns_g_aclconfctx != NULL)
/*
* Shut down all dyndb instances.
*/
/*
* Parse the global default pseudo-config file.
*/
if (first_time) {
if (result != ISC_R_SUCCESS)
ns_main_earlyfatal("unable to load "
"internal defaults: %s",
&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-validation auto"
* is turned on, the root key found there will be used as a
* default trust anchor, and if "dnssec-lookaside auto" is
* turned on, then the DLV key found there will too.
*/
"reading built-in trusted "
&bindkeys_parser));
}
/* Ensure exclusive access to configuration data. */
if (!exclusive) {
}
/*
* Set process limits, which (usually) needs to be done as root.
*/
/*
* Check the process lockfile.
*/
/*
* 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'");
}
#ifdef HAVE_GEOIP
/*
* Initialize GeoIP databases from the configured location.
* This should happen before configuring any ACLs, so that we
* know what databases are available and can reject any GeoIP
* ACLs that can't work.
*/
char *dir;
} else
#endif /* HAVE_GEOIP */
/*
* Configure various server options.
*/
&server->recursionquota);
"'recursive-clients %d' too low when "
"running with %d worker threads",
}
} else
&server->blackholeacl));
&server->keepresporder));
"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 (!ns_g_disable4)
}
if (avoidv4ports != NULL)
if (usev6ports != NULL)
else {
&udpport_high),
if (udpport_low == udpport_high)
else {
}
if (!ns_g_disable6)
}
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;
/* Set the transfer message size for TCP */
if (transfer_message_size < 512)
transfer_message_size = 512;
else if (transfer_message_size > 65535)
transfer_message_size = 65535;
/*
* Configure the zone manager.
*/
/*
* Determine which port to use for listening for incoming connections.
*/
if (ns_g_port != 0)
else
/*
* Determing the default DSCP code point.
*/
/*
* Find the listen queue depth.
*/
ns_g_listen = 10;
/*
* 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.
*/
/* check return code? */
&listenon);
} else if (!ns_g_lwresdonly) {
/*
* Not specified, use default.
*/
}
listenon);
}
}
/*
* Ditto for IPv6.
*/
{
/* check return code? */
&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.
*/
/*
* Check that named is able to TCP listen on at least one
* interface. Otherwise, another named process could be running
* and we should fail.
*/
"unable to listen on any configured interfaces");
goto cleanup;
}
/*
* Arrange for further interface scanning to occur periodically
* as specified by the "interface-interval" option.
*/
if (interface_interval == 0) {
}
/*
* Enable automatic interface scans.
*/
/*
* 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.
*/
/*
* Create the views and count all the configured zones in
* order to correctly size the zone manager's task table.
* (We only count zones for configured views; the built-in
* "bind" view can be ignored as it only adds a negligible
* number of zones.)
*
* If we're allowing new zones, we need to be able to find the
* new zone file and count those as well. So we setup the new
* zone configuration context, but otherwise view configuration
* waits until after the zone manager's task list has been sized.
*/
{
}
/*
* If there were no explicit views then we do the default
* view here.
*/
}
/*
* Zones have been counted; set the zone manager task pool size.
*/
"sizing zone task pool based on %d zones", num_zones);
/*
* 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.
*/
}
/*
* Create (or recreate) the built-in views.
*/
&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).
*/
"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) {
"not using config file logging "
"statement for logging due to "
"-g option");
if (result != ISC_R_SUCCESS) {
"checking logging configuration "
"failed: %s",
goto cleanup;
}
}
} else {
"creating new logging configuration");
"configuring logging");
} else {
"setting up default logging channels");
"setting up default 'category unmatched'");
"setting up default 'category default'");
}
"installing logging configuration");
"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 char *str;
}
}
}
}
else
else if (ns_g_memstatistics)
ns_main_setmemstats("named.memstats");
else
"strdup");
"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 defined(HAVE_OPENSSL_AES) || defined(HAVE_OPENSSL_EVP_AES)
#else
INSIST(0);
#endif
else
INSIST(0);
if (result == ISC_R_SUCCESS) {
isc_buffer_t b;
unsigned int usedlength;
goto cleanup;
usedlength = isc_buffer_usedlength(&b);
case ns_cookiealg_aes:
if (usedlength != ISC_AES128_KEYLENGTH)
"AES cookie-secret must be 128 bits");
break;
case ns_cookiealg_sha1:
if (usedlength != ISC_SHA1_DIGESTLENGTH)
"SHA1 cookie-secret must be 160 bits");
break;
case ns_cookiealg_sha256:
if (usedlength != ISC_SHA256_DIGESTLENGTH)
"SHA256 cookie-secret must be 256 bits");
break;
}
} else {
NULL,
0);
if (result != ISC_R_SUCCESS)
goto cleanup;
}
(void) ns_server_loadnta(server);
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)
/*
* Record the time of most recent configuration
*/
if (tresult != ISC_R_SUCCESS)
ns_main_earlyfatal("isc_time_now() failed: %s",
/* Relinquish exclusive access to configuration data. */
if (exclusive)
return (result);
}
static isc_result_t
view_loaded(void *arg) {
unsigned int refs;
/*
* 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.
*
* We use the zoneload reference counter to let us
* know when all views are finished.
*/
if (refs != 0)
return (ISC_R_SUCCESS);
/*
* To maintain compatibility with log parsing tools that might
* be looking for this string after "rndc reconfig", we keep it
* as it is
*/
if (reconfig) {
"any newly configured zones are now loaded");
} else {
"all zones loaded");
}
"forcing zone maintenance");
ISC_LOG_NOTICE, "running");
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned int refs = 0;
return (ISC_R_NOMEMORY);
/*
* Schedule zones to be loaded from disk.
*/
{
if (result != ISC_R_SUCCESS &&
result != DNS_R_UPTODATE &&
result != DNS_R_CONTINUE)
goto cleanup;
}
if (result != ISC_R_SUCCESS &&
result != DNS_R_UPTODATE &&
result != DNS_R_CONTINUE)
goto cleanup;
}
/*
* 'dns_view_asyncload' calls view_loaded if there are no
* zones.
*/
}
if (refs == 0) {
} else if (init) {
/*
* Place the task manager into privileged mode. This
* ensures that after we leave task-exclusive mode, no
* other tasks will be able to run except for the ones
* that are loading zones. (This should only be done during
* the initial server setup; it isn't necessary during
* a reload.)
*/
}
return (result);
}
static void
"creating dispatch manager");
"creating interface manager");
"creating interface timer");
"creating heartbeat timer");
"creating pps timer");
"creating default configuration parser");
"creating additional configuration parser");
if (ns_g_lwresdonly)
ISC_TRUE),
"loading configuration");
else
"loading configuration");
#ifdef ENABLE_AFL
#endif
}
void
}
static void
ISC_LOG_INFO, "shutting down%s",
if (ns_g_aclconfctx != NULL)
(void) ns_server_saventa(server);
if (flush)
else
}
}
if (ns_g_sessionkey != NULL) {
}
#ifdef HAVE_DNSTAP
#endif
#ifdef HAVE_GEOIP
#endif
}
void
/* Initialize configuration data with default values. */
#ifdef HAVE_GEOIP
/* Initialize GeoIP before using ACL environment */
#endif
/* Initialize server data structures. */
/* Must be first. */
"initializing DST");
&server->in_roothints),
"setting up root hints");
"initializing reload event lock");
sizeof(isc_event_t));
"allocating reload event");
"creating TKEY context");
/*
* Setup the server task, which is responsible for coordinating
* startup and shutdown of the server, as well as all exclusive
* tasks.
*/
"creating server task");
"isc_task_onshutdown");
"isc_app_onrun");
server->interface_interval = 0;
server->heartbeat_interval = 0;
"dns_zonemgr_create");
"dns_zonemgr_setsize");
"isc_mem_strdup");
"isc_stats_create");
"isc_mem_strdup");
"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 (rcode)");
"dns_stats_create (zone)");
"dns_stats_create (resolver)");
"dns_stats_create (inbound UDP IPv4 traffic size)");
"dns_stats_create (outbound UDP IPv4 traffic size)");
"dns_stats_create (inbound UDP IPv6 traffic size)");
"dns_stats_create (outbound UDP IPv6 traffic size)");
"dns_stats_create (inbound TCP IPv4 traffic size)");
"dns_stats_create (outbound TCP IPv4 traffic size)");
"dns_stats_create (inbound TCP IPv6 traffic size)");
"dns_stats_create (outbound TCP IPv6 traffic size)");
"ns_controls_create");
server->dispatchgen = 0;
server->session_keybits = 0;
}
void
#ifdef HAVE_DNSTAP
#endif /* HAVE_DNSTAP */
}
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;
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);
}
/*
* Handle a reload event (from SIGHUP).
*/
static void
"received SIGHUP signal to reload zones");
}
void
}
void
"automatic interface rescan");
}
/*
* Get the next token from lexer 'lex'.
*
* NOTE: the token value for string tokens always uses the same pointer
* value. Multiple calls to this function on the same lexer will always
* return either that value (lex->data) or NULL. It is necessary to copy
* the token into local storage if it needs to be referenced after the next
* call to next_token().
*/
static char *
&token);
switch (result) {
case ISC_R_NOMORE:
(void) isc_lex_close(lex);
break;
case ISC_R_SUCCESS:
(void) isc_lex_close(lex);
break;
case ISC_R_NOSPACE:
}
return (NULL);
default:
}
return (NULL);
}
return (NULL);
}
/*
* Find the zone specified in the control channel command, if any.
* If a zone is specified, point '*zonep' at it, otherwise
* set '*zonep' to NULL, and f 'zonename' is not NULL, copy
* the zone name into it (N.B. 'zonename' must have space to hold
* a full DNS name).
*
* If 'zonetxt' is set, the caller has already pulled a token
* off the command line that is to be used as the zone name. (This
* is sometimes done when it's necessary to check for an optional
* argument before the zone name, as in "rndc sync [-clean] zone".)
*/
static isc_result_t
{
char *ptr;
char *classtxt;
char zonebuf[DNS_NAME_FORMATSIZE];
if (skip) {
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
}
/* Look for the zone name. */
return (ISC_R_SUCCESS);
/* Copy zonetxt because it'll be overwritten by next_token() */
/* Look for the optional class name. */
/* Look for the optional view name. */
} else
if (result == ISC_R_NOTFOUND)
"no matching zone '%s' in any view",
zonebuf);
else if (result == ISC_R_MULTIPLE)
"zone '%s' was found in multiple views",
zonebuf);
} else {
if (result != ISC_R_SUCCESS) {
"no matching view '%s'", viewtxt);
goto report;
}
if (result != ISC_R_SUCCESS)
"no matching zone '%s' in view '%s'",
}
/* Partial match? */
if (result == DNS_R_PARTIALMATCH)
if (result != ISC_R_SUCCESS) {
if (tresult == ISC_R_SUCCESS)
}
return (result);
}
/*
* Act on a "retransfer" command from the command channel.
*/
isc_buffer_t **text)
{
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_UNEXPECTEDEND);
}
else
return (result);
}
/*
* Act on a "reload" command from the command channel.
*/
isc_buffer_t **text)
{
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.
*/
if (result == ISC_R_SUCCESS)
"scheduled loading new zones");
else
"loading new zones failed: %s",
return (result);
}
/*
* Act on a "notify" command from the command channel.
*/
isc_buffer_t **text)
{
const 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.
*/
isc_buffer_t **text)
{
const char msg1[] = "zone refresh queued";
const 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);
}
char *ptr;
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
else
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
"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 (!cfg_obj_isuint32(dscpobj))
else {
"dscp 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);
/* also dump zones */
/* this is the default */
/* only dump zones, suppress caches */
/* only dump adb, suppress other caches */
/* only dump badcache, suppress other caches */
/* only dump servfail cache, suppress other caches */
}
{
continue;
}
goto nextview;
}
return (ISC_R_SUCCESS);
return (result);
}
isc_buffer_t **text)
{
char *ptr;
char tbuf[64];
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* "-" here means print the output instead of dumping to file */
else {
if (result != ISC_R_SUCCESS) {
}
}
do {
{
continue;
if (result == ISC_R_NOTFOUND) {
continue;
}
if (result == ISC_R_NOTFOUND) {
continue;
}
}
if (isc_buffer_usedlength(*text) > 0) {
else
}
(char *) isc_buffer_base(*text));
(void)isc_stdio_close(fp);
}
if (result == ISC_R_SUCCESS)
"dumpsecroots complete");
else
"dumpsecroots failed: %s",
return (result);
}
{
}
if (result == ISC_R_SUCCESS)
"dumprecursing complete");
else
"dumprecursing failed: %s",
return (result);
}
char *ptr;
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);
}
isc_buffer_t **text)
{
char *ptr;
/* 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 (set) {
} else {
if (!first)
? "enabled" : "disabled"));
}
}
if (!set)
else if (changed)
else
return (result);
}
char *ptr;
/* 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",
ptr);
else
"flushing caches in all views succeeded");
} else {
if (!found) {
"flushing cache in view '%s' failed: "
"view not found", ptr);
} else
}
return (result);
}
char target[DNS_NAME_FORMATSIZE];
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 %s '%s' in cache view '%s' "
"failed: %s",
}
}
"flushing %s '%s' in cache view '%s' "
"succeeded",
else
"flushing %s '%s' in all cache views "
"succeeded",
target);
} else {
if (!found)
"flushing %s '%s' in cache view '%s' "
"failed: view not found",
}
return (result);
}
unsigned int automatic;
if (ns_g_server->version_set) {
ob = " (";
cb = ")";
alt = "version.bind/txt/ch disabled";
else
}
sizeof(boottime));
sizeof(configtime));
if (result != ISC_R_SUCCESS)
hostname, ns_os_uname());
if (ns_g_chrootdir != NULL) {
} else {
}
#ifdef ISC_PLATFORM_USETHREADS
#else
#endif
return (ISC_R_SUCCESS);
return (result);
}
char *ptr;
unsigned long count;
unsigned long i;
const unsigned char chars[] = "abcdefghijklmnopqrstuvwxyz0123456789";
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
count = 26;
else
for (i = 0; i < count; i++)
return (result);
}
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);
}
isc_buffer_t **text)
{
unsigned int foundkeys = 0;
char target[DNS_NAME_FORMATSIZE];
char fbuf[16];
return (ISC_R_UNEXPECTEDEND);
&foundkeys);
if (result != ISC_R_SUCCESS) {
return (result);
}
}
}
return (result);
}
static isc_result_t
unsigned int *foundkeys)
{
char namestr[DNS_NAME_FORMATSIZE];
char creatorstr[DNS_NAME_FORMATSIZE];
const char *viewname;
else
viewname = "(global)";
origin);
if (result == ISC_R_NOTFOUND) {
return (ISC_R_SUCCESS);
}
return (result);
}
for (;;) {
sizeof(creatorstr));
if (*foundkeys != 0)
"\"; type \"dynamic\"; key \""));
} else {
if (*foundkeys != 0)
"\"; type \"static\"; key \""));
}
(*foundkeys)++;
}
break;
}
return (ISC_R_SUCCESS);
return (result);
}
unsigned int foundkeys = 0;
&foundkeys);
if (result != ISC_R_SUCCESS) {
return (result);
}
&foundkeys);
if (result != ISC_R_SUCCESS) {
return (result);
}
}
if (foundkeys == 0)
if (isc_buffer_usedlength(*text) > 0)
return (result);
}
/*
* Act on a "sign" or "loadkeys" command from the command channel.
*/
char *ptr;
return (ISC_R_UNEXPECTEDEND);
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_UNEXPECTEDEND); /* XXX: or do all zones? */
if (type != dns_zone_master) {
return (DNS_R_NOTMASTER);
}
/* "rndc loadkeys" requires "auto-dnssec maintain". */
if ((keyopts & DNS_ZONEKEY_ALLOW) == 0)
else
return (result);
}
/*
* Act on a "sync" command from the command channel.
*/
static isc_result_t
char *journal;
}
if (result != ISC_R_SUCCESS)
if (cleanup) {
(void)isc_file_remove(journal);
}
return (result);
}
char zonename[DNS_NAME_FORMATSIZE];
}
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS &&
tresult == ISC_R_SUCCESS)
}
"dumping all zones%s: %s",
return (tresult);
}
{
vname = "";
sep = "";
} else {
sep = " ";
}
sizeof(classstr));
"sync: dumping zone '%s/%s'%s%s%s: %s",
return (result);
}
/*
* Act on a "freeze" or "thaw" command from the command channel.
*/
{
char zonename[DNS_NAME_FORMATSIZE];
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 (DNS_R_NOTMASTER);
}
return (DNS_R_NOTDYNAMIC);
}
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)
} 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.
*/
}
#endif /* HAVE_LIBSCF */
/*
* Emit a comment at the top of the nzf file containing the viewname
* Expects the fp to already be open for writing
*/
#define HEADER1 "# New zone file for view: "
#define HEADER2 "\n# This file contains configuration for zones added by\n" \
"# the 'rndc addzone' command. DO NOT EDIT BY HAND.\n"
static isc_result_t
return (result);
}
#if 0
/*
* XXXMPA When we move to using a database instead of a flat file
* we will use nzf_remove. Remember that we need to use a cannonical
* form of the zone name when we do.
*/
static isc_result_t
/* Rewrite zone list */
size_t n;
/* Create a temporary file */
/* Look for the entry for that zone */
/* Skip initial comment, if any */
continue;
if (*buf != '#')
/*
* Any other lines not starting with zone, copy
* them out and continue.
*/
continue;
}
p = buf+4;
/* This is a zone; find its name. */
while (*p &&
((*p == '"') || isspace((unsigned char)*p)))
p++;
/*
* If it's not the zone we're looking for, copy
* it out and continue
*/
continue;
}
/*
* But if it is the zone we want, skip over it
* so it will be omitted from the new file
*/
p += znamelen;
if (isspace((unsigned char)*p) ||
*p == '"' || *p == '{') {
/* This must be the entry */
found = p;
break;
}
/* Copy the buffer out and continue */
}
/* Skip over an option block (matching # of braces) */
if (found) {
int openbrace = 0, closebrace = 0;
for (;;) {
while (*p) {
if (*p == '{') openbrace++;
if (*p == '}') closebrace++;
p++;
}
break;
break;
p = buf;
}
/* Just spool the remainder of the file out */
while (n > 0U) {
}
/*
* Close files before overwriting the nzfile
* with the temporary file as it's necessary on
* some platforms (win32).
*/
(void) isc_stdio_close(ifp);
(void) isc_stdio_close(ofp);
/* Move temporary into place */
} else {
"deleted zone %s was missing from "
"new zone file", zonename);
goto cleanup;
}
}
(void) isc_stdio_close(ifp);
(void) isc_stdio_close(ofp);
return (result);
}
#endif
static void
}
static isc_result_t
if (offset == 0)
return (result);
}
static isc_result_t
isc_buffer_t **text)
{
const char *bn;
/* Try to parse the argument string */
bn = "addzone";
bn = "modzone";
else
INSIST(0);
/*
* Convert the "addzone" or "modzone" to just "zone", for
* the benefit of the parser
*/
&cfg_type_addzoneconf, &zoneconf));
if (! cfg_obj_islist(zlist))
/* For now we only support adding one zone at a time */
/* Make sense of optional class argument */
/* Make sense of optional view argument */
viewname = "_default";
&view);
if (result == ISC_R_NOTFOUND) {
goto cleanup;
} else if (result != ISC_R_SUCCESS) {
goto cleanup;
}
return (ISC_R_SUCCESS);
return (result);
}
static isc_result_t
char tmp[1024];
if (result == ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS)
return (result);
return (result);
(void) isc_stdio_close(fp);
return (result);
}
static isc_result_t
const dns_name_t *zname)
{
if (! cfg_obj_islist(zl))
return (ISC_R_FAILURE);
{
const char *zn;
cfg_listelt_t *e;
continue;
return (ISC_R_SUCCESS);
}
return (ISC_R_NOTFOUND);
}
static isc_result_t
isc_buffer_t **text)
{
/* Zone shouldn't already exist */
if (result == ISC_R_SUCCESS) {
goto cleanup;
} else if (result == DNS_R_PARTIALMATCH) {
/* Create our sub-zone anyway */
} else if (result != ISC_R_NOTFOUND)
goto cleanup;
/* Make sure we can open the configuration save file */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
/* Mark view unfrozen so that zone can be added */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
/* Is it there yet? */
/*
* If there wasn't a previous newzone config, just save the one
* we've created. If there was a previous one, merge the new
* zone into it.
*/
else {
cfg_obj_t *z;
}
/*
* Load the zone from the master file. If this fails, we'll
* need to undo the configuration we've done already.
*/
if (result != ISC_R_SUCCESS) {
"addzone failed; reverting.");
/* If the zone loaded partially, unload it */
dns_db_detach(&dbp);
}
/* Remove the zone from the zone table */
goto cleanup;
}
/* Flag the zone as having been added at runtime */
/* Emit the zone configuration */
(void) isc_stdio_close(fp);
return (result);
}
static isc_result_t
isc_buffer_t **text)
{
cfg_obj_t *z;
/* Zone must already exist */
if (result != ISC_R_SUCCESS)
goto cleanup;
/* Make sure we can open the configuration save file */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
}
/* Reconfigure the zone */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
/* Is it there yet? */
/* Remove old zone from configuration (and NZF file if applicable) */
if (added) {
/* nzf_remove(view->new_zone_file, view->name, zname); */
} else {
else {
}
}
/* Load the zone from the master file if it needs reloading. */
if (result != ISC_R_SUCCESS) {
"modzone failed; removing zone.");
/* If the zone loaded partially, unload it */
dns_db_detach(&dbp);
}
/* Remove the zone from the zone table */
goto cleanup;
}
/* Store the new zone configuration; also in NZF if applicable */
if (added) {
(void) isc_stdio_close(fp);
} else {
}
return (result);
}
/*
* Act on an "addzone" or "modzone" command from the command channel.
*/
const char *zonename;
else {
}
/* Are we accepting new zones in this view? */
goto cleanup;
}
goto cleanup;
}
if (addzone)
else
"%s zone %s in view %s via %s",
/* Changing a zone counts as reconfiguration */
if (isc_buffer_usedlength(*text) > 0)
return (result);
}
static isc_boolean_t
if (first)
"The following files were in use "
"and may now be removed:\n");
else
return (ISC_FALSE);
}
return (first);
}
/*
* Act on a "delzone" command from the command channel.
*/
char zonename[DNS_NAME_FORMATSIZE];
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* Find out what we are to do. */
return (ISC_R_UNEXPECTEDEND);
}
goto cleanup;
}
/* Is this a policy zone? */
"' cannot be deleted: response-policy zone."));
goto cleanup;
}
/* Dig out configuration for this zone */
/* Remove the zone from the new_zone_file if applicable */
} else {
}
}
/* Stop answering for this zone */
dns_db_detach(&dbp);
}
/* Clean up stub / slave zone files */
if (!added) {
} else if (cleanup) {
}
{
}
}
"zone %s removed via delzone", zonename);
/* Removing a zone counts as reconfiguration */
if (isc_buffer_usedlength(*text) > 0)
if (exclusive)
return (result);
}
/*
* Act on a "showzone" command from the command channel.
*/
static const cfg_obj_t *
const char *map_key_for_list,
const char *name)
{
const cfg_listelt_t *element;
}
{
const char *vname;
continue;
}
if (result == ISC_R_SUCCESS &&
break;
break;
}
return (obj);
}
static void
}
char zonename[DNS_NAME_FORMATSIZE];
/* Parse parameters */
goto cleanup;
}
goto cleanup;
}
/* Find the view statement */
/* Find the zone statement */
else
"zone", zonename);
if (isc_buffer_usedlength(*text) > 0)
if (exclusive)
return (result);
}
static void
newzone_cfgctx_destroy(void **cfgp) {
}
}
}
static isc_result_t
int i, n;
union {
unsigned char rnd[256];
} rnd;
isc_region_t r;
if (saltlen > 256U)
return (ISC_R_RANGE);
for (i = 0; i < n; i++)
"generated salt: %s", text);
return (ISC_R_SUCCESS);
}
isc_uint32_t serial = 0;
unsigned char salt[255];
const char *ptr;
size_t n;
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
/* Find out what we are to do. */
return (ISC_R_UNEXPECTEDEND);
{
return (ISC_R_UNEXPECTEDEND);
char nbuf[256];
return (ISC_R_UNEXPECTEDEND);
hash = 0;
else {
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDEND);
if (n == sizeof(nbuf))
return (ISC_R_NOSPACE);
if (n != 3U)
return (ISC_R_BADNUMBER);
return (ISC_R_RANGE);
return (ISC_R_UNEXPECTEDEND);
/* Auto-generate a random salt.
* XXXMUKS: This currently uses the
* minimum recommended length by RFC
* 5155 (64 bits). It should be made
* configurable.
*/
saltlen = 8;
}
}
return (ISC_R_UNEXPECTEDEND);
} else
if (clear) {
} else if (chain) {
ISC_TRUE));
} else if (setserial) {
} else if (list) {
if (result == ISC_R_NOTFOUND) {
goto cleanup;
}
result == ISC_R_SUCCESS;
{
if (!first)
}
if (!first)
if (result == ISC_R_NOMORE)
}
if (dns_rdataset_isassociated(&privset))
dns_db_detach(&db);
return (result);
}
static isc_result_t
if (result != ISC_R_SUCCESS)
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static inline isc_result_t
}
static isc_result_t
if (result != ISC_R_SUCCESS)
return (ISC_R_NOSPACE);
isc_buffer_putuint8(*b, val);
return (ISC_R_SUCCESS);
}
static inline isc_result_t
putnull(isc_buffer_t **b) {
return (putuint8(b, 0));
}
isc_buffer_t **text)
{
char zonename[DNS_NAME_FORMATSIZE];
char lbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
char xbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
char rbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
char kbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
int nfiles = 0;
goto cleanup;
}
switch (zonetype) {
case dns_zone_master:
type = "master";
break;
case dns_zone_slave:
type = "slave";
break;
case dns_zone_stub:
type = "stub";
break;
case dns_zone_staticstub:
type = "staticstub";
break;
case dns_zone_redirect:
type = "redirect";
break;
case dns_zone_key:
type = "key";
break;
case dns_zone_dlz:
type = "dlz";
break;
default:
type = "unknown";
}
/* Inline signing? */
if (hasraw)
/* Serial number */
if (hasraw) {
}
/* Database node count */
/* Security */
DNS_ZONEKEY_MAINTAIN) != 0);
/* Master files */
/* Load time */
if (zonetype == dns_zone_slave ||
zonetype == dns_zone_stub ||
{
}
/* Key refresh time */
if (zonetype == dns_zone_master ||
{
sizeof(kbuf));
}
/* Dynamic? */
if (zonetype == dns_zone_master) {
}
/* Next resign event */
{
if (result == ISC_R_SUCCESS) {
char namebuf[DNS_NAME_FORMATSIZE];
char typebuf[DNS_RDATATYPE_FORMATSIZE];
sizeof(rtbuf));
}
}
/* Create text */
int i;
for (i = 0; i < nfiles; i++) {
}
}
if (hasraw) {
}
if (! isc_time_isepoch(&loadtime)) {
}
if (! isc_time_isepoch(&refreshtime)) {
}
if (! isc_time_isepoch(&expiretime)) {
}
if (secure) {
if (hasraw)
else
} else
if (maintain) {
if (! isc_time_isepoch(&refreshkeytime)) {
}
} else if (allow)
if (!isc_time_isepoch(&resigntime)) {
}
if (dynamic) {
if (frozen)
else
} else
/* Indicate truncated output if possible. */
if (result == ISC_R_NOSPACE)
dns_db_detach(&db);
int i;
for (i = 0; i < nfiles; i++)
}
return (result);
}
static inline isc_boolean_t
size_t l;
return (ISC_FALSE);
cmd++;
return (ISC_FALSE);
return (ISC_TRUE);
}
isc_buffer_t **text)
{
char namebuf[DNS_NAME_FORMATSIZE];
isc_time_t t;
char tbuf[64];
/* Skip the command name. */
return (ISC_R_UNEXPECTEDEND);
for (;;) {
/* Check for options */
return (ISC_R_UNEXPECTEDEND);
ntattl = 0;
continue;
msg = "No lifetime specified";
}
if (result != ISC_R_SUCCESS) {
msg = "could not parse NTA lifetime";
}
if (ntattl > 604800) {
msg = "NTA lifetime cannot exceed one week";
}
continue;
} else
break;
}
/*
* If -dump was specified, list NTA's and return
*/
if (dump) {
{
if (result == ISC_R_NOTFOUND)
continue;
}
goto cleanup;
}
if (readonly) {
"rejecting restricted control channel "
"NTA command");
}
/* Get the NTA name. */
return (ISC_R_UNEXPECTEDEND);
/* Copy nametext as it'll be overwritten by next_token() */
else {
isc_buffer_t b;
}
/* Look for the view name. */
{
continue;
if (view->nta_lifetime == 0)
continue;
if (!ttlset)
if (result == ISC_R_NOTFOUND) {
continue;
}
"flush tree '%s' in cache view '%s': %s",
if (ntattl != 0) {
isc_time_set(&t, when, 0);
"added NTA '%s' (%d sec) in view '%s'",
} else {
"removed NTA '%s' in view %s",
}
if (result != ISC_R_SUCCESS) {
"error writing NTA file "
"for view '%s': %s",
}
}
}
if (excl)
return (result);
}
{
if (result != ISC_R_SUCCESS) {
"error writing NTA file "
"for view '%s': %s",
}
}
return (ISC_R_SUCCESS);
}
{
if ((result != ISC_R_SUCCESS) &&
(result != ISC_R_FILENOTFOUND) &&
(result != ISC_R_NOTFOUND))
{
"error loading NTA file "
"for view '%s': %s",
}
}
return (ISC_R_SUCCESS);
}
static isc_result_t
return (result);
}
static isc_result_t
result == ISC_R_SUCCESS;
{
continue;
char nbuf[DNS_NAME_FORMATSIZE];
}
result == ISC_R_SUCCESS;
{
char alg[DNS_SECALG_FORMATSIZE];
char tbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
isc_region_t r;
isc_time_t t;
dns_rdata_toregion(&rdata, &r);
isc_region_consume(&r, 12);
? " SEP" : "",
"\n\tnext refresh: %s", tbuf);
sizeof(tbuf));
"\n\tremove at: %s", tbuf);
}
else if (revoked)
"\n\ttrust revoked");
"\n\ttrusted since: %s", tbuf);
"\n\ttrust pending: %s", tbuf);
}
}
if (result == ISC_R_NOMORE)
}
dns_db_detach(&db);
return (result);
}
static isc_result_t
char msg[ISC_FORMATHTTPTIMESTAMP_SIZE];
isc_time_t t;
if (isc_time_isepoch(&t)) {
} else {
}
return (result);
}
/* Skip rndc command name */
return (ISC_R_UNEXPECTEDEND);
/* Get managed-keys subcommand */
return (ISC_R_UNEXPECTEDEND);
else {
goto cleanup;
}
/* Look for the optional class name. */
/* Look for the optional view name. */
}
} else {
if (result != ISC_R_SUCCESS) {
} else {
"unknown class '%s'", classtxt);
goto cleanup;
}
}
}
{
continue;
"view '%s': no managed keys", viewtxt);
goto cleanup;
} else
continue;
}
switch (opt) {
case REFRESH:
break;
case STATUS:
if (!first)
break;
case SYNC:
break;
default:
INSIST(0);
}
break;
}
if (!found)
if (isc_buffer_usedlength(*text) > 0)
return (result);
}
#if HAVE_DNSTAP
return (ISC_R_NOTFOUND);
#else
return (ISC_R_NOTIMPLEMENTED);
#endif
}