diff --git a/CHANGES b/CHANGES index 96d364222a..72dcf4674a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + 977. [bug] Improve "not at top of zone" error message. + 976. [func] named-checkconf will now test load master zone files (-z). [RT #1468] diff --git a/lib/dns/include/dns/master.h b/lib/dns/include/dns/master.h index a2b2979b97..2e9f5ed529 100644 --- a/lib/dns/include/dns/master.h +++ b/lib/dns/include/dns/master.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: master.h,v 1.31 2001/02/01 21:29:35 marka Exp $ */ +/* $Id: master.h,v 1.32 2001/09/04 00:35:19 marka Exp $ */ #ifndef DNS_MASTER_H #define DNS_MASTER_H 1 @@ -36,6 +36,7 @@ #define DNS_MASTER_AGETTL 0x00000001 /* Age the ttl based on $DATE. */ #define DNS_MASTER_MANYERRORS 0x00000002 /* Continue processing on errors. */ #define DNS_MASTER_NOINCLUDE 0x00000004 /* Disallow $INCLUDE directives. */ +#define DNS_MASTER_ZONE 0x00000008 /* Loading a zone master file. */ ISC_LANG_BEGINDECLS diff --git a/lib/dns/master.c b/lib/dns/master.c index ee9ace5d62..6c10199820 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.122 2001/08/28 03:58:05 marka Exp $ */ +/* $Id: master.c,v 1.123 2001/09/04 00:35:17 marka Exp $ */ #include @@ -1396,6 +1396,27 @@ load(dns_loadctx_t *lctx) { continue; } + if (type == dns_rdatatype_soa && + (lctx->options & DNS_MASTER_ZONE) != 0 && + dns_name_compare(ictx->current, lctx->top) != 0) { + char namebuf[DNS_NAME_FORMATSIZE]; + dns_name_format(ictx->current, namebuf, + sizeof(namebuf)); + (*callbacks->error)(callbacks, + "dns_master_load: %s:%lu: SOA " + "record not at top of zone (%s)", + source, line, namebuf); + result = DNS_R_NOTZONETOP; + if (MANYERRS(lctx, result)) { + SETRESULT(lctx, result); + read_till_eol = ISC_TRUE; + target = target_ft; + continue; + } else if (result != ISC_R_SUCCESS) + goto insist_and_cleanup; + } + + if (type == dns_rdatatype_sig) covers = dns_rdata_covers(&rdata[rdcount]); else diff --git a/lib/dns/zone.c b/lib/dns/zone.c index b287a7cb9b..081ac8a3a9 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zone.c,v 1.339 2001/09/03 01:21:19 marka Exp $ */ +/* $Id: zone.c,v 1.340 2001/09/04 00:35:15 marka Exp $ */ #include @@ -1036,7 +1036,8 @@ zone_gotreadhandle(isc_task_t *task, isc_event_t *event) { result = dns_master_loadfileinc(load->zone->masterfile, dns_db_origin(load->db), dns_db_origin(load->db), - load->zone->rdclass, 0, + load->zone->rdclass, + DNS_MASTER_ZONE, &load->callbacks, task, zone_loaddone, load, &load->zone->lctx, load->zone->mctx); @@ -1087,16 +1088,17 @@ zone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) { result = DNS_R_CONTINUE; } else if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_MANYERRORS)) { dns_rdatacallbacks_t callbacks; + unsigned int options; dns_rdatacallbacks_init(&callbacks); result = dns_db_beginload(db, &callbacks.add, &callbacks.add_private); if (result != ISC_R_SUCCESS) return (result); + options = DNS_MASTER_MANYERRORS|DNS_MASTER_ZONE; result = dns_master_loadfile(zone->masterfile, &zone->origin, &zone->origin, zone->rdclass, - DNS_MASTER_MANYERRORS, - &callbacks, zone->mctx); + options, &callbacks, zone->mctx); tresult = dns_db_endload(db, &callbacks.add_private); if (result == ISC_R_SUCCESS) result = tresult;