server.c revision 9e694201cfe00011e98bfa9cdb6358e7d050be7b
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <isc/assertions.h>
#include <dns/confparser.h>
#include <dns/fixedname.h>
#include <dns/tkeyconf.h>
#include <dns/tsigconf.h>
#include <dns/zoneconf.h>
#include <named/interfacemgr.h>
#include <named/listenlist.h>
/*
* Check an operation for failure. Assumes that the function
* using it has a 'result' variable and a 'cleanup' label.
*/
} while (0)
if (result != ISC_R_SUCCESS) { \
"%s: %s", msg, \
isc_result_totext(result)); \
goto cleanup; \
} \
} while (0) \
if (result != ISC_R_SUCCESS) \
} while (0) \
typedef struct {
} ns_load_t;
/*
* Configure 'view' according to 'cctx'.
*
* XXX reconfiguration should preserve cache contents.
*/
static isc_result_t
{
/*
* Cache.
*/
/*
* XXXRTH Temporary support for loading cache contents.
*/
if (ns_g_cachefile != NULL) {
}
/*
* Resolver.
*
* XXXRTH hardwired number of tasks. Also, we'll need to
* see if we are dealing with a shared dispatcher in this view.
*/
NULL));
/*
* We have default hints for class IN.
*/
/*
* Configure the view's TSIG keys.
*/
return (result);
}
/*
* Create the special view that handles queries for
* "version.bind. CH". The version string returned is that
* configured in 'configctx', or a compiled-in default if
* there is no "version" configuration option.
*/
static isc_result_t
char *versiontext;
unsigned char buf[256];
isc_region_t r;
static unsigned char origindata[] = "\007version\004bind";
r.base = origindata;
r.length = sizeof(origindata);
dns_name_fromregion(&origin, &r);
if (versiontext == NULL)
if (len > 255)
&view));
/* Transfer ownership. */
dns_db_detach(&db);
return (result);
}
/*
* Configure or reconfigure a zone. This callback function
* is called after parsing each "zone" statement in named.conf.
*/
static isc_result_t
void *uap)
{
char *viewname;
char *corigin;
/*
* Get the zone origin as a dns_name_t.
*/
/* XXX casting away const */
/*
* Find or create the view in the new view list.
*/
else
viewname = "_default";
goto cleanup;
}
/*
* Check for duplicates in the new zone table.
*/
if (result == ISC_R_SUCCESS) {
/*
* We already have this zone!
*/
goto cleanup;
}
/*
* See if we can reuse an existing zone. This is
* only possible if all of these are true:
* - The zone's view exists
* - A zone with the right name exists in the view
* - The zone is compatible with the config
* options (e.g., an existing master zone cannot
* be reused if the options specify a slave zone)
*/
&pview);
goto cleanup;
goto cleanup;
}
/*
* If we cannot reuse an existing zone, we will have to
* create a new one.
*/
zone));
}
/*
* Configure the zone.
*/
/*
* XXX Why was this here?
*
* if (dns_zone_gettype(zone) == dns_zone_hint)
* INSIST(0);
*/
/*
* Add the zone to its view in the new view list.
*/
return (result);
}
/*
* Configure a single server ACL at '*aclp'. Get its configuration by
* calling 'getacl'.
*/
static isc_result_t
{
}
return (result);
}
/*
* Configure a single server quota.
*/
static void
{
}
static isc_result_t
ISC_LOG_INFO, "loading configuration from '%s'",
filename);
/*
* Parse the configuration file creating a parse tree. Any
* 'zone' statements are handled immediately by calling
* load_zone() through 'callbacks'.
*/
&callbacks));
/*
* Configure various server options.
*/
&server->recursionacl));
&server->transferacl));
/*
* Configure the interface manager according to the "listen-on"
* statement.
*/
{
} else {
/* Not specified, use default. */
&listenon));
}
}
/*
* If we haven't created any views, create a default view for class
* IN. (We're a caching-only server.)
*/
"_default", &view),
"creating default view");
}
/*
* Configure and freeze the views. Their zone tables have
* already been filled in at parsing time, but other stuff
* like the resolvers are still unconfigured.
*/
{
}
/*
* Create (or recreate) the version view.
*/
/*
* Change directory.
*/
if (result != ISC_R_SUCCESS) {
ISC_LOG_ERROR, "change directory "
"to '%s' failed: %s",
}
}
/*
* Swap our new view list with the production one.
*/
/*
* Load the TKEY information from the configuration.
*/
{
dns_tkey_ctx_t *t = NULL;
"configuring TKEY");
}
/*
* Rescan the interface list to pick up changes in the
* listen-on option.
*/
/*
* This cleans up either the old production view list
* or our temporary list depending on whether they
* were swapped above or not.
*/
}
return (result);
}
static isc_result_t
/*
* Load zone data from disk.
*/
{
}
/*
* Force zone maintenance. Do this after loading
* so that we know when we need to force AXFR of
* slave zones whose master files are missing.
*/
return (result);
}
static void
(void)task;
"creating client manager");
&server->interfacemgr),
"creating interface manager");
"loading configuration");
"loading zones");
ISC_LOG_INFO, "running");
}
static void
(void)task;
ISC_LOG_INFO, "shutting down");
}
}
void
/* Initialize configuration data with default values. */
/* Initialize server data structures. */
"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.
*/
"creating server task");
"isc_task_onshutdown");
"isc_app_onrun");
"dns_zonemgr_create");
}
void
}
static void
{
ISC_LOG_CRITICAL, "exiting (due to fatal error)");
exit(1);
}
static void
if (result != DNS_R_SUCCESS) {
"reloading configuration failed: %s",
}
if (result != DNS_R_SUCCESS) {
"reloading zones failed: %s",
}
}
void
}