Commit 9dafd058 authored by Andreas Gustafsson's avatar Andreas Gustafsson
Browse files

implemented 'rndc reconfig'

parent fd59e595
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: control.c,v 1.3 2001/04/11 20:37:33 bwelling Exp $ */ /* $Id: control.c,v 1.4 2001/05/07 23:33:58 gson Exp $ */
#include <config.h> #include <config.h>
...@@ -79,6 +79,8 @@ ns_control_docommand(isccc_sexpr_t *message) { ...@@ -79,6 +79,8 @@ ns_control_docommand(isccc_sexpr_t *message) {
*/ */
if (command_compare(command, NS_COMMAND_RELOAD)) { if (command_compare(command, NS_COMMAND_RELOAD)) {
result = ns_server_reloadcommand(ns_g_server, command); result = ns_server_reloadcommand(ns_g_server, command);
} else if (command_compare(command, NS_COMMAND_RECONFIG)) {
result = ns_server_reconfigcommand(ns_g_server, command);
} else if (command_compare(command, NS_COMMAND_REFRESH)) { } else if (command_compare(command, NS_COMMAND_REFRESH)) {
result = ns_server_refreshcommand(ns_g_server, command); result = ns_server_refreshcommand(ns_g_server, command);
} else if (command_compare(command, NS_COMMAND_HALT)) { } else if (command_compare(command, NS_COMMAND_HALT)) {
...@@ -89,13 +91,6 @@ ns_control_docommand(isccc_sexpr_t *message) { ...@@ -89,13 +91,6 @@ ns_control_docommand(isccc_sexpr_t *message) {
ns_server_flushonshutdown(ns_g_server, ISC_TRUE); ns_server_flushonshutdown(ns_g_server, ISC_TRUE);
isc_app_shutdown(); isc_app_shutdown();
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
} else if (command_compare(command, NS_COMMAND_RELOADCONFIG) ||
command_compare(command, NS_COMMAND_RELOADZONES)) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_CONTROL, ISC_LOG_WARNING,
"unimplemented channel command '%s'",
command);
result = ISC_R_NOTIMPLEMENTED;
} else if (command_compare(command, NS_COMMAND_DUMPSTATS)) { } else if (command_compare(command, NS_COMMAND_DUMPSTATS)) {
result = ns_server_dumpstats(ns_g_server); result = ns_server_dumpstats(ns_g_server);
} else if (command_compare(command, NS_COMMAND_QUERYLOG)) { } else if (command_compare(command, NS_COMMAND_QUERYLOG)) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: control.h,v 1.3 2001/04/11 20:37:36 bwelling Exp $ */ /* $Id: control.h,v 1.4 2001/05/07 23:34:01 gson Exp $ */
#ifndef NAMED_CONTROL_H #ifndef NAMED_CONTROL_H
#define NAMED_CONTROL_H 1 #define NAMED_CONTROL_H 1
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
#define NS_COMMAND_STOP "stop" #define NS_COMMAND_STOP "stop"
#define NS_COMMAND_HALT "halt" #define NS_COMMAND_HALT "halt"
#define NS_COMMAND_RELOAD "reload" #define NS_COMMAND_RELOAD "reload"
#define NS_COMMAND_RELOADCONFIG "reload-config" #define NS_COMMAND_RECONFIG "reconfig"
#define NS_COMMAND_RELOADZONES "reload-zones"
#define NS_COMMAND_REFRESH "refresh" #define NS_COMMAND_REFRESH "refresh"
#define NS_COMMAND_DUMPSTATS "stats" #define NS_COMMAND_DUMPSTATS "stats"
#define NS_COMMAND_QUERYLOG "querylog" #define NS_COMMAND_QUERYLOG "querylog"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: server.h,v 1.53 2001/04/11 20:37:37 bwelling Exp $ */ /* $Id: server.h,v 1.54 2001/05/07 23:34:02 gson Exp $ */
#ifndef NAMED_SERVER_H #ifndef NAMED_SERVER_H
#define NAMED_SERVER_H 1 #define NAMED_SERVER_H 1
...@@ -118,6 +118,12 @@ ns_server_reloadcommand(ns_server_t *server, char *args); ...@@ -118,6 +118,12 @@ ns_server_reloadcommand(ns_server_t *server, char *args);
* Act on a "reload" command from the command channel. * Act on a "reload" command from the command channel.
*/ */
isc_result_t
ns_server_reconfigcommand(ns_server_t *server, char *args);
/*
* Act on a "reconfig" command from the command channel.
*/
isc_result_t isc_result_t
ns_server_refreshcommand(ns_server_t *server, char *args); ns_server_refreshcommand(ns_server_t *server, char *args);
/* /*
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: server.c,v 1.318 2001/04/19 23:38:32 bwelling Exp $ */ /* $Id: server.c,v 1.319 2001/05/07 23:34:00 gson Exp $ */
#include <config.h> #include <config.h>
...@@ -2065,6 +2065,28 @@ load_zones(ns_server_t *server, isc_boolean_t stop) { ...@@ -2065,6 +2065,28 @@ load_zones(ns_server_t *server, isc_boolean_t stop) {
return (result); return (result);
} }
static isc_result_t
load_new_zones(ns_server_t *server, isc_boolean_t stop) {
isc_result_t result;
dns_view_t *view;
result = isc_task_beginexclusive(server->task);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
/*
* Load zone data from disk.
*/
for (view = ISC_LIST_HEAD(server->viewlist);
view != NULL;
view = ISC_LIST_NEXT(view, link))
{
CHECK(dns_view_loadnew(view, stop));
}
cleanup:
isc_task_endexclusive(server->task);
return (result);
}
static void static void
run_server(isc_task_t *task, isc_event_t *event) { run_server(isc_task_t *task, isc_event_t *event) {
isc_result_t result; isc_result_t result;
...@@ -2309,32 +2331,64 @@ fatal(const char *msg, isc_result_t result) { ...@@ -2309,32 +2331,64 @@ fatal(const char *msg, isc_result_t result) {
exit(1); exit(1);
} }
static void static isc_result_t
ns_server_reload(isc_task_t *task, isc_event_t *event) { loadconfig(ns_server_t *server) {
isc_result_t result; isc_result_t result;
ns_server_t *server = (ns_server_t *)event->ev_arg; result = load_configuration(ns_g_lwresdonly ?
lwresd_g_conffile : ns_g_conffile,
server,
ISC_FALSE);
if (result != ISC_R_SUCCESS)
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
"reloading configuration failed: %s",
isc_result_totext(result));
return (result);
}
INSIST(task = server->task); static void
UNUSED(task); reload(ns_server_t *server) {
isc_result_t result;
CHECK(loadconfig(server));
if (ns_g_lwresdonly) result = load_zones(server, ISC_FALSE);
result = load_configuration(lwresd_g_conffile, server,
ISC_FALSE);
else
result = load_configuration(ns_g_conffile, server, ISC_FALSE);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_ERROR, NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
"reloading configuration failed: %s", "reloading zones failed: %s",
isc_result_totext(result)); isc_result_totext(result));
} }
result = load_zones(server, ISC_FALSE); cleanup: ;
}
static void
reconfig(ns_server_t *server) {
isc_result_t result;
CHECK(loadconfig(server));
result = load_new_zones(server, ISC_FALSE);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_ERROR, NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
"reloading zones failed: %s", "loading new zones failed: %s",
isc_result_totext(result)); isc_result_totext(result));
} }
cleanup: ;
}
/*
* Handle a reload event (from SIGHUP).
*/
static void
ns_server_reload(isc_task_t *task, isc_event_t *event) {
isc_result_t result;
ns_server_t *server = (ns_server_t *)event->ev_arg;
INSIST(task = server->task);
UNUSED(task);
reload(server);
LOCK(&server->reload_event_lock); LOCK(&server->reload_event_lock);
INSIST(server->reload_event == NULL); INSIST(server->reload_event == NULL);
server->reload_event = event; server->reload_event = event;
...@@ -2446,12 +2500,11 @@ ns_server_reloadcommand(ns_server_t *server, char *args) { ...@@ -2446,12 +2500,11 @@ ns_server_reloadcommand(ns_server_t *server, char *args) {
dns_zone_t *zone = NULL; dns_zone_t *zone = NULL;
dns_zonetype_t type; dns_zonetype_t type;
UNUSED(server);
result = zone_from_args(server, args, &zone); result = zone_from_args(server, args, &zone);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);
if (zone == NULL) { if (zone == NULL) {
ns_server_reloadwanted(server); reload(server);
} else { } else {
type = dns_zone_gettype(zone); type = dns_zone_gettype(zone);
if (type == dns_zone_slave || type == dns_zone_stub) if (type == dns_zone_slave || type == dns_zone_stub)
...@@ -2463,6 +2516,17 @@ ns_server_reloadcommand(ns_server_t *server, char *args) { ...@@ -2463,6 +2516,17 @@ ns_server_reloadcommand(ns_server_t *server, char *args) {
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
/*
* Act on a "reconfig" command from the command channel.
*/
isc_result_t
ns_server_reconfigcommand(ns_server_t *server, char *args) {
UNUSED(args);
reconfig(server);
return (ISC_R_SUCCESS);
}
/* /*
* Act on a "refresh" command from the command channel. * Act on a "refresh" command from the command channel.
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN" <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd"> "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
<!-- File: $Id: Bv9ARM-book.xml,v 1.126 2001/04/26 18:05:04 gson Exp $ --> <!-- File: $Id: Bv9ARM-book.xml,v 1.127 2001/05/07 23:34:13 gson Exp $ -->
<book> <book>
<title>BIND 9 Administrator Reference Manual</title> <title>BIND 9 Administrator Reference Manual</title>
...@@ -729,20 +729,33 @@ of a server.</para> ...@@ -729,20 +729,33 @@ of a server.</para>
<variablelist> <variablelist>
<varlistentry><term><userinput>reload</userinput></term> <varlistentry><term><userinput>reload</userinput></term>
<listitem><para>Reload configuration file and zones.</para></listitem></varlistentry> <listitem><para>Reload configuration file and zones.</para></listitem>
</varlistentry>
<varlistentry><term><userinput>reload <replaceable>zone</replaceable> <varlistentry><term><userinput>reload <replaceable>zone</replaceable>
<optional><replaceable>class</replaceable> <optional><replaceable>class</replaceable>
<optional><replaceable>view</replaceable></optional></optional></userinput></term> <optional><replaceable>view</replaceable></optional></optional></userinput></term>
<listitem><para>Reload the given zone.</para></listitem></varlistentry> <listitem><para>Reload the given zone.</para></listitem>
</varlistentry>
<varlistentry><term><userinput>refresh <replaceable>zone</replaceable> <varlistentry><term><userinput>refresh <replaceable>zone</replaceable>
<optional><replaceable>class</replaceable> <optional><replaceable>class</replaceable>
<optional><replaceable>view</replaceable></optional></optional></userinput></term> <optional><replaceable>view</replaceable></optional></optional></userinput></term>
<listitem><para>Schedule zone maintenance for the given zone.</para></listitem></varlistentry> <listitem><para>Schedule zone maintenance for the given zone.</para></listitem>
</varlistentry>
<varlistentry><term><userinput>reconfig</userinput></term>
<listitem><para>Reload the configuration file and load new zones,
but do not reload existing zone files even if they have changed.
This is faster than a full <command>reload</command> when there
is a large number of zones because it avoids the need to examine the
modification times of the zones files.
</para></listitem>
</varlistentry>
<varlistentry><term><userinput>stats</userinput></term> <varlistentry><term><userinput>stats</userinput></term>
<listitem><para>Write server statistics to the statistics file.</para></listitem></varlistentry> <listitem><para>Write server statistics to the statistics file.</para></listitem>
</varlistentry>
<varlistentry><term><userinput>querylog</userinput></term> <varlistentry><term><userinput>querylog</userinput></term>
<listitem><para>Toggle query logging.</para></listitem></varlistentry> <listitem><para>Toggle query logging.</para></listitem></varlistentry>
......
...@@ -949,6 +949,25 @@ CLASS="replaceable" ...@@ -949,6 +949,25 @@ CLASS="replaceable"
><TT ><TT
CLASS="userinput" CLASS="userinput"
><B ><B
>reconfig</B
></TT
></DT
><DD
><P
>Reload the configuration file and load new zones,
but do not reload existing zone files even if they have changed.
This is faster than a full <B
CLASS="command"
>reload</B
> when there
is a large number of zones because it avoids the need to examine the
modification times of the zones files.
</P
></DD
><DT
><TT
CLASS="userinput"
><B
>stats</B >stats</B
></TT ></TT
></DT ></DT
...@@ -1271,7 +1290,7 @@ CLASS="sect2" ...@@ -1271,7 +1290,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN628" NAME="AEN634"
>3.4.2. Signals</A >3.4.2. Signals</A
></H2 ></H2
><P ><P
...@@ -1284,7 +1303,7 @@ CLASS="command" ...@@ -1284,7 +1303,7 @@ CLASS="command"
><DIV ><DIV
CLASS="informaltable" CLASS="informaltable"
><A ><A
NAME="AEN632" NAME="AEN638"
></A ></A
><P ><P
></P ></P
......
...@@ -88,7 +88,7 @@ HREF="Bv9ARM.ch04.html#incremental_zone_transfers" ...@@ -88,7 +88,7 @@ HREF="Bv9ARM.ch04.html#incremental_zone_transfers"
></DT ></DT
><DT ><DT
>4.3. <A >4.3. <A
HREF="Bv9ARM.ch04.html#AEN692" HREF="Bv9ARM.ch04.html#AEN698"
>Split DNS</A >Split DNS</A
></DT ></DT
><DT ><DT
...@@ -98,12 +98,12 @@ HREF="Bv9ARM.ch04.html#tsig" ...@@ -98,12 +98,12 @@ HREF="Bv9ARM.ch04.html#tsig"
></DT ></DT
><DT ><DT
>4.5. <A >4.5. <A
HREF="Bv9ARM.ch04.html#AEN852" HREF="Bv9ARM.ch04.html#AEN858"
>TKEY</A >TKEY</A
></DT ></DT
><DT ><DT
>4.6. <A >4.6. <A
HREF="Bv9ARM.ch04.html#AEN867" HREF="Bv9ARM.ch04.html#AEN873"
>SIG(0)</A >SIG(0)</A
></DT ></DT
><DT ><DT
...@@ -113,7 +113,7 @@ HREF="Bv9ARM.ch04.html#DNSSEC" ...@@ -113,7 +113,7 @@ HREF="Bv9ARM.ch04.html#DNSSEC"
></DT ></DT
><DT ><DT
>4.8. <A >4.8. <A
HREF="Bv9ARM.ch04.html#AEN952" HREF="Bv9ARM.ch04.html#AEN958"
>IPv6 Support in <SPAN >IPv6 Support in <SPAN
CLASS="acronym" CLASS="acronym"
>BIND</SPAN >BIND</SPAN
...@@ -274,7 +274,7 @@ CLASS="sect1" ...@@ -274,7 +274,7 @@ CLASS="sect1"
><H1 ><H1
CLASS="sect1" CLASS="sect1"
><A ><A
NAME="AEN692" NAME="AEN698"
>4.3. Split DNS</A >4.3. Split DNS</A
></H1 ></H1
><P ><P
...@@ -672,7 +672,7 @@ CLASS="sect2" ...@@ -672,7 +672,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN783" NAME="AEN789"
>4.4.1. Generate Shared Keys for Each Pair of Hosts</A >4.4.1. Generate Shared Keys for Each Pair of Hosts</A
></H2 ></H2
><P ><P
...@@ -690,7 +690,7 @@ CLASS="sect3" ...@@ -690,7 +690,7 @@ CLASS="sect3"
><H3 ><H3
CLASS="sect3" CLASS="sect3"
><A ><A
NAME="AEN788" NAME="AEN794"
>4.4.1.1. Automatic Generation</A >4.4.1.1. Automatic Generation</A
></H3 ></H3
><P ><P
...@@ -732,7 +732,7 @@ CLASS="sect3" ...@@ -732,7 +732,7 @@ CLASS="sect3"
><H3 ><H3
CLASS="sect3" CLASS="sect3"
><A ><A
NAME="AEN799" NAME="AEN805"
>4.4.1.2. Manual Generation</A >4.4.1.2. Manual Generation</A
></H3 ></H3
><P ><P
...@@ -753,7 +753,7 @@ CLASS="sect2" ...@@ -753,7 +753,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN804" NAME="AEN810"
>4.4.2. Copying the Shared Secret to Both Machines</A >4.4.2. Copying the Shared Secret to Both Machines</A
></H2 ></H2
><P ><P
...@@ -765,7 +765,7 @@ CLASS="sect2" ...@@ -765,7 +765,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN807" NAME="AEN813"
>4.4.3. Informing the Servers of the Key's Existence</A >4.4.3. Informing the Servers of the Key's Existence</A
></H2 ></H2
><P ><P
...@@ -813,7 +813,7 @@ CLASS="sect2" ...@@ -813,7 +813,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN819" NAME="AEN825"
>4.4.4. Instructing the Server to Use the Key</A >4.4.4. Instructing the Server to Use the Key</A
></H2 ></H2
><P ><P
...@@ -873,7 +873,7 @@ CLASS="sect2" ...@@ -873,7 +873,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN835" NAME="AEN841"
>4.4.5. TSIG Key Based Access Control</A >4.4.5. TSIG Key Based Access Control</A
></H2 ></H2
><P ><P
...@@ -919,7 +919,7 @@ CLASS="sect2" ...@@ -919,7 +919,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN848" NAME="AEN854"
>4.4.6. Errors</A >4.4.6. Errors</A
></H2 ></H2
><P ><P
...@@ -948,7 +948,7 @@ CLASS="sect1" ...@@ -948,7 +948,7 @@ CLASS="sect1"
><H1 ><H1
CLASS="sect1" CLASS="sect1"
><A ><A
NAME="AEN852" NAME="AEN858"
>4.5. TKEY</A >4.5. TKEY</A
></H1 ></H1
><P ><P
...@@ -1014,7 +1014,7 @@ CLASS="sect1" ...@@ -1014,7 +1014,7 @@ CLASS="sect1"
><H1 ><H1
CLASS="sect1" CLASS="sect1"
><A ><A
NAME="AEN867" NAME="AEN873"
>4.6. SIG(0)</A >4.6. SIG(0)</A
></H1 ></H1
><P ><P
...@@ -1086,7 +1086,7 @@ CLASS="sect2" ...@@ -1086,7 +1086,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN884" NAME="AEN890"
>4.7.1. Generating Keys</A >4.7.1. Generating Keys</A
></H2 ></H2
><P ><P
...@@ -1165,7 +1165,7 @@ CLASS="sect2" ...@@ -1165,7 +1165,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A ><A
NAME="AEN904" NAME="AEN910"
>4.7.2. Creating a Keyset</A >4.7.2. Creating a Keyset</A
></H2 ></H2
><P ><P
...@@ -1218,7 +1218,7 @@ CLASS="sect2" ...@@ -1218,7 +1218,7 @@ CLASS="sect2"
><H2 ><H2
CLASS="sect2" CLASS="sect2"
><A