From: Evan Hunt Date: Thu, 4 May 2017 19:32:32 +0000 (-0700) Subject: [master] fix lmdb delzone X-Git-Tag: v9.12.0a1~307 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a554a444caf444b6239a7ae80d6448cad3a363e;p=thirdparty%2Fbind9.git [master] fix lmdb delzone 4616. [bug] When using LMDB, zones deleted using "rndc delzone" were not correctly removed from the new-zone database. [RT #45185] --- diff --git a/CHANGES b/CHANGES index 21ef323a236..0ac26f68a89 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4616. [bug] When using LMDB, zones deleted using "rndc delzone" + were not correctly removed from the new-zone + database. [RT #45185] + 4615. [bug] AD could be set on truncated answer with no records present in the answer and authority sections. [RT #45140] diff --git a/bin/named/server.c b/bin/named/server.c index f8467ffa5fd..34b03ee0a7b 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -12166,6 +12166,10 @@ rmzone(isc_task_t *task, isc_event_t *event) { dns_db_t *dbp = NULL; isc_boolean_t added; isc_result_t result; +#ifdef HAVE_LMDB + MDB_txn *txn = NULL; + MDB_dbi dbi; +#endif REQUIRE(dz != NULL); @@ -12185,8 +12189,28 @@ rmzone(isc_task_t *task, isc_event_t *event) { /* Remove the zone from configuration (and NZF file if applicable) */ added = dns_zone_getadded(zone); -#ifndef HAVE_LMDB if (added && cfg != NULL) { +#ifdef HAVE_LMDB + /* Make sure we can open the NZD database */ + result = nzd_open(view, 0, &txn, &dbi); + if (result != ISC_R_SUCCESS) { + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_SERVER, + ISC_LOG_ERROR, + "unable to open NZD database for '%s'", + view->new_zone_db); + } else { + result = nzd_save(&txn, dbi, zone, NULL); + } + + if (result != ISC_R_SUCCESS) { + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_SERVER, + ISC_LOG_ERROR, "unable to " + "delete zone configuration: %s", + isc_result_totext(result)); + } +#else result = delete_zoneconf(view, cfg->add_parser, cfg->nzf_config, dns_zone_getorigin(zone), @@ -12194,12 +12218,12 @@ rmzone(isc_task_t *task, isc_event_t *event) { if (result != ISC_R_SUCCESS) { isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, - ISC_LOG_WARNING, "unable to " + ISC_LOG_ERROR, "unable to " "delete zone configuration: %s", isc_result_totext(result)); } - } #endif /* HAVE_LMDB */ + } if (!added && cfg != NULL) { if (cfg->vconfig != NULL) { @@ -12218,7 +12242,7 @@ rmzone(isc_task_t *task, isc_event_t *event) { if (result != ISC_R_SUCCESS){ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, - ISC_LOG_WARNING, "unable to " + ISC_LOG_ERROR, "unable to " "delete zone configuration: %s", isc_result_totext(result)); } @@ -12278,6 +12302,10 @@ rmzone(isc_task_t *task, isc_event_t *event) { } } +#ifdef HAVE_LMDB + if (txn != NULL) + (void) nzd_close(&txn, ISC_FALSE); +#endif if (raw != NULL) dns_zone_detach(&raw); dns_zone_detach(&zone); @@ -12302,9 +12330,6 @@ ns_server_delzone(ns_server_t *server, isc_lex_t *lex, isc_buffer_t **text) { ns_dzctx_t *dz = NULL; isc_event_t *dzevent = NULL; isc_task_t *task = NULL; -#ifdef HAVE_LMDB - MDB_txn *txn = NULL; -#endif /* HAVE_LMDB */ /* Skip the command name. */ ptr = next_token(lex, text); @@ -12425,10 +12450,6 @@ ns_server_delzone(ns_server_t *server, isc_lex_t *lex, isc_buffer_t **text) { dns_zone_detach(&dz->zone); isc_mem_put(ns_g_mctx, dz, sizeof(*dz)); } -#ifdef HAVE_LMDB - if (txn != NULL) - (void) nzd_close(&txn, ISC_FALSE); -#endif /* HAVE_LMDB */ return (result); } diff --git a/bin/tests/system/addzone/tests.sh b/bin/tests/system/addzone/tests.sh index 765408a4e09..b5950bc27ee 100755 --- a/bin/tests/system/addzone/tests.sh +++ b/bin/tests/system/addzone/tests.sh @@ -119,6 +119,14 @@ n=`expr $n + 1` if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` +if [ -n "$NZD" ]; then + echo "I:checking zone is present in NZD ($n)" + ret=0 + $NZD2NZF ns2/_default.nzd | grep previous.example > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` +fi + echo "I:deleting previously added zone ($n)" ret=0 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone previous.example 2>&1 | sed 's/^/I:ns2 /' @@ -129,6 +137,18 @@ n=`expr $n + 1` if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` +if [ -n "$NZD" ]; then + echo "I:checking zone was deleted from NZD ($n)" + for i in 0 1 2 3 4 5 6 7 8 9; do + ret=0 + $NZD2NZF ns2/_default.nzd | grep previous.example > /dev/null && ret=1 + [ $ret = 0 ] && break + sleep 1 + done + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` +fi + if [ -z "$NZD" ]; then echo "I:checking NZF file now has comment ($n)" ret=0 diff --git a/doc/arm/notes.xml b/doc/arm/notes.xml index 20c2453c82e..3ca3d16d2e8 100644 --- a/doc/arm/notes.xml +++ b/doc/arm/notes.xml @@ -390,7 +390,12 @@ - None. + Due to some incorrectly deleted code, when BIND was + built with LMDB, zones that were deleted via + rndc delzone were removed from the + running server but were not removed from the new zone + database, so that deletion did not persist after a + server restart. This has been corrected. [RT #45185]