2930. [experimental] New "rndc addzone" and "rndc delzone" commads

allow dynamic addition and deletion of zones.
			To enable this feature, specify a "new-zone-file"
			option at the view or options level in named.conf.
			Zone configuration information for the new zones
			will be written into that file.  To make the new
			zones persist after a restart, "include" the file
			into named.conf in the appropriate view.  (Note:
			This feature is not yet documented, and its syntax
			is expected to change.) [RT #19447]
This commit is contained in:
Evan Hunt
2010-07-11 00:12:57 +00:00
parent 773896a200
commit 86dcc40058
13 changed files with 734 additions and 36 deletions
+2 -2
View File
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: resolver.h,v 1.66 2010/02/25 05:08:01 tbox Exp $ */
/* $Id: resolver.h,v 1.67 2010/07/11 00:12:57 each Exp $ */
#ifndef DNS_RESOLVER_H
#define DNS_RESOLVER_H 1
@@ -180,7 +180,7 @@ dns_resolver_freeze(dns_resolver_t *res);
*
* Requires:
*
*\li 'res' is a valid, unfrozen resolver.
*\li 'res' is a valid resolver.
*
* Ensures:
*
+17 -2
View File
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: view.h,v 1.124 2010/06/22 03:58:38 marka Exp $ */
/* $Id: view.h,v 1.125 2010/07/11 00:12:57 each Exp $ */
#ifndef DNS_VIEW_H
#define DNS_VIEW_H 1
@@ -416,7 +416,7 @@ dns_view_addzone(dns_view_t *view, dns_zone_t *zone);
void
dns_view_freeze(dns_view_t *view);
/*%<
* Freeze view.
* Freeze view. No changes can be made to view configuration while frozen.
*
* Requires:
*
@@ -427,6 +427,21 @@ dns_view_freeze(dns_view_t *view);
*\li 'view' is frozen.
*/
void
dns_view_thaw(dns_view_t *view);
/*%<
* Thaw view. This allows zones to be added or removed at runtime. This is
* NOT thread-safe; the caller MUST have run isc_task_exclusive() prior to
* thawing the view.
*
* Requires:
*
*\li 'view' is a valid, frozen view.
*
* Ensures:
*
*\li 'view' is no longer frozen.
*/
isc_result_t
dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints,
+1 -3
View File
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: resolver.c,v 1.424 2010/07/04 00:48:57 marka Exp $ */
/* $Id: resolver.c,v 1.425 2010/07/11 00:12:57 each Exp $ */
/*! \file */
@@ -7684,13 +7684,11 @@ dns_resolver_prime(dns_resolver_t *res) {
void
dns_resolver_freeze(dns_resolver_t *res) {
/*
* Freeze resolver.
*/
REQUIRE(VALID_RESOLVER(res));
REQUIRE(!res->frozen);
res->frozen = ISC_TRUE;
}
+21 -13
View File
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: view.c,v 1.165 2010/06/22 03:58:38 marka Exp $ */
/* $Id: view.c,v 1.166 2010/07/11 00:12:57 each Exp $ */
/*! \file */
@@ -709,7 +709,27 @@ dns_view_setdstport(dns_view_t *view, in_port_t dstport) {
view->dstport = dstport;
}
void
dns_view_freeze(dns_view_t *view) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(!view->frozen);
if (view->resolver != NULL) {
INSIST(view->cachedb != NULL);
dns_resolver_freeze(view->resolver);
}
view->frozen = ISC_TRUE;
}
#ifdef BIND9
void
dns_view_thaw(dns_view_t *view) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(view->frozen);
view->frozen = ISC_FALSE;
}
isc_result_t
dns_view_addzone(dns_view_t *view, dns_zone_t *zone) {
isc_result_t result;
@@ -723,18 +743,6 @@ dns_view_addzone(dns_view_t *view, dns_zone_t *zone) {
}
#endif
void
dns_view_freeze(dns_view_t *view) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(!view->frozen);
if (view->resolver != NULL) {
INSIST(view->cachedb != NULL);
dns_resolver_freeze(view->resolver);
}
view->frozen = ISC_TRUE;
}
#ifdef BIND9
isc_result_t
dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep) {
+4 -1
View File
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: namedconf.h,v 1.15 2009/07/31 23:43:23 each Exp $ */
/* $Id: namedconf.h,v 1.16 2010/07/11 00:12:57 each Exp $ */
#ifndef ISCCFG_NAMEDCONF_H
#define ISCCFG_NAMEDCONF_H 1
@@ -36,6 +36,9 @@ LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_namedconf;
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_bindkeys;
/*%< A bind.keys file. */
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_addzoneconf;
/*%< A single zone passed via the addzone rndc command. */
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_rndcconf;
/*%< A complete rndc.conf file. */
+64 -1
View File
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: namedconf.c,v 1.119 2010/06/25 03:24:05 marka Exp $ */
/* $Id: namedconf.c,v 1.120 2010/07/11 00:12:57 each Exp $ */
/*! \file */
@@ -101,6 +101,7 @@ static cfg_type_t cfg_type_negated;
static cfg_type_t cfg_type_notifytype;
static cfg_type_t cfg_type_optional_allow;
static cfg_type_t cfg_type_optional_class;
static cfg_type_t cfg_type_optional_qstring;
static cfg_type_t cfg_type_optional_facility;
static cfg_type_t cfg_type_optional_keyref;
static cfg_type_t cfg_type_optional_port;
@@ -888,6 +889,7 @@ options_clauses[] = {
{ "use-ixfr", &cfg_type_boolean, 0 },
{ "version", &cfg_type_qstringornone, 0 },
{ "flush-zones-on-shutdown", &cfg_type_boolean, 0 },
{ "new-zone-file", &cfg_type_qstringornone, 0 },
{ NULL, NULL, 0 }
};
@@ -1057,6 +1059,7 @@ view_clauses[] = {
{ "transfer-format", &cfg_type_transferformat, 0 },
{ "use-queryport-pool", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
{ "zero-no-soa-ttl-cache", &cfg_type_boolean, 0 },
{ "new-zone-file", &cfg_type_qstringornone, 0 },
#ifdef ALLOW_FILTER_AAAA_ON_V4
{ "filter-aaaa", &cfg_type_bracketed_aml, 0 },
{ "filter-aaaa-on-v4", &cfg_type_v4_aaaa, 0 },
@@ -1396,6 +1399,42 @@ static cfg_type_t cfg_type_logging = {
"logging", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, logging_clausesets };
/*%
* For parsing an 'addzone' statement
*/
/*%
* A zone statement.
*/
static cfg_tuplefielddef_t addzone_fields[] = {
{ "filepart", &cfg_type_optional_qstring, 0 },
{ "name", &cfg_type_astring, 0 },
{ "class", &cfg_type_optional_class, 0 },
{ "view", &cfg_type_optional_class, 0 },
{ "options", &cfg_type_zoneopts, 0 },
{ NULL, NULL, 0 }
};
static cfg_type_t cfg_type_addzone = {
"addzone", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, addzone_fields };
static cfg_clausedef_t
addzoneconf_clauses[] = {
{ "addzone", &cfg_type_addzone, 0 },
{ NULL, NULL, 0 }
};
static cfg_clausedef_t *
addzoneconf_clausesets[] = {
addzoneconf_clauses,
NULL
};
LIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_addzoneconf = {
"addzoneconf", cfg_parse_mapbody, cfg_print_mapbody, cfg_doc_mapbody,
&cfg_rep_map, addzoneconf_clausesets
};
static isc_result_t
parse_unitstring(char *str, isc_resourcevalue_t *valuep) {
char *endp;
@@ -1798,6 +1837,30 @@ static cfg_type_t cfg_type_optional_class = {
NULL, NULL
};
/*%
* An optional string, distinguished by being in quotes
*/
static isc_result_t
parse_optional_qstr(cfg_parser_t *pctx, const cfg_type_t *type,
cfg_obj_t **ret)
{
isc_result_t result;
UNUSED(type);
CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
if (pctx->token.type == isc_tokentype_qstring)
CHECK(cfg_parse_obj(pctx, &cfg_type_qstring, ret));
else
CHECK(cfg_parse_obj(pctx, &cfg_type_void, ret));
cleanup:
return (result);
}
static cfg_type_t cfg_type_optional_qstring = {
"optional_quoted_string", parse_optional_qstr, NULL, cfg_doc_terminal,
NULL, NULL
};
static isc_result_t
parse_querysource(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;