From 65c9645ca7385e68fb8be1b136cc498a3a9f325d Mon Sep 17 00:00:00 2001 From: James Brister Date: Sat, 6 May 2000 10:18:48 +0000 Subject: [PATCH] Support new 'database' statement in zone. database "quoted-string"; --- bin/tests/named.conf | 1 + lib/dns/config/confparser.y | 29 ++++++++++--- lib/dns/config/confzone.c | 75 ++++++++++++++++++++++++++++++++-- lib/dns/include/dns/confzone.h | 12 ++++++ 4 files changed, 108 insertions(+), 9 deletions(-) diff --git a/bin/tests/named.conf b/bin/tests/named.conf index a33a28d25a..68a23d99fc 100644 --- a/bin/tests/named.conf +++ b/bin/tests/named.conf @@ -172,6 +172,7 @@ controls { zone "master.demo.zone" { type master; // what used to be called "primary" + database "somedb -option1 -option2 arg1 arg2 arg3"; file "master.demo.zone"; check-names fail; allow-update { none; }; diff --git a/lib/dns/config/confparser.y b/lib/dns/config/confparser.y index 0c237d0523..c7286e1408 100644 --- a/lib/dns/config/confparser.y +++ b/lib/dns/config/confparser.y @@ -16,7 +16,7 @@ * SOFTWARE. */ -/* $Id: confparser.y,v 1.71 2000/05/03 19:29:38 brister Exp $ */ +/* $Id: confparser.y,v 1.72 2000/05/06 10:18:46 brister Exp $ */ #include @@ -250,6 +250,7 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult); %token L_CONTROLS %token L_CORESIZE %token L_DATASIZE +%token L_DATABASE %token L_DEALLOC_ON_EXIT %token L_DEBUG %token L_DEFAULT @@ -396,7 +397,6 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult); %type query_source_v6 %type ip_and_port_element %type in_addr_list -%type notify_in_addr_list %type opt_in_addr_list %type opt_zone_forwarders_list %type port_ip_list @@ -3925,7 +3925,7 @@ zone_non_type_keywords: L_FILE | L_FILE_IXFR | L_IXFR_TMP | L_MASTERS | L_MAX_TRANSFER_TIME_OUT | L_MAX_TRANSFER_IDLE_IN | L_MAX_TRANSFER_IDLE_OUT | L_MAX_LOG_SIZE_IXFR | L_NOTIFY | L_MAINTAIN_IXFR_BASE | L_PUBKEY | L_ALSO_NOTIFY | L_DIALUP | - L_DISABLED + L_DISABLED | L_DATABASE ; @@ -4367,13 +4367,29 @@ zone_option: L_FILE L_QSTRING { disabled = ISC_TRUE; } + | L_DATABASE L_QSTRING + { + dns_c_zone_t *zone = dns_c_ctx_getcurrzone(currcfg); + + INSIST(zone != NULL); + + tmpres = dns_c_zone_setdatabase(zone, $2); + isc_mem_free(memctx, $2); + + if (tmpres == ISC_R_EXISTS) { + parser_warning(ISC_FALSE, + "redefining zone database."); + } else if (tmpres != ISC_R_SUCCESS) { + parser_error(ISC_FALSE, + "failed to set zone database."); + YYABORT; + } + + } | zone_update_policy ; -notify_in_addr_list: opt_in_addr_list - ; - ip4_address: L_IP4ADDR { isc_sockaddr_fromin(&$$, &$1, 0); @@ -4612,6 +4628,7 @@ static struct token keyword_tokens [] = { { "cleaning-interval", L_CLEAN_INTERVAL }, { "controls", L_CONTROLS }, { "coresize", L_CORESIZE }, + { "database", L_DATABASE }, { "datasize", L_DATASIZE }, { "deallocate-on-exit", L_DEALLOC_ON_EXIT }, { "debug", L_DEBUG }, diff --git a/lib/dns/config/confzone.c b/lib/dns/config/confzone.c index 8942bcf36d..9819e4da40 100644 --- a/lib/dns/config/confzone.c +++ b/lib/dns/config/confzone.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: confzone.c,v 1.38 2000/05/03 19:29:41 brister Exp $ */ +/* $Id: confzone.c,v 1.39 2000/05/06 10:18:47 brister Exp $ */ #include @@ -500,7 +500,8 @@ dns_c_zone_new(isc_mem_t *mem, newzone->internalname = (internalname == NULL ? isc_mem_strdup(mem, name) : isc_mem_strdup(mem, internalname)); - + newzone->database = NULL; + switch (ztype) { case dns_c_zone_master: res = master_zone_init(&newzone->u.mzone); @@ -580,7 +581,7 @@ dns_c_zone_print(FILE *fp, int indent, dns_c_zone_t *zone) } fprintf(fp, " {\n"); - + switch (zone->ztype) { case dns_c_zone_master: dns_c_printtabs(fp, indent + 1); @@ -613,6 +614,12 @@ dns_c_zone_print(FILE *fp, int indent, dns_c_zone_t *zone) break; } + if (zone->database != NULL) { + fprintf(fp, "\n"); + dns_c_printtabs(fp, indent + 1); + fprintf(fp, "database \"%s\";\n", zone->database); + } + dns_c_printtabs(fp, indent); fprintf(fp, "};\n"); } @@ -3867,6 +3874,11 @@ zone_delete(dns_c_zone_t **zone) isc_mem_free(z->mem, z->name); isc_mem_free(z->mem, z->internalname); + + if (z->database != NULL) { + isc_mem_free(z->mem, z->database); + z->database = NULL; + } switch(z->ztype) { case dns_c_zone_master: @@ -4124,3 +4136,60 @@ set_iplist_field(isc_mem_t *mem, return (res); } + +isc_result_t +dns_c_zone_setdatabase(dns_c_zone_t *zone, const char *database) +{ + isc_boolean_t existed = ISC_FALSE; + + REQUIRE(DNS_C_ZONE_VALID(zone)); + REQUIRE(database != NULL); + REQUIRE(database[0] != '\0'); + + if (zone->database != NULL) { + existed = ISC_TRUE; + isc_mem_free(zone->mem, zone->database); + } + + zone->database = isc_mem_strdup(zone->mem, database); + if (zone->database == NULL) { + return (ISC_R_NOMEMORY); + } else if (existed) { + return (ISC_R_EXISTS); + } else { + return (ISC_R_SUCCESS); + } +} + + + +isc_result_t +dns_c_zone_getdatabase(dns_c_zone_t *zone, char **retval) +{ + REQUIRE(DNS_C_ZONE_VALID(zone)); + REQUIRE(retval != NULL); + + *retval = zone->database; + if (zone->database == NULL) { + return (ISC_R_NOTFOUND); + } else { + return (ISC_R_SUCCESS); + } +} + + + +isc_result_t +dns_c_zone_unsetdatabase(dns_c_zone_t *zone) +{ + REQUIRE(DNS_C_ZONE_VALID(zone)); + + if (zone->database == NULL) { + return (ISC_R_NOTFOUND); + } else { + isc_mem_free(zone->mem, zone->database); + zone->database = NULL; + return (ISC_R_SUCCESS); + } +} + diff --git a/lib/dns/include/dns/confzone.h b/lib/dns/include/dns/confzone.h index 52d3448715..3749fb16db 100644 --- a/lib/dns/include/dns/confzone.h +++ b/lib/dns/include/dns/confzone.h @@ -200,6 +200,7 @@ struct dns_c_zone { char *name; /* e.g. "foo.com" */ char *internalname; /* e.g. "foo.com.ext" */ + char *database; dns_rdataclass_t zclass; dns_c_view_t *view; @@ -448,6 +449,17 @@ dns_c_zone_getallowupd(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval); isc_result_t dns_c_zone_unsetallowupd(dns_c_zone_t *zone); + +isc_result_t +dns_c_zone_setdatabase(dns_c_zone_t *zone, const char *database); + +isc_result_t +dns_c_zone_getdatabase(dns_c_zone_t *zone, char **retval); + +isc_result_t +dns_c_zone_unsetdatabase(dns_c_zone_t *zone); + + ISC_LANG_ENDDECLS #endif /* DNS_CONFZONE_H */