From: Mark Andrews Date: Tue, 17 Oct 2000 07:22:39 +0000 (+0000) Subject: 521. [bug] Detect master files which contain $INCLUDE and always X-Git-Tag: v9.0.1^4~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b20ee662a7c847c9ef7b96ab9e5e34543efe5c0d;p=thirdparty%2Fbind9.git 521. [bug] Detect master files which contain $INCLUDE and always reload. [RT #196] new result code DNS_R_SEENINCLUDE dns_master_load* can now return DNS_R_SEENINCLUDE --- diff --git a/CHANGES b/CHANGES index 59c64058278..9091653fe41 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ + 521. [bug] Detect master files which contain $INCLUDE and always + reload. [RT #196] + 520. [bug] Upgraded libtool to 1.3.5, which allows shared library builds to work on AIX (and possibly others). diff --git a/bin/dnssec/dnssec-signkey.c b/bin/dnssec/dnssec-signkey.c index 2d3f1082253..8f8db1e2ed6 100644 --- a/bin/dnssec/dnssec-signkey.c +++ b/bin/dnssec/dnssec-signkey.c @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dnssec-signkey.c,v 1.37 2000/09/26 22:11:22 bwelling Exp $ */ +/* $Id: dnssec-signkey.c,v 1.38 2000/10/17 07:22:21 marka Exp $ */ #include @@ -273,7 +273,7 @@ main(int argc, char *argv[]) { check_result(result, "dns_db_create()"); result = dns_db_load(db, argv[0]); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) fatal("failed to load database from '%s': %s", argv[0], isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 8bdbdadd6b5..580c2d5ba4a 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dnssec-signzone.c,v 1.100 2000/09/26 22:11:23 bwelling Exp $ */ +/* $Id: dnssec-signzone.c,v 1.101 2000/10/17 07:22:22 marka Exp $ */ #include @@ -460,7 +460,7 @@ opendb(const char *prefix, dns_name_t *name, dns_rdataclass_t rdclass, check_result(result, "dns_db_create()"); result = dns_db_load(*db, filename); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) dns_db_detach(db); } diff --git a/bin/named/server.c b/bin/named/server.c index 842ded41719..307cdc1158c 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.229 2000/10/13 22:35:45 bwelling Exp $ */ +/* $Id: server.c,v 1.230 2000/10/17 07:22:23 marka Exp $ */ #include @@ -477,6 +477,7 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview, NS_LOGMODULE_SERVER, ISC_LOG_DEBUG(1), "loading cache '%s'", ns_g_cachefile); + /* DNS_R_SEENINCLUDE should be impossible here. */ CHECK(dns_db_load(view->cachedb, ns_g_cachefile)); } diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index d6f9fd57aee..e9e2fea6555 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zoneconf.c,v 1.62 2000/10/13 23:21:16 bwelling Exp $ */ +/* $Id: zoneconf.c,v 1.63 2000/10/17 07:22:35 marka Exp $ */ #include @@ -239,12 +239,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview, dns_zone_setqueryacl, dns_zone_clearqueryacl)); - result = dns_c_zone_getdialup(czone, &boolean); - if (result != ISC_R_SUCCESS) - result = dns_c_ctx_getdialup(cctx, &boolean); - if (result != ISC_R_SUCCESS) - boolean = ISC_FALSE; - dns_zone_setoption(zone, DNS_ZONEOPT_DIALUP, boolean); + if (czone->ztype != dns_c_zone_hint) { + result = dns_c_zone_getdialup(czone, &boolean); + if (result != ISC_R_SUCCESS) + result = dns_c_ctx_getdialup(cctx, &boolean); + if (result != ISC_R_SUCCESS) + boolean = ISC_FALSE; + dns_zone_setoption(zone, DNS_ZONEOPT_DIALUP, boolean); + } #ifndef NOMINUM_PUBLIC if (czone->ztype != dns_c_zone_stub) { diff --git a/bin/tests/db_test.c b/bin/tests/db_test.c index 2fd0d1d78bd..2571d1974dd 100644 --- a/bin/tests/db_test.c +++ b/bin/tests/db_test.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: db_test.c,v 1.53 2000/08/01 01:12:40 tale Exp $ */ +/* $Id: db_test.c,v 1.54 2000/10/17 07:22:25 marka Exp $ */ /* * Principal Author: Bob Halley @@ -284,7 +284,7 @@ load(const char *filename, const char *origintext, isc_boolean_t cache) { printf("loading %s (%s)\n", filename, origintext); result = dns_db_load(dbi->db, filename); - if (result != ISC_R_SUCCESS) { + if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) { dns_db_detach(&dbi->db); isc_mem_put(mctx, dbi, sizeof *dbi); return (result); diff --git a/bin/tests/master/dns_master_load_8_data b/bin/tests/master/dns_master_load_8_data index 84428a31ba5..b109d43b8de 100644 --- a/bin/tests/master/dns_master_load_8_data +++ b/bin/tests/master/dns_master_load_8_data @@ -9,4 +9,4 @@ # class is the zone's class # expected_result is a text representation of a dns_result_t # -master8.data test in ISC_R_SUCCESS +master8.data test in DNS_R_SEENINCLUDE diff --git a/bin/tests/nxtify.c b/bin/tests/nxtify.c index 58ac25115cd..e7ff4130dc2 100644 --- a/bin/tests/nxtify.c +++ b/bin/tests/nxtify.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nxtify.c,v 1.16 2000/09/15 21:40:39 bwelling Exp $ */ +/* $Id: nxtify.c,v 1.17 2000/10/17 07:22:26 marka Exp $ */ #include @@ -146,6 +146,8 @@ nxtify(char *filename) { dns_rdataclass_in, 0, NULL, &db); check_result(result, "dns_db_create()"); result = dns_db_load(db, filename); + if (result == DNS_R_SEENINCLUDE) + result = ISC_R_SUCCCESS; check_result(result, "dns_db_load()"); wversion = NULL; result = dns_db_newversion(db, &wversion); diff --git a/lib/dns/db.c b/lib/dns/db.c index 79d7269e650..93191231c6e 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: db.c,v 1.56 2000/09/26 22:45:52 bwelling Exp $ */ +/* $Id: db.c,v 1.57 2000/10/17 07:22:29 marka Exp $ */ /*** *** Imports @@ -32,6 +32,7 @@ #include #include #include +#include /*** *** Private Types @@ -287,7 +288,7 @@ dns_db_load(dns_db_t *db, const char *filename) { * result if dns_master_loadfile() succeeded. If dns_master_loadfile() * failed, we want to return the result code it gave us. */ - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE) result = eresult; return (result); diff --git a/lib/dns/include/dns/master.h b/lib/dns/include/dns/master.h index d9a451b2b85..269bbf4bd4f 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.24 2000/09/05 03:35:22 marka Exp $ */ +/* $Id: master.h,v 1.25 2000/10/17 07:22:36 marka Exp $ */ #ifndef DNS_MASTER_H #define DNS_MASTER_H 1 @@ -136,6 +136,8 @@ dns_master_loadfilequota(const char *master_file, dns_name_t *top, * * Returns: * ISC_R_SUCCESS upon successfully loading the master file. + * ISC_R_SEENINCLUDE upon successfully loading the master file with + * a $INCLUDE statement. * ISC_R_NOMEMORY out of memory. * ISC_R_UNEXPECTEDEND expected to be able to read a input token and * there was not one. diff --git a/lib/dns/include/dns/result.h b/lib/dns/include/dns/result.h index fbc01b4783a..453179eb956 100644 --- a/lib/dns/include/dns/result.h +++ b/lib/dns/include/dns/result.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: result.h,v 1.68 2000/10/16 04:08:13 marka Exp $ */ +/* $Id: result.h,v 1.69 2000/10/17 07:22:38 marka Exp $ */ #ifndef DNS_RESULT_H #define DNS_RESULT_H 1 @@ -102,8 +102,9 @@ #define DNS_R_RECOVERABLE (ISC_RESULTCLASS_DNS + 63) #define DNS_R_UNKNOWNOPT (ISC_RESULTCLASS_DNS + 64) #define DNS_R_UNEXPECTEDID (ISC_RESULTCLASS_DNS + 65) +#define DNS_R_SEENINCLUDE (ISC_RESULTCLASS_DNS + 66) -#define DNS_R_NRESULTS 66 /* Number of results */ +#define DNS_R_NRESULTS 67 /* Number of results */ /* * DNS wire format rcodes. diff --git a/lib/dns/master.c b/lib/dns/master.c index adaf288e950..86c4d48cc19 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.72 2000/09/23 01:05:35 bwelling Exp $ */ +/* $Id: master.c,v 1.73 2000/10/17 07:22:30 marka Exp $ */ #include @@ -99,6 +99,7 @@ struct dns_loadctx { isc_boolean_t default_ttl_known; isc_boolean_t warn_1035; isc_boolean_t age_ttl; + isc_boolean_t seen_include; isc_uint32_t ttl; isc_uint32_t default_ttl; dns_rdataclass_t zclass; @@ -388,6 +389,7 @@ loadctx_create(isc_mem_t *mctx, isc_boolean_t age_ttl, dns_name_t *top, ctx->default_ttl = 0; ctx->warn_1035 = ISC_TRUE; /* XXX Argument? */ ctx->age_ttl = age_ttl; + ctx->seen_include = ISC_FALSE; ctx->zclass = zclass; dns_fixedname_init(&ctx->fixed_top); @@ -754,6 +756,7 @@ load(dns_loadctx_t **ctxp) { CTX_COPYVAR(ctx, *ctxp, ttl); CTX_COPYVAR(ctx, *ctxp, default_ttl); CTX_COPYVAR(ctx, *ctxp, warn_1035); + CTX_COPYVAR(ctx, *ctxp, seen_include); dns_loadctx_detach(&ctx); ctx = *ctxp; continue; @@ -1372,7 +1375,8 @@ load(dns_loadctx_t **ctxp) { if (!done) { INSIST(ctx->done != NULL && ctx->task != NULL); result = DNS_R_CONTINUE; - } + } else if (result == ISC_R_SUCCESS && ctx->seen_include) + result = DNS_R_SEENINCLUDE; goto cleanup; log_and_cleanup: @@ -1427,6 +1431,8 @@ pushfile(const char *master_file, dns_name_t *origin, dns_loadctx_t **ctxp) { ctx = *ctxp; REQUIRE(DNS_LCTX_VALID(ctx)); + ctx->seen_include = ISC_TRUE; + result = loadctx_create(ctx->mctx, ctx->age_ttl, ctx->top, ctx->zclass, origin, ctx->callbacks, ctx->task, ctx->done, ctx->done_arg, @@ -1454,6 +1460,7 @@ pushfile(const char *master_file, dns_name_t *origin, dns_loadctx_t **ctxp) { CTX_COPYVAR(ctx, new, ttl); CTX_COPYVAR(ctx, new, default_ttl); CTX_COPYVAR(ctx, new, warn_1035); + CTX_COPYVAR(ctx, new, seen_include); result = isc_lex_openfile(new->lex, master_file); if (result != ISC_R_SUCCESS) diff --git a/lib/dns/result.c b/lib/dns/result.c index c1fc0974432..94a3c14e4c5 100644 --- a/lib/dns/result.c +++ b/lib/dns/result.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: result.c,v 1.74 2000/10/16 04:08:11 marka Exp $ */ +/* $Id: result.c,v 1.75 2000/10/17 07:22:31 marka Exp $ */ #include @@ -104,7 +104,8 @@ static const char *text[DNS_R_NRESULTS] = { "recoverable error occurred", /* 63 DNS_R_RECOVERABLE */ "unknown opt attribute record", /* 64 DNS_R_UNKNOWNOPT */ - "unexpected message id" /* 65 DNS_R_UNEXPECTEDID */ + "unexpected message id", /* 65 DNS_R_UNEXPECTEDID */ + "seen include file" /* 66 DNS_R_SEENINCLUDE */ }; static const char *rcode_text[DNS_R_NRCODERESULTS] = { diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index e9d1f10bc63..8e62069a939 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rootns.c,v 1.15 2000/08/01 01:22:53 tale Exp $ */ +/* $Id: rootns.c,v 1.16 2000/10/17 07:22:32 marka Exp $ */ #include @@ -26,6 +26,7 @@ #include #include #include +#include #include static char root_ns[] = @@ -108,9 +109,9 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, } else result = ISC_R_NOTFOUND; eresult = dns_db_endload(db, &callbacks.add_private); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE) result = eresult; - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) goto db_detach; *target = db; diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 481774124b8..d4981e3987e 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.235 2000/10/16 22:26:25 mws Exp $ */ +/* $Id: zone.c,v 1.236 2000/10/17 07:22:34 marka Exp $ */ #include @@ -195,7 +195,7 @@ struct dns_zone { #define DNS_ZONEFLG_NEEDDUMP 0x00000002U /* zone need consolidation */ #define DNS_ZONEFLG_USEVC 0x00000004U /* use tcp for refresh query */ #define DNS_ZONEFLG_DUMPING 0x00000008U /* a dump is in progress */ -/* #define DNS_ZONEFLG_UNUSED 0x00000010U */ /* unused */ +#define DNS_ZONEFLG_HASINCLUDE 0x00000010U /* $INCLUDE in zone file */ #define DNS_ZONEFLG_LOADED 0x00000020U /* database has loaded */ #define DNS_ZONEFLG_EXITING 0x00000040U /* zone is being destroyed */ #define DNS_ZONEFLG_EXPIRED 0x00000080U /* zone has expired */ @@ -824,13 +824,17 @@ dns_zone_load(dns_zone_t *zone) { * than the last time the zone was loaded. If the zone has not * been loaded yet, zone->loadtime will be the epoch. */ - result = isc_file_getmodtime(zone->dbname, &filetime); - if (result == ISC_R_SUCCESS && ! isc_time_isepoch(&zone->loadtime) && - isc_time_compare(&filetime, &zone->loadtime) < 0) { - zone_log(zone, me, ISC_LOG_DEBUG(1), - "skipping: database file older than last load"); - result = ISC_R_SUCCESS; - goto cleanup; + if (!DNS_ZONEFLG_HASINCLUDE) { + result = isc_file_getmodtime(zone->dbname, &filetime); + if (result == ISC_R_SUCCESS && + !isc_time_isepoch(&zone->loadtime) && + isc_time_compare(&filetime, &zone->loadtime) < 0) { + zone_log(zone, me, ISC_LOG_DEBUG(1), + "skipping: database file older" + " than last load"); + result = ISC_R_SUCCESS; + goto cleanup; + } } /* @@ -891,7 +895,8 @@ zone_gotreadhandle(isc_task_t *task, isc_event_t *event) { load->zone->rdclass, ISC_FALSE, &load->callbacks, task, zone_loaddone, load, load->zone->mctx); - if (result != ISC_R_SUCCESS && result != DNS_R_CONTINUE) + if (result != ISC_R_SUCCESS && result != DNS_R_CONTINUE && + result != DNS_R_SEENINCLUDE) goto fail; return; @@ -968,7 +973,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, * indicates that the "permanent" form does not exist. * XXX better error feedback to log. */ - if (result != ISC_R_SUCCESS) { + if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) { if (zone->type == dns_zone_slave || zone->type == dns_zone_stub) { if (result == ISC_R_FILENOTFOUND) @@ -993,6 +998,10 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, zone_log(zone, me, ISC_LOG_INFO, "loaded"); + if (result == DNS_R_SEENINCLUDE) + zone->flags |= DNS_ZONEFLG_HASINCLUDE; + else + zone->flags &= ~DNS_ZONEFLG_HASINCLUDE; /* * Apply update log, if any. */ @@ -4445,7 +4454,7 @@ zone_loaddone(void *arg, isc_result_t result) { DNS_ENTER; tresult = dns_db_endload(load->db, &load->callbacks.add_private); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE) result = tresult; LOCK(&load->zone->lock); diff --git a/lib/dns/zoneconf.c b/lib/dns/zoneconf.c index d6f9fd57aee..e9e2fea6555 100644 --- a/lib/dns/zoneconf.c +++ b/lib/dns/zoneconf.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zoneconf.c,v 1.62 2000/10/13 23:21:16 bwelling Exp $ */ +/* $Id: zoneconf.c,v 1.63 2000/10/17 07:22:35 marka Exp $ */ #include @@ -239,12 +239,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview, dns_zone_setqueryacl, dns_zone_clearqueryacl)); - result = dns_c_zone_getdialup(czone, &boolean); - if (result != ISC_R_SUCCESS) - result = dns_c_ctx_getdialup(cctx, &boolean); - if (result != ISC_R_SUCCESS) - boolean = ISC_FALSE; - dns_zone_setoption(zone, DNS_ZONEOPT_DIALUP, boolean); + if (czone->ztype != dns_c_zone_hint) { + result = dns_c_zone_getdialup(czone, &boolean); + if (result != ISC_R_SUCCESS) + result = dns_c_ctx_getdialup(cctx, &boolean); + if (result != ISC_R_SUCCESS) + boolean = ISC_FALSE; + dns_zone_setoption(zone, DNS_ZONEOPT_DIALUP, boolean); + } #ifndef NOMINUM_PUBLIC if (czone->ztype != dns_c_zone_stub) { diff --git a/lib/tests/t_api.c b/lib/tests/t_api.c index 0f6d6cff6bf..6ba3571b4be 100644 --- a/lib/tests/t_api.c +++ b/lib/tests/t_api.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_api.c,v 1.42 2000/08/01 01:33:14 tale Exp $ */ +/* $Id: t_api.c,v 1.43 2000/10/17 07:22:39 marka Exp $ */ #include @@ -621,6 +621,7 @@ struct dns_errormap { { DNS_R_BADDB, "DNS_R_BADDB" }, { DNS_R_ZONECUT, "DNS_R_ZONECUT" }, { DNS_R_NOTZONETOP, "DNS_R_NOTZONETOP" }, + { DNS_R_SEENINCLUDE, "DNS_R_SEENINCLUDE" }, { (isc_result_t)0, NULL } };