2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Support new 'database' statement in zone.

database "quoted-string";
This commit is contained in:
James Brister
2000-05-06 10:18:48 +00:00
parent 7aedafe2e3
commit 65c9645ca7
4 changed files with 108 additions and 9 deletions

View File

@@ -172,6 +172,7 @@ controls {
zone "master.demo.zone" { zone "master.demo.zone" {
type master; // what used to be called "primary" type master; // what used to be called "primary"
database "somedb -option1 -option2 arg1 arg2 arg3";
file "master.demo.zone"; file "master.demo.zone";
check-names fail; check-names fail;
allow-update { none; }; allow-update { none; };

View File

@@ -16,7 +16,7 @@
* SOFTWARE. * 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 <config.h> #include <config.h>
@@ -250,6 +250,7 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult);
%token L_CONTROLS %token L_CONTROLS
%token L_CORESIZE %token L_CORESIZE
%token L_DATASIZE %token L_DATASIZE
%token L_DATABASE
%token L_DEALLOC_ON_EXIT %token L_DEALLOC_ON_EXIT
%token L_DEBUG %token L_DEBUG
%token L_DEFAULT %token L_DEFAULT
@@ -396,7 +397,6 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult);
%type <ipaddress> query_source_v6 %type <ipaddress> query_source_v6
%type <ipaddress> ip_and_port_element %type <ipaddress> ip_and_port_element
%type <iplist> in_addr_list %type <iplist> in_addr_list
%type <iplist> notify_in_addr_list
%type <iplist> opt_in_addr_list %type <iplist> opt_in_addr_list
%type <iplist> opt_zone_forwarders_list %type <iplist> opt_zone_forwarders_list
%type <iplist> port_ip_list %type <iplist> 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_TIME_OUT | L_MAX_TRANSFER_IDLE_IN |
L_MAX_TRANSFER_IDLE_OUT | L_MAX_LOG_SIZE_IXFR | L_NOTIFY | L_MAX_TRANSFER_IDLE_OUT | L_MAX_LOG_SIZE_IXFR | L_NOTIFY |
L_MAINTAIN_IXFR_BASE | L_PUBKEY | L_ALSO_NOTIFY | L_DIALUP | 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; 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 | zone_update_policy
; ;
notify_in_addr_list: opt_in_addr_list
;
ip4_address: L_IP4ADDR ip4_address: L_IP4ADDR
{ {
isc_sockaddr_fromin(&$$, &$1, 0); isc_sockaddr_fromin(&$$, &$1, 0);
@@ -4612,6 +4628,7 @@ static struct token keyword_tokens [] = {
{ "cleaning-interval", L_CLEAN_INTERVAL }, { "cleaning-interval", L_CLEAN_INTERVAL },
{ "controls", L_CONTROLS }, { "controls", L_CONTROLS },
{ "coresize", L_CORESIZE }, { "coresize", L_CORESIZE },
{ "database", L_DATABASE },
{ "datasize", L_DATASIZE }, { "datasize", L_DATASIZE },
{ "deallocate-on-exit", L_DEALLOC_ON_EXIT }, { "deallocate-on-exit", L_DEALLOC_ON_EXIT },
{ "debug", L_DEBUG }, { "debug", L_DEBUG },

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * 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 <config.h> #include <config.h>
@@ -500,6 +500,7 @@ dns_c_zone_new(isc_mem_t *mem,
newzone->internalname = (internalname == NULL ? newzone->internalname = (internalname == NULL ?
isc_mem_strdup(mem, name) : isc_mem_strdup(mem, name) :
isc_mem_strdup(mem, internalname)); isc_mem_strdup(mem, internalname));
newzone->database = NULL;
switch (ztype) { switch (ztype) {
case dns_c_zone_master: case dns_c_zone_master:
@@ -613,6 +614,12 @@ dns_c_zone_print(FILE *fp, int indent, dns_c_zone_t *zone)
break; 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); dns_c_printtabs(fp, indent);
fprintf(fp, "};\n"); fprintf(fp, "};\n");
} }
@@ -3868,6 +3875,11 @@ zone_delete(dns_c_zone_t **zone)
isc_mem_free(z->mem, z->name); isc_mem_free(z->mem, z->name);
isc_mem_free(z->mem, z->internalname); isc_mem_free(z->mem, z->internalname);
if (z->database != NULL) {
isc_mem_free(z->mem, z->database);
z->database = NULL;
}
switch(z->ztype) { switch(z->ztype) {
case dns_c_zone_master: case dns_c_zone_master:
res = master_zone_clear(z->mem, &z->u.mzone); res = master_zone_clear(z->mem, &z->u.mzone);
@@ -4124,3 +4136,60 @@ set_iplist_field(isc_mem_t *mem,
return (res); 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);
}
}

View File

@@ -200,6 +200,7 @@ struct dns_c_zone {
char *name; /* e.g. "foo.com" */ char *name; /* e.g. "foo.com" */
char *internalname; /* e.g. "foo.com.ext" */ char *internalname; /* e.g. "foo.com.ext" */
char *database;
dns_rdataclass_t zclass; dns_rdataclass_t zclass;
dns_c_view_t *view; 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 isc_result_t
dns_c_zone_unsetallowupd(dns_c_zone_t *zone); 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 ISC_LANG_ENDDECLS
#endif /* DNS_CONFZONE_H */ #endif /* DNS_CONFZONE_H */