]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] fix lmdb delzone
authorEvan Hunt <each@isc.org>
Thu, 4 May 2017 19:32:32 +0000 (12:32 -0700)
committerEvan Hunt <each@isc.org>
Thu, 4 May 2017 19:32:32 +0000 (12:32 -0700)
4616. [bug] When using LMDB, zones deleted using "rndc delzone"
were not correctly removed from the new-zone
database. [RT #45185]

CHANGES
bin/named/server.c
bin/tests/system/addzone/tests.sh
doc/arm/notes.xml

diff --git a/CHANGES b/CHANGES
index 21ef323a236737c90b62248bdeca58f30b6affb8..0ac26f68a8945b6f7961864ce05a4348b4a222a6 100644 (file)
--- 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]
index f8467ffa5fd37d3e1a9d7a2083bd1764fd9da318..34b03ee0a7be366c689fb00498ffbc8d0a42a90c 100644 (file)
@@ -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);
 }
index 765408a4e09e4834760634448c1bad0f3617992a..b5950bc27eed76d82b09b958a0fe9256435d8115 100755 (executable)
@@ -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
index 20c2453c82eda77d5d64c55a2af06c0599e3d559..3ca3d16d2e8bdfcac7818d4740346de9ceb0aa05 100644 (file)
     <itemizedlist>
       <listitem>
        <para>
-         None.
+         Due to some incorrectly deleted code, when BIND was
+         built with LMDB, zones that were deleted via
+         <command>rndc delzone</command> 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]
        </para>
       </listitem>
     </itemizedlist>