server.c revision b5d3508e8ae9870d29d0ea0845c13c55426ecc59
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1999-2003 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
cfe32752a66fe1f050d5ed7ddce75f6d58fe1637Evan Hunt * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <ctype.h>
#ifdef HAVE_LIBSCF
#include <stdlib.h>
#ifndef PATH_MAX
goto cleanup; \
goto cleanup; \
struct ns_dispatch {
unsigned int dispatchgen;
struct ns_cache {
struct dumpcontext {
struct viewlistentry {
struct zonelistentry {
struct cfg_context {
const char *empty_zones[] = {
ISC_PLATFORM_NORETURN_PRE static void
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
isc_buffer_t b;
const char *str;
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (result);
* we have foo.example.com and bar.example.com, we'd get a match
* for baz.example.com, which is not the expected result.
goto cleanup;
return (result);
return (result);
static isc_result_t
isc_region_t r;
if (managed) {
const char *initmethod;
goto cleanup;
&viewclass));
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
goto cleanup;
return (result);
static isc_result_t
const char *directory;
return (ISC_R_SUCCESS);
&view_keys);
return (ISC_R_UNEXPECTED);
&builtin_keys);
&builtin_keys);
&builtin_keys);
&builtin_keys);
mctx));
goto cleanup;
return (result);
static isc_result_t
const char *str;
isc_buffer_t b;
return (result);
static isc_result_t
unsigned int maxdispatchbuffers;
switch (af) {
case AF_INET:
case AF_INET6:
INSIST(0);
switch (af) {
case AF_INET:
case AF_INET6:
INSIST(0);
return (ISC_R_SUCCESS);
attrs = 0;
switch (af) {
case AF_INET:
case AF_INET6:
if (is_firstview) {
attrmask = 0;
switch (af) {
case AF_INET:
case AF_INET6:
return (ISC_R_SUCCESS);
buf);
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int mode = 0;
const char *str;
isc_buffer_t b;
return (result);
return (result);
return (result);
mode = 0;
INSIST(0);
if (addroot) {
return (result);
static isc_result_t
const char *str;
unsigned int prefixlen;
return (result);
INSIST(0);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
const char *str;
isc_buffer_t b;
return (result);
static isc_result_t
const char *str;
isc_buffer_t b;
return (result);
static isc_boolean_t
const char *str;
isc_buffer_t b;
0, NULL);
return (ISC_TRUE);
return (ISC_FALSE);
for (i = 0; i < dbtypec; i++)
static isc_result_t
if (on) {
return (result);
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,
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
static isc_result_t
return (result);
static isc_result_t
const char *contact)
char *cp;
const unsigned char *s6;
isc_buffer_t b;
while (prefixlen > 0) {
return (result);
static isc_result_t
const char *str;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
unsigned int dlzargc;
char **dlzargv;
unsigned int cleaning_interval;
const char *str;
unsigned int resopts = 0;
value);
goto cleanup;
ISC_TRUE));
if (s == NULL) {
goto cleanup;
goto cleanup;
&dlzdb);
goto cleanup;
goto cleanup;
value);
goto cleanup;
INSIST(0);
unsigned int prefixlen;
unsigned int dns64options = 0;
&prefixlen);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
&pview);
goto cleanup;
zero_no_soattl)) {
&cache));
goto cleanup;
== NULL)));
== NULL)));
goto cleanup;
max_adb_size = 0;
if (max_cache_size != 0) {
if (max_adb_size == 0)
if (need_hints)
goto cleanup;
INSIST(0);
* configured in named.conf.
#ifdef ALLOW_FILTER_AAAA
INSIST(0);
INSIST(0);
const char *dom;
const char *str;
isc_buffer_t b;
isc_buffer_t b;
const char *str;
0, NULL));
name));
const char *empty;
int empty_zone = 0;
const char *str;
NULL));
NULL));
NULL));
&forwarders);
&pview);
goto cleanup;
zonestats_on));
zone));
empty_dbtype));
ISC_TRUE);
goto cleanup;
return (result);
static isc_result_t
return (result);
static isc_result_t
return (ISC_R_RANGE);
NULL));
val);
return (ISC_R_RANGE);
NULL, 0));
return (result);
static isc_result_t
return (ISC_R_RANGE);
goto cleanup;
INSIST(0);
goto cleanup;
return (result);
static isc_result_t
const char *viewname;
&viewclass);
return (result);
static isc_result_t
return (result);
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
return (ISC_R_EXISTS);
return (result);
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
const char *zname;
const char *ztypestr;
goto cleanup;
return (ISC_R_FAILURE);
zname);
goto cleanup;
goto cleanup;
&only);
zname);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
zone));
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
forwardtype));
return (result);
static isc_result_t
&pview);
return (result);
return (ISC_R_SUCCESS);
goto cleanup;
return (result);
static isc_result_t
const char *directory;
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
goto clean;
goto clean;
return (ISC_R_SUCCESS);
return (result);
goto fail;
goto fail;
goto fail;
goto fail;
fail:
goto clean;
static unsigned int oldrequests = 0;
static isc_result_t
char *copy;
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_result_t
const char *resource;
if (positive)
if (positive)
hiport);
static isc_result_t
const char *type;
return (ISC_R_SUCCESS);
case dns_zone_master:
case dns_zone_slave:
case dns_zone_stub:
case dns_zone_redirect:
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
&tsigkey));
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
unsigned int algtype;
return (result);
return (result);
if (need_deleteold) {
if (need_createnew) {
goto cleanup;
goto cleanup;
return (result);
return (result);
static isc_result_t
if (!allow) {
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int maxsocks;
int num_zones = 0;
if (first_time) {
filename);
* option where the above parsing failed, parse resolv.conf.
if (ns_g_lwresdonly &&
&config);
&bindkeys_parser));
if (!exclusive) {
maxsocks = 0;
if (maxsocks != 0) {
reserved = 0;
&udpport_high),
&udpport_high),
if (ns_g_port != 0)
} else if (!ns_g_lwresdonly) {
listenon);
} else if (!ns_g_lwresdonly) {
listenon);
if (interface_interval == 0) {
if (heartbeat_interval == 0) {
else if (ns_g_lwresdonly)
if (first_time) {
#ifdef PATH_RANDOMDEV
&ns_g_entropy);
if (first_time)
* files specified in named.conf get created by the
if (ns_g_logstderr) {
if (first_time) {
&categories);
const char *str;
else if (ns_g_memstatistics)
if (exclusive)
return (result);
static isc_result_t
unsigned int refs;
if (refs != 0)
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int refs = 0;
return (ISC_R_NOMEMORY);
goto cleanup;
goto cleanup;
if (refs == 0) {
return (result);
static isc_result_t
return (result);
if (ns_g_lwresdonly)
ISC_TRUE),
if (flush)
sizeof(isc_event_t));
goto cleanup;
attrs = 0;
case AF_INET:
case AF_INET6:
goto cleanup;
attrmask = 0;
goto cleanup;
static isc_result_t
return (result);
static isc_result_t
return (result);
cleanup: ;
char *res;
return (res);
static isc_result_t
char *classtxt;
if (skip) {
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
if (zonename)
goto fail1;
goto fail1;
goto fail1;
return (result);
return (result);
return (ISC_R_UNEXPECTEDEND);
return (result);
return (result);
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_CONTINUE:
case DNS_R_UPTODATE:
return (result);
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
return (ISC_R_FAILURE);
char *ptr;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
if (ns_g_port != 0) {
return (result);
return (ISC_R_RANGE);
return (result);
return (result);
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (result);
goto cleanup;
goto done;
goto resume;
goto cleanup;
goto nextzone;
goto nextzone;
goto cleanup;
goto nextview;
done:
char *ptr;
const char *sep;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_NOMEMORY);
goto nextview;
return (ISC_R_SUCCESS);
return (result);
char *ptr;
return (ISC_R_UNEXPECTEDEND);
return (result);
return (result);
char *ptr;
char *levelstr;
char *endp;
long newlevel;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_RANGE);
return (ISC_R_SUCCESS);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDEND);
return (DNS_R_SYNTAX);
goto out;
if (changed)
out:
return (result);
return (ISC_R_UNEXPECTEDEND);
viewname);
if (!found) {
return (result);
isc_buffer_t b;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDEND);
return (result);
target);
if (!found)
return (result);
#ifdef ISC_PLATFORM_USETHREADS
#ifdef ISC_PLATFORM_USETHREADS
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int *foundkeys)
origin);
return (ISC_R_SUCCESS);
return (result);
goto nextkey;
(*foundkeys)++;
goto again;
return (result);
return (ISC_R_SUCCESS);
unsigned int foundkeys = 0;
char *target;
char *viewname;
return (ISC_R_UNEXPECTEDEND);
&foundkeys);
return (result);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int *foundkeys)
const char *viewname;
origin);
return (ISC_R_SUCCESS);
return (result);
(*foundkeys)++;
sizeof(creatorstr));
return (ISC_R_NOSPACE);
return (result);
return (ISC_R_SUCCESS);
unsigned int foundkeys = 0;
&foundkeys);
return (result);
&foundkeys);
return (result);
if (foundkeys == 0) {
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
return (result);
return (DNS_R_NOTMASTER);
return (result);
static isc_result_t
char *journal;
if (cleanup) {
return (result);
return (result);
return (tresult);
sizeof(classstr));
return (result);
return (result);
return (tresult);
return (DNS_R_NOTMASTER);
return (DNS_R_NOTDYNAMIC);
if (freeze) {
if (frozen) {
if (frozen) {
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_UPTODATE:
case DNS_R_CONTINUE:
sizeof(classstr));
return (result);
#ifdef HAVE_LIBSCF
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
const char *zonename;
const char *argp;
&config));
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
const char *vname;
goto cleanup;
goto cleanup;
NULL));
return (result);
goto cleanup;
goto cleanup;
goto cleanup;
size_t n;
(long)getpid()));
goto cleanup;
p += znamelen;
if (isspace((unsigned char)*p) ||
found = p;
if (found) {
p = buf;
goto cleanup;
return (result);
const char *ptr;
size_t n;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDEND);
hash = 0;
return (ISC_R_UNEXPECTEDEND);
if (n == sizeof(nbuf))
return (ISC_R_NOSPACE);
return (ISC_R_BADNUMBER);
return (ISC_R_RANGE);
return (ISC_R_UNEXPECTEDEND);
if (clear) {
} else if (chain) {
ISC_TRUE));
} else if (list) {
goto cleanup;
if (!first)
return (result);
int nfiles = 0;
goto cleanup;
switch (zonetype) {
case dns_zone_master:
case dns_zone_slave:
case dns_zone_stub:
case dns_zone_staticstub:
case dns_zone_redirect:
case dns_zone_key:
case dns_zone_dlz:
if (hasraw)
if (hasraw) {
DNS_ZONEKEY_MAINTAIN) != 0);
sizeof(kbuf));
sizeof(rtbuf));
for (i = 0; i < nfiles; i++) {
if (hasraw) {
if (secure) {
if (hasraw)
if (maintain) {
} else if (allow)
if (dynamic) {
if (frozen)
for (i = 0; i < nfiles; i++)
return (result);