server.c revision 7027fd24a28b2f8de661b61fcf082f3851b20a32
/*
* 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/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/compress.h>
#include <dns/zoneconf.h>
typedef struct {
} ns_load_t;
static isc_task_t * server_task;
static isc_result_t
{
/*
* View.
*/
if (result != ISC_R_SUCCESS)
return (result);
/*
* Cache.
*/
if (result != ISC_R_SUCCESS)
goto cleanup;
/*
* XXXRTH Temporary support for loading cache contents.
*/
if (ns_g_cachefile != NULL) {
if (result != ISC_R_SUCCESS)
goto cleanup;
}
/*
* Resolver.
*
* XXXRTH hardwired number of tasks. Also, we'll need to
* see if we are dealing with a shared dispatcher in this view.
*/
NULL);
if (result != ISC_R_SUCCESS)
goto cleanup;
/*
* We have default hints for class IN.
*/
if (rdclass == dns_rdataclass_in)
return (ISC_R_SUCCESS);
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;
char buf[256];
isc_region_t r;
if (versiontext == NULL)
if (len > 255)
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != DNS_R_SUCCESS)
goto cleanup;
if (result != DNS_R_SUCCESS)
goto cleanup;
&view);
if (result != ISC_R_SUCCESS)
return (result);
if (result != DNS_R_SUCCESS)
goto cleanup;
if (result != DNS_R_SUCCESS)
goto cleanup;
/* Transfer ownership. */
dns_db_detach(&db);
return (result);
}
static isc_result_t
void *uap)
{
/*
* Load (or reload) a zone.
*/
/*
* Find the view.
*/
if (result != ISC_R_SUCCESS)
return (result);
} else {
if (result == ISC_R_NOTFOUND) {
/*
* Create a default view.
*/
&tview);
if (result != ISC_R_SUCCESS)
return (result);
} else if (result != ISC_R_SUCCESS)
return (result);
}
/*
* Do we already have a production version of this view?
*/
&pview);
goto cleanup;
/*
* Create a new zone structure and configure it.
*/
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
INSIST(0);
} else {
/*
* Check for duplicates in the new zone table.
*/
if (result == ISC_R_SUCCESS) {
/*
* We already have this zone!
*/
goto cleanup;
}
/*
* Do we have the zone in the production view?
*/
else
if (result == ISC_R_SUCCESS) {
/*
* Yes.
*
* If the production zone's configuration is
* the same as the new zone's, we can use the
* production zone.
*/
else
} else if (result == ISC_R_NOTFOUND) {
/*
* This is a new zone.
*/
if (result != DNS_R_SUCCESS)
goto cleanup;
if (result != DNS_R_SUCCESS)
goto cleanup;
}
}
return (result);
}
/* XXX will need error recovery for reconfig */
static void
{
if (result != DNS_R_SUCCESS)
"server ACL setup failed");
}
}
static void
&callbacks);
if (result != ISC_R_SUCCESS) {
#ifdef notyet
}
#endif
"load of '%s' failed", filename);
}
/*
* Configure various server options.
*/
/*
* If we haven't created any views, create a default view for class
* IN. (We're a caching-only server.)
*/
if (result != ISC_R_SUCCESS)
"could not create default view");
}
/*
* Freeze the views.
*/
/*
* Create the version view.
*/
if (result != ISC_R_SUCCESS)
"could not create version view");
/*
* Change directory.
*/
if (result != ISC_R_SUCCESS)
"change directory to '%s' failed: %s",
}
/*
* Load zones.
*/
}
/*
* 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.
*/
/*
* Put the configuration into production.
*/
/*
* Cleanup old configuration.
*/
}
/*
* Load the TSIG information from the configuration
*/
if (result != ISC_R_SUCCESS)
"dns_tsig_init() failed: %s",
/*
* Load the TKEY information from the configuration
*/
if (result != ISC_R_SUCCESS) {
"dns_tkey_init() failed: %s",
}
}
static void
(void)task;
ISC_LOG_INFO, "running");
}
static void
(void)task;
ISC_LOG_INFO, "shutting down");
}
}
return (ISC_R_NOMEMORY);
/* Initialize. */
return (ISC_R_SUCCESS);
}
void
}
ns_server_init() {
/*
* Create the server object.
*/
if (result != ISC_R_SUCCESS)
return (result);
/*
* Setup default root server hints.
*/
result = ns_rootns_init();
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
/*
* Setup the server task, which is responsible for coordinating
* startup and shutdown of the server.
*/
if (result != ISC_R_SUCCESS)
goto cleanup_rootns;
if (result != ISC_R_SUCCESS)
goto cleanup_task;
if (result != ISC_R_SUCCESS)
goto cleanup_task;
return (ISC_R_SUCCESS);
/* XXXRTH Add zonemgr, and version view cleanups. */
return (result);
}
void
const char *format, ...)
{
ISC_LOG_CRITICAL, "exiting (due to fatal error)");
if (want_core && ns_g_coreok)
abort();
exit(1);
}