server.c revision 534057c9f91a3eb6e0541f3526459c716239b337
/*
* Copyright (C) 1999-2017 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/fixedname.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>
#ifdef HAVE_GEOIP
#endif /* HAVE_GEOIP */
#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_LMDB
#include <lmdb.h>
#define count_newzones count_newzones_db
#define dumpzone dumpzone_db
#else /* HAVE_LMDB */
#define count_newzones count_newzones_file
#define dumpzone dumpzone_file
#endif /* HAVE_LMDB */
#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;
/*%
* A function to write out added-zone configuration to the new_zone_file
* specified in 'view'. Maybe called by delete_zoneconf().
*/
/*%
* 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 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 int
#ifdef HAVE_LMDB
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
static void
static isc_result_t
static isc_result_t
#else
static isc_result_t
#endif
/*%
* Configure a single view ACL at '*aclp'. Get its configuration from
* 'vconfig' (for per-view configuration) and maybe from 'config'
*/
static isc_result_t
{
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);
}
/*%
* Check whether a key has been successfully loaded.
*/
static isc_boolean_t
if (result != ISC_R_SUCCESS)
return (ISC_FALSE);
}
/*%
* 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);
}
/*
* If bind.keys exists and is populated, it overrides
* the managed-keys clause hard-coded in ns_g_config.
*/
"obtaining root key for view %s "
"from '%s'",
&builtin_keys);
if ((builtin_keys == NULL) &&
(builtin_managed_keys == NULL))
"dnssec-validation auto: "
"WARNING: root zone key "
"not found");
}
if ((builtin_keys == NULL) &&
(builtin_managed_keys == NULL))
{
"using built-in root key for view %s",
&builtin_keys);
}
if (builtin_keys != NULL)
if (builtin_managed_keys != NULL)
mctx));
"root key not loaded");
goto cleanup;
}
}
}
/*
* Add key zone for managed-keys.
*/
}
if (result != ISC_R_SUCCESS) {
"invalid managed-keys-directory %s: %s",
goto cleanup;
if (!isc_file_isdirwritable(directory)) {
"managed-keys-directory '%s' "
"is not writable", directory);
goto cleanup;
}
} else if (need_mkey_dir) {
"unable to retrieve "
"current working directory");
goto cleanup;
}
if (!isc_file_isdirwritable(cwd)) {
"working directory '%s' "
"is not writable", cwd);
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);
}
#ifdef HAVE_DLOPEN
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);
}
#endif
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 buf[sizeof("x.x.")];
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;
}
/*
* 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;
{
/*
* The dns_view_findzone() call above increments the
* zone's reference count, which we need to decrement
* back. However, as dns_zone_detach() sets the
* supplied pointer to NULL, calling it is deferred
* until the dnszone variable is no longer used.
*/
}
}
"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;
unsigned int i;
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
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
}
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
}
&obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
}
"fstrm-set-output-notify-threshold",
&obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
i);
}
&obj);
if (result == ISC_R_SUCCESS) {
else
}
&obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
}
&obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
}
&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 */
static isc_result_t
create_mapped_acl(void) {
if (result != ISC_R_SUCCESS)
return (result);
if (result == ISC_R_SUCCESS)
return (result);
}
/*
* Configure 'view' according to 'vconfig', taking defaults from 'config'
* where values are missing in 'vconfig'.
*
* When configuring the default view, 'vconfig' will be NULL and the
* global defaults in 'config' used exclusively.
*/
static isc_result_t
{
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));
}
/*
* If we're allowing added zones, then load zone configuration
* from the newzone file for zones that were added during previous
* runs.
*/
/*
* 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%%' "
}
}
/* 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;
} else {
if (ns_g_mapped == NULL) {
result = create_mapped_acl();
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.
* (These are only meaningful at the view level, but 'config'
* must be passed so that named ACLs defined at the global level
* can be retrieved.)
*/
&view->matchclients));
&view->matchdestinations));
/*
* Configure the "match-recursive-only" option.
*/
else
/*
* Configure other configurable data.
*/
if (cfg_obj_isboolean(obj)) {
if (cfg_obj_asboolean(obj))
else
} else {
} else
INSIST(0);
}
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-recursion", and
* "allow-recursion-on" acls if configured in named.conf.
* (Ignore the global defaults for now, because these ACLs
* can inherit from each other when only some of them set at
*/
{
}
/*
* "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.
*/
}
}
&view->recursionacl);
&view->recursionacl);
}
}
/*
* If any are still unset, we now get default "allow-recursion",
* "allow-recursion-on" and "allow-query-cache" ACLs from
* the global config.
*/
"allow-recursion", NULL,
&view->recursionacl));
}
"allow-recursion-on", NULL,
&view->recursiononacl));
}
"allow-query-cache", NULL,
}
/*
* We're not recursive; if "allow-query-cache" hasn't been
*/
}
/*
* 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.
*/
"deny-answer-addresses", "acl",
&view->denyansweracl));
"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-notify, allow-update
* and allow-update-forwarding ACLs, so they can be
* inherited by zones. (Note these cannot be set at
*/
}
}
}
/*
* Configure default allow-transer ACL so it can be inherited
* by zones. (Note this *can* be set at options or view level.)
*/
}
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) {
/* "auto" is deprecated, log a warning if seen */
const char *dom;
/* If "no", skip; if "auto", log warning */
/*
* Warning logged by libbind9.
*/
}
}
}
if (result == ISC_R_SUCCESS) {
dns_fixedname_init(&f);
/* Also log a warning if manually configured to dlv.isc.org */
iscdlv = dns_fixedname_name(&f);
{
/*
* Warning logged by libbind9.
*/
} else {
}
}
} 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
#ifdef HAVE_DLOPEN
{
const void *hashinit = isc_hash_get_initializer();
ns_g_timermgr, &dctx));
}
}
#endif
/*
* 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
}
}
typedef struct {
} ns_tat_t;
static int
cid(const void *a, const void *b) {
return (-1);
return (1);
else
return (0);
}
static void
/* Free resources which are not of interest */
}
struct dotat_arg {
};
static void
unsigned int i, n = 0;
int m;
do {
n++;
}
}
if (n == 0)
return;
if (n > 1)
/*
* Encoded as "_ta-xxxx\(-xxxx\)*" where xxxx is the hex version of
* of the keyid.
*/
label[0] = 0;
if (m < 0 || (unsigned)m > r.length)
return;
isc_textregion_consume(&r, m);
for (i = 0; i < n; i++) {
if (m < 0 || (unsigned)m > r.length)
return;
isc_textregion_consume(&r, m);
}
if (result != ISC_R_SUCCESS)
return;
return;
if (result != ISC_R_SUCCESS) {
}
}
static void
{
if (!view->trust_anchor_telemetry ||
{
continue;
}
if (result != ISC_R_SUCCESS) {
continue;
}
}
}
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));
if (result != ISC_R_SUCCESS)
goto cleanup;
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);
}
#ifndef HAVE_LMDB
static isc_result_t
/* The new zone file may not exist. That is OK. */
*num_zonesp = 0;
return (ISC_R_SUCCESS);
}
/*
* In the case of NZF files, we also parse the configuration in
* the file at this stage.
*
* This may be called in multiple views, so we reset
* the parser each time.
*/
if (result == ISC_R_SUCCESS) {
int num_zones;
"NZF file '%s' contains %d zones",
if (num_zonesp != NULL)
*num_zonesp = num_zones;
} else {
"Error parsing NZF file '%s': %s",
}
return (result);
}
#else /* HAVE_LMDB */
static isc_result_t
int n;
ISC_LOG_INFO, "loading NZD zone count from '%s' "
"for view '%s'",
*num_zonesp = n;
"NZD database '%s' contains %d zones",
view->new_zone_db, n);
if (result != ISC_R_SUCCESS)
*num_zonesp = 0;
return (ISC_R_SUCCESS);
}
#endif /* HAVE_LMDB */
static isc_result_t
int *num_zones)
{
int i = 0;
if (result == ISC_R_SUCCESS)
maps[i++] = ns_g_defaults;
if (result == ISC_R_SUCCESS)
#ifdef HAVE_LMDB
"'lmdb-mapsize "
"is too small",
mapsize);
return (ISC_R_FAILURE);
"'lmdb-mapsize "
"is too large",
mapsize);
return (ISC_R_FAILURE);
}
}
#else
#endif /* HAVE_LMDB */
/*
* 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) {
*num_zones = 0;
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.
*/
if (result != ISC_R_SUCCESS) {
return (result);
}
return (result);
}
static void
{
const char *zname;
if (result2 != ISC_R_SUCCESS) {
return;
}
if (result2 != ISC_R_SUCCESS) {
return;
}
if (result2 != ISC_R_SUCCESS) {
return;
}
if (result == ISC_R_SUCCESS) {
} else {
}
}
}
#ifndef HAVE_LMDB
static isc_result_t
{
const cfg_listelt_t *element;
return (ISC_R_SUCCESS);
}
"loading additional zones for view '%s'",
{
}
{
}
return (result);
}
#else /* HAVE_LMDB */
static isc_result_t
{
const char *zone_name;
const char *zone_config;
if (result != ISC_R_SUCCESS)
goto cleanup;
} else {
}
/* zone zonename { config; }; */
zone_config_len + 2);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
if (result != ISC_R_SUCCESS) {
"parsing config for zone '%.*s' in "
"NZD database '%s' failed",
(int) zone_name_len, zone_name,
view->new_zone_db);
goto cleanup;
}
*zoneconfig = zoneconf;
}
return (result);
}
/*%
* Prototype for a callback which can be used with for_all_newzone_cfgs().
*/
/*%
* For each zone found in a NZD opened by the caller, create an object
* representing its configuration and invoke "callback" with the created
* object, "config", "vconfig", "mctx", "view" and "actx" as arguments (all
* these are non-global variables required to invoke configure_zone()).
* Immediately interrupt processing if an error is encountered while
* transforming NZD data into a zone configuration object or if "callback"
* returns an error.
*/
static isc_result_t
{
int status;
if (status != MDB_SUCCESS) {
return (ISC_R_FAILURE);
}
status == MDB_SUCCESS;
{
/*
* Create a configuration object from data fetched from NZD.
*/
if (result != ISC_R_SUCCESS) {
break;
}
/*
* Extract zone configuration from configuration object.
*/
if (result != ISC_R_SUCCESS) {
break;
} else if (!cfg_obj_islist(zlist)) {
break;
}
/*
* Invoke callback.
*/
if (result != ISC_R_SUCCESS) {
break;
}
/*
* Destroy the configuration object created in this iteration.
*/
}
}
if (zconfigobj != NULL) {
}
return (result);
}
/*%
* Attempt to configure a zone found in NZD and return the result.
*/
static isc_result_t
{
}
/*%
* Revert new view assignment for a zone found in NZD.
*/
static isc_result_t
{
return (ISC_R_SUCCESS);
}
static isc_result_t
{
return (ISC_R_SUCCESS);
}
if (result != ISC_R_SUCCESS) {
return (ISC_R_SUCCESS);
}
ISC_LOG_INFO, "loading NZD configs from '%s' "
"for view '%s'",
if (result != ISC_R_SUCCESS) {
/*
* An error was encountered while attempting to configure zones
* found in NZD. As this error may have been caused by a
* configure_zone() failure, try restoring a sane configuration
* by reattaching all zones found in NZD to the old view. If
* this also fails, too bad, there is nothing more we can do in
* terms of trying to make things right.
*/
dbi);
}
return (result);
}
static isc_result_t
{
int status;
char zname[DNS_NAME_FORMATSIZE];
isc_buffer_t b;
ISC_LOG_INFO, "loading NZD config from '%s' "
"for zone '%s'",
/* Normalize zone name */
if (status != MDB_SUCCESS) {
}
*zoneconfig = zoneconf;
}
}
return (result);
}
#endif /* HAVE_LMDB */
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.
*/
"reading built-in trusted "
&bindkeys_parser));
} else {
"unable to open '%s' using built-in keys",
}
/* 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 {
}
/*
* Set "blackhole". Only legal at options level; there is
* no default.
*/
&server->blackholeacl));
}
/*
* Set "keep-response-order". Only legal at options or
* global defaults level.
*/
"keep-response-order", NULL,
&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.
*/
{
int nzf_num_zones;
}
/*
* If there were no explicit views then we do the default
* view here.
*/
int nzf_num_zones;
}
/*
* 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 */
/*
* Commit any dns_zone_setview() calls on all zones in the new
* view.
*/
{
}
/* 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 {
int level = ISC_LOG_ERROR;
#ifdef PATH_RANDOMDEV
if (ns_g_fallbackentropy != NULL) {
}
#endif
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
}
}
#ifdef HAVE_LMDB
/*
* If we're using LMDB, we may have created newzones databases
* as root, making it impossible to reopen them later after
* switching to a new userid. We close them now, and reopen
* after relinquishing privileges them.
*/
if (first_time) {
{
}
}
#endif /* HAVE_LMDB */
/*
* Relinquish root privileges.
*/
if (first_time) {
}
/*
* Check that the working directory is writable.
*/
if (!isc_file_isdirwritable(".")) {
"the working directory is not writable");
}
#ifdef HAVE_LMDB
/*
* Reopen NZD databases.
*/
if (first_time) {
{
}
}
#endif /* HAVE_LMDB */
/*
* 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 trust anchor telemetry 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;
}
if (!found) {
return (result);
}
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 */
#ifndef HAVE_LMDB
/*
* 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);
}
static void
}
static isc_result_t
if (offset == 0)
(void)isc_stdio_close(fp);
if (offsetok) {
offset);
if (result2 != ISC_R_SUCCESS) {
"Error truncating NZF file '%s' "
"during rollback from append: "
"%s",
}
}
}
return (result);
}
static isc_result_t
const cfg_listelt_t *elt;
char tmp[1024];
if (result == ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS)
return (result);
if (!cfg_obj_islist(zl))
{
}
if (result != ISC_R_SUCCESS)
goto cleanup;
return (result);
(void)isc_stdio_close(fp);
(void)isc_file_remove(tmp);
return (result);
}
#else /* HAVE_LMDB */
static void
}
static void
}
static isc_result_t
{
int status;
char namebuf[1024];
/* We're deleting the zone from the database */
"Error deleting zone %s "
"from NZD database: %s",
goto cleanup;
} else if (status != MDB_NOTFOUND) {
}
} else {
/* We're creating or overwriting the zone */
if (result != ISC_R_SUCCESS) {
"Unable to allocate buffer in "
"nzd_save(): %s",
goto cleanup;
}
"Unable to get options from config in "
"nzd_save()");
goto cleanup;
}
if (status != MDB_SUCCESS) {
"Error inserting zone in "
"NZD database: %s",
goto cleanup;
}
}
(void) mdb_txn_abort(*txnp);
} else {
if (status != MDB_SUCCESS) {
"Error committing "
"NZD database: %s",
}
}
}
return (result);
}
static isc_result_t
int status;
if (status != MDB_SUCCESS) {
ISC_LOG_WARNING, "mdb_txn_begin: %s",
return (ISC_R_FAILURE);
}
if (status != MDB_SUCCESS) {
ISC_LOG_WARNING, "mdb_dbi_open: %s",
}
return (result);
}
static isc_result_t
int status;
if (status != MDB_SUCCESS) {
ISC_LOG_WARNING, "mdb_txn_begin: %s",
goto cleanup;
}
if (status != MDB_SUCCESS) {
ISC_LOG_WARNING, "mdb_dbi_open: %s",
goto cleanup;
}
if (status != MDB_SUCCESS) {
}
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
/*
* nzd_env_close() and nzd_env_reopen are a kluge to address the
* problem of an NZD file possibly being created before we drop
* root privileges.
*/
static void
char dbpath_copy[PATH_MAX];
return;
}
/*
* Database files must be owned by the eventual user, not by root.
*/
/*
* Some platforms need the lockfile not to exist when we reopen the
* environment.
*/
(void) isc_file_remove(lockpath);
}
static isc_result_t
int status;
return (ISC_R_SUCCESS);
}
if (status != MDB_SUCCESS) {
"mdb_env_create failed: %s",
}
if (status != MDB_SUCCESS) {
"mdb_env_set_mapsize failed: %s",
}
}
if (status != MDB_SUCCESS) {
"mdb_env_open of '%s' failed: %s",
}
}
return (result);
}
static isc_result_t
int status;
if (commit) {
if (status != MDB_SUCCESS) {
}
} else {
}
}
return (result);
}
static isc_result_t
int status;
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
if (status != MDB_SUCCESS) {
ISC_LOG_WARNING, "mdb_stat: %s",
goto cleanup;
}
return (result);
}
static isc_result_t
int status, n;
const cfg_listelt_t *element;
/*
* If NZF file doesn't exist, or NZD DB exists and already
* has data, return without attempting migration.
*/
goto cleanup;
}
if (result == ISC_R_SUCCESS && n > 0) {
goto cleanup;
}
"Migrating zones from NZF file '%s' to "
"NZD database '%s'",
/*
* Instead of blindly copying lines, we parse the NZF file using
* the configuration parser, because it validates it against the
* config type, giving us a guarantee that valid configuration
* will be written to DB.
*/
if (result != ISC_R_SUCCESS) {
"Error parsing NZF file '%s': %s",
goto cleanup;
}
if (!cfg_obj_islist(zonelist)) {
}
{
char zname[DNS_NAME_FORMATSIZE];
const char *origin;
isc_buffer_t b;
goto cleanup;
}
/* Normalize zone name */
goto cleanup;
}
if (status != MDB_SUCCESS) {
"Error inserting zone in "
"NZD database: %s",
goto cleanup;
}
}
/*
* Leaving the NZF file in place is harmless as we won't use it
* if an NZD database is found for the view. But we rename NZF file
* to a backup name here.
*/
}
if (result != ISC_R_SUCCESS) {
} else {
}
}
if (nzf_config != NULL) {
}
return (result);
}
#endif /* HAVE_LMDB */
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 */
/* Check the zone type for ones that are not supported by addzone. */
"'in-view' zones not supported by ");
} else
}
{
}
/* 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
{
if (!cfg_obj_islist(zl))
{
const char *zn;
cfg_listelt_t *e;
if (result != ISC_R_SUCCESS ||
continue;
break;
}
/*
* Write config to NZF file if appropriate
*/
return (result);
}
static isc_result_t
isc_buffer_t **text)
{
#ifndef HAVE_LMDB
#else /* HAVE_LMDB */
#endif /* HAVE_LMDB */
/* 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;
#ifndef HAVE_LMDB
/*
* Make sure we can open the configuration save file
*/
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
(void)isc_stdio_close(fp);
#else /* HAVE_LMDB */
/* Make sure we can open the NZD database */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
#endif /* HAVE_LMDB */
/* Mark view unfrozen and configure zone */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
/* Is it there yet? */
if (result != ISC_R_SUCCESS) {
"added new zone was not found: %s",
goto cleanup;
}
#ifndef HAVE_LMDB
/*
* 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;
}
#endif /* HAVE_LMDB */
/*
* 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 */
#ifdef HAVE_LMDB
/* Save the new zone configuration into the NZD */
#else
/* Append the zone configuration to the NZF */
#endif /* HAVE_LMDB */
#ifndef HAVE_LMDB
(void)isc_stdio_close(fp);
NULL);
}
#else /* HAVE_LMDB */
#endif /* HAVE_LMDB */
return (result);
}
static isc_result_t
isc_buffer_t **text)
{
#ifndef HAVE_LMDB
cfg_obj_t *z;
#else /* HAVE_LMDB */
#endif /* HAVE_LMDB */
/* Zone must already exist */
if (result != ISC_R_SUCCESS)
goto cleanup;
#ifndef HAVE_LMDB
}
#endif
#ifndef HAVE_LMDB
/* Make sure we can open the configuration save file */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
(void)isc_stdio_close(fp);
#else /* HAVE_LMDB */
/* Make sure we can open the NZD database */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
#endif /* HAVE_LMDB */
/* Reconfigure the zone */
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
/* Is it there yet? */
#ifndef HAVE_LMDB
/* Remove old zone from configuration (and NZF file if applicable) */
if (added) {
if (result != ISC_R_SUCCESS) {
"not deleted: "));
goto cleanup;
}
}
#endif /* HAVE_LMDB */
if (!added) {
NULL);
} else {
NULL);
}
if (result != ISC_R_SUCCESS) {
"not deleted: "));
goto cleanup;
}
}
/* Load the zone from the master file if it needs reloading. */
/*
* Dynamic zones need no reloading, so we can pass this result.
*/
if (result == DNS_R_DYNAMIC)
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;
}
#ifndef HAVE_LMDB
/* Store the new zone configuration; also in NZF if applicable */
#endif /* HAVE_LMDB */
if (added) {
#ifdef HAVE_LMDB
#else
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
#endif /* HAVE_LMDB */
} else {
}
if (exclusive)
#ifndef HAVE_LMDB
(void)isc_stdio_close(fp);
#else /* HAVE_LMDB */
#endif /* HAVE_LMDB */
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? */
#ifdef HAVE_LMDB
#else
#endif /* HAVE_LMDB */
{
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);
}
typedef struct {
} ns_dzctx_t;
/*
* Carry out a zone deletion scheduled by ns_server_delzone().
*/
static void
char zonename[DNS_NAME_FORMATSIZE];
#ifdef HAVE_LMDB
#endif
/* Dig out configuration for this zone */
"deleting zone %s in view %s via delzone",
/* Remove the zone from configuration (and NZF file if applicable) */
#ifdef HAVE_LMDB
/* Make sure we can open the NZD database */
if (result != ISC_R_SUCCESS) {
"unable to open NZD database for '%s'",
view->new_zone_db);
} else {
}
if (result != ISC_R_SUCCESS) {
ISC_LOG_ERROR, "unable to "
"delete zone configuration: %s",
}
#else
if (result != ISC_R_SUCCESS) {
ISC_LOG_ERROR, "unable to "
"delete zone configuration: %s",
}
#endif /* HAVE_LMDB */
}
NULL);
} else {
NULL);
}
if (result != ISC_R_SUCCESS){
ISC_LOG_ERROR, "unable to "
"delete zone configuration: %s",
}
}
/* Unload zone database */
dns_db_detach(&dbp);
}
const char *file;
if (result != ISC_R_SUCCESS) {
"file %s not removed: %s",
}
if (result != ISC_R_SUCCESS) {
"file %s not removed: %s",
}
if (result != ISC_R_SUCCESS) {
"file %s not removed: %s",
}
if (result != ISC_R_SUCCESS) {
"file %s not removed: %s",
}
}
}
#ifdef HAVE_LMDB
#endif
}
/*
* Act on a "delzone" command from the command channel.
*/
char zonename[DNS_NAME_FORMATSIZE];
const char *ptr;
/* 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;
}
/* Send cleanup event */
if (!added) {
"' is no longer active and will be deleted.\n"));
} else if (cleanup) {
{
const char *file;
}
}
"zone %s scheduled for removal via delzone", zonename);
/* Removing a zone counts as reconfiguration */
if (isc_buffer_usedlength(*text) > 0)
}
return (result);
}
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
}
/*
* Act on a "showzone" command from the command channel.
*/
char zonename[DNS_NAME_FORMATSIZE];
#ifdef HAVE_LMDB
#endif /* HAVE_LMDB */
/* Parse parameters */
goto cleanup;
}
goto cleanup;
}
/* Find the view statement */
/* Find the zone statement */
else
#ifndef HAVE_LMDB
"zone", zonename);
#else /* HAVE_LMDB */
if (!cfg_obj_islist(zlist))
}
#endif /* HAVE_LMDB */
#ifdef HAVE_LMDB
#endif /* HAVE_LMDB */
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
char *ptr;
int backups = 0;
return (ISC_R_NOTFOUND);
/* Check the command name. */
return (ISC_R_UNEXPECTEDEND);
/* "dnstap-reopen" was used in 9.11.0b1 */
} else {
return (ISC_R_UNEXPECTEDEND);
}
backups = -1;
unsigned int n;
if (n != 1U)
return (ISC_R_BADNUMBER);
}
} else
return (DNS_R_SYNTAX);
return (result);
#else
return (ISC_R_NOTIMPLEMENTED);
#endif
}