From: Mark Andrews Date: Thu, 17 Apr 2003 11:31:02 +0000 (+0000) Subject: 1467. [func] $GENERATES now supports optional class and ttl. X-Git-Tag: v9.2.3rc1~104^2~22 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=397f86cf2767cabfb8b4238188187e2abc8a48d1;p=thirdparty%2Fbind9.git 1467. [func] $GENERATES now supports optional class and ttl. --- diff --git a/CHANGES b/CHANGES index c4c09bae9f1..e0e6a7fe41a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +1467. [func] $GENERATES now supports optional class and ttl. + 1466. [bug] lwresd configuration errors resulted in memory and lock leaks. [RT #5228] diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml index f0d13f63263..f43713f8d02 100644 --- a/doc/arm/Bv9ARM-book.xml +++ b/doc/arm/Bv9ARM-book.xml @@ -2,7 +2,7 @@ - + BIND 9 Administrator Reference Manual @@ -5440,7 +5440,7 @@ This could be construed as a deviation from RFC 1035, a feature, or both. with undefined TTLs. Valid TTLs are of the range 0-2147483647 seconds. $TTL is defined in RFC 2308. <acronym>BIND</acronym> Master File Extension: the <command>$GENERATE</command> Directive - Syntax: $GENERATE range lhs type rhs comment + Syntax: $GENERATE range lhs ttl class type rhs comment $GENERATE is used to create a series of resource records that only differ from each other by an iterator. $GENERATE can be used to easily generate the sets of records required to support @@ -5491,6 +5491,22 @@ the name. For compatibility with earlier versions $$ is still recognised a indicating a literal $ in the output. + + ttl + ttl specifies the + ttl of the generated records. If not specified this will be + inherited using the normal ttl inhertance rules. + class and ttl can be + entered in either order. + + + class + class specifies the + class of the generated records. This must match the zone class if + it is specified. + class and ttl can be + entered in either order. + type At present the only supported types are @@ -5505,6 +5521,7 @@ similarly to lhs. The $GENERATE directive is a BIND extension and not part of the standard zone file format. + BIND 8 does not support the optional TTL and CLASS fields. diff --git a/lib/dns/master.c b/lib/dns/master.c index a1541a72200..7e291be95d1 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: master.c,v 1.144 2003/04/17 05:40:45 marka Exp $ */ +/* $Id: master.c,v 1.145 2003/04/17 11:31:02 marka Exp $ */ #include @@ -869,6 +869,8 @@ load(dns_loadctx_t *lctx) { unsigned long line = 0; isc_boolean_t explicit_ttl; isc_stdtime_t now; + char classname1[DNS_RDATACLASS_FORMATSIZE]; + char classname2[DNS_RDATACLASS_FORMATSIZE]; REQUIRE(DNS_LCTX_VALID(lctx)); callbacks = lctx->callbacks; @@ -1059,24 +1061,6 @@ load(dns_loadctx_t *lctx) { continue; } else if (strcasecmp(DNS_AS_STR(token), "$GENERATE") == 0) { - /* - * Use default ttl if known otherwise - * inherit or error. - */ - if (!lctx->ttl_known && - !lctx->default_ttl_known) { - (*callbacks->error)(callbacks, - "%s: %s:%lu: no TTL specified", - "dns_master_load", source, line); - result = DNS_R_NOTTL; - if (MANYERRS(lctx, result)) { - SETRESULT(lctx, result); - lctx->ttl = 0; - } else if (result != ISC_R_SUCCESS) - goto insist_and_cleanup; - } else if (lctx->default_ttl_known) { - lctx->ttl = lctx->default_ttl; - } /* * Lazy cleanup. */ @@ -1088,7 +1072,7 @@ load(dns_loadctx_t *lctx) { isc_mem_free(mctx, gtype); if (rhs != NULL) isc_mem_free(mctx, rhs); - /* range */ + /* RANGE */ GETTOKEN(lctx->lex, 0, &token, ISC_FALSE); range = isc_mem_strdup(mctx, DNS_AS_STR(token)); @@ -1103,8 +1087,35 @@ load(dns_loadctx_t *lctx) { result = ISC_R_NOMEMORY; goto log_and_cleanup; } - /* TYPE */ + rdclass = 0; + explicit_ttl = ISC_FALSE; + /* CLASS? */ GETTOKEN(lctx->lex, 0, &token, ISC_FALSE); + if (dns_rdataclass_fromtext(&rdclass, + &token.value.as_textregion) + == ISC_R_SUCCESS) { + GETTOKEN(lctx->lex, 0, &token, + ISC_FALSE); + } + /* TTL? */ + if (dns_ttl_fromtext(&token.value.as_textregion, + &lctx->ttl) + == ISC_R_SUCCESS) { + limit_ttl(callbacks, source, line, + &lctx->ttl); + lctx->ttl_known = ISC_TRUE; + explicit_ttl = ISC_TRUE; + GETTOKEN(lctx->lex, 0, &token, + ISC_FALSE); + } + /* CLASS? */ + if (rdclass == 0 && + dns_rdataclass_fromtext(&rdclass, + &token.value.as_textregion) + == ISC_R_SUCCESS) + GETTOKEN(lctx->lex, 0, &token, + ISC_FALSE); + /* TYPE */ gtype = isc_mem_strdup(mctx, DNS_AS_STR(token)); if (gtype == NULL) { @@ -1118,6 +1129,29 @@ load(dns_loadctx_t *lctx) { result = ISC_R_NOMEMORY; goto log_and_cleanup; } + if (!lctx->ttl_known && + !lctx->default_ttl_known) { + (*callbacks->error)(callbacks, + "%s: %s:%lu: no TTL specified", + "dns_master_load", source, line); + result = DNS_R_NOTTL; + if (MANYERRS(lctx, result)) { + SETRESULT(lctx, result); + lctx->ttl = 0; + } else if (result != ISC_R_SUCCESS) + goto insist_and_cleanup; + } else if (!explicit_ttl && + lctx->default_ttl_known) { + lctx->ttl = lctx->default_ttl; + } + /* + * If the class specified does not match the + * zone's class print out a error message and + * exit. + */ + if (rdclass != 0 && rdclass != lctx->zclass) { + goto bad_class; + } result = generate(lctx, range, lhs, gtype, rhs, source, line); if (MANYERRS(lctx, result)) { @@ -1405,8 +1439,7 @@ load(dns_loadctx_t *lctx) { * print out a error message and exit. */ if (rdclass != 0 && rdclass != lctx->zclass) { - char classname1[DNS_RDATACLASS_FORMATSIZE]; - char classname2[DNS_RDATACLASS_FORMATSIZE]; + bad_class: dns_rdataclass_format(rdclass, classname1, sizeof(classname1));