From 89227c76bebc5a757680f8c9de4c19ec967d24f6 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Tue, 4 Sep 2001 22:51:41 +0000 Subject: [PATCH] pullup: 977. [bug] Improve "not at top of zone" error message. --- CHANGES | 2 ++ lib/dns/include/dns/master.h | 3 ++- lib/dns/master.c | 23 ++++++++++++++++++++++- lib/dns/zone.c | 10 ++++++---- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 82a9fad05d..e10ef095fb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,6 @@ + 977. [bug] Improve "not at top of zone" error message. + 975. [bug] "max-cache-size default;" as a view option caused an assertion failure. diff --git a/lib/dns/include/dns/master.h b/lib/dns/include/dns/master.h index a2b2979b97..a6df12f224 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.31.2.1 2001/09/04 22:51:41 gson 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..0ccf95d88f 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.122.2.1 2001/09/04 22:51:37 gson 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 46fbf9f464..dcca1bebb3 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.333 2001/08/28 03:58:10 marka Exp $ */ +/* $Id: zone.c,v 1.333.2.1 2001/09/04 22:51:38 gson 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;