Commit 3a554a44 authored by Evan Hunt's avatar Evan Hunt
Browse files

[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]
parent 96125490
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]
......
......@@ -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);
}
......
......@@ -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
......
......@@ -390,7 +390,12 @@
<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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment