From 94124ad484d5ec774777ceba1b009e310eb5ef88 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 8 Jan 2015 19:19:12 +1100 Subject: [PATCH] 4031. [bug] named-checkconf -z failed to report a missing file with a hint zone. [RT #38294] (cherry picked from commit d1f1f13c7fc1f1515930053508f1645cfafaa478) --- CHANGES | 3 +++ bin/named/server.c | 12 ++---------- bin/tests/system/checkconf/tests.sh | 3 ++- lib/dns/rootns.c | 16 +++++++++++----- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGES b/CHANGES index 3253d0d0fd..9505da1a07 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4031. [bug] named-checkconf -z failed to report a missing file + with a hint zone. [RT #38294] + 4028. [bug] $GENERATE with a zero step was not being caught as a error. A $GENERATE with a / but no step was not being caught as a error. [RT #38262] diff --git a/bin/named/server.c b/bin/named/server.c index 8117474c32..da1af3ce25 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -3863,16 +3863,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig, if (dns_name_equal(origin, dns_rootname)) { const char *hintsfile = cfg_obj_asstring(fileobj); - result = configure_hints(view, hintsfile); - if (result != ISC_R_SUCCESS) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, - NS_LOGMODULE_SERVER, - ISC_LOG_ERROR, - "could not configure root hints " - "from '%s': %s", hintsfile, - isc_result_totext(result)); - goto cleanup; - } + CHECK(configure_hints(view, hintsfile)); + /* * Hint zones may also refer to delegation only points. */ diff --git a/bin/tests/system/checkconf/tests.sh b/bin/tests/system/checkconf/tests.sh index 480d7bde09..54bcf85894 100644 --- a/bin/tests/system/checkconf/tests.sh +++ b/bin/tests/system/checkconf/tests.sh @@ -55,7 +55,8 @@ done echo "I: checking that named-checkconf -z catches missing hint file" ret=0 -$CHECKCONF -z hint-nofile.conf > /dev/null 2>&1 && ret=1 +$CHECKCONF -z hint-nofile.conf > hint-nofile.out 2>&1 && ret=1 +grep "could not configure root hints from 'nonexistent.db': file not found" hint-nofile.out > /dev/null || ret=1 if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index a3d9bd8d60..44718ecb1f 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -211,7 +211,7 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone, rdclass, 0, NULL, &db); if (result != ISC_R_SUCCESS) - return (result); + goto failure; dns_rdatacallbacks_init(&callbacks); @@ -222,7 +222,7 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, result = dns_db_beginload(db, &callbacks.add, &callbacks.add_private); if (result != ISC_R_SUCCESS) - return (result); + goto failure; if (filename != NULL) { /* * Load the hints from the specified filename. @@ -245,7 +245,7 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, if (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE) result = eresult; if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) - goto db_detach; + goto failure; if (check_hints(db) != ISC_R_SUCCESS) isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_HINTS, ISC_LOG_WARNING, @@ -254,8 +254,14 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, *target = db; return (ISC_R_SUCCESS); - db_detach: - dns_db_detach(&db); + failure: + isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_HINTS, + ISC_LOG_ERROR, "could not configure root hints from " + "'%s': %s", (filename != NULL) ? filename : "", + isc_result_totext(result)); + + if (db != NULL) + dns_db_detach(&db); return (result); }