} else if (command_compare(command, NS_COMMAND_ADDZONE)) {
result = ns_server_add_zone(ns_g_server, command);
} else if (command_compare(command, NS_COMMAND_DELZONE)) {
- result = ns_server_del_zone(ns_g_server, command);
+ result = ns_server_del_zone(ns_g_server, command, text);
} else if (command_compare(command, NS_COMMAND_SIGNING)) {
result = ns_server_signing(ns_g_server, command, text);
} else if (command_compare(command, NS_COMMAND_ZONESTATUS)) {
return (result);
}
+static isc_boolean_t
+inuse(const char* file, isc_boolean_t first, isc_buffer_t *text) {
+#define INUSEMSG "The following files were in use and may now be removed:\n"
+
+ if (file != NULL && isc_file_exists(file) &&
+ isc_buffer_availablelength(text) >
+ strlen(file) + (first ? sizeof(INUSEMSG) : 0))
+ {
+ if (first)
+ isc__buffer_putstr(text, INUSEMSG);
+ else
+ isc_buffer_putstr(text, "\n");
+ isc__buffer_putstr(text, file);
+ return (ISC_FALSE);
+ }
+ return (first);
+}
+
/*
* Act on a "delzone" command from the command channel.
*/
isc_result_t
-ns_server_del_zone(ns_server_t *server, char *args) {
+ns_server_del_zone(ns_server_t *server, char *args, isc_buffer_t *text) {
isc_result_t result;
dns_zone_t *zone = NULL;
+ dns_zone_t *raw = NULL;
+ dns_zone_t *mayberaw;
dns_view_t *view = NULL;
dns_db_t *dbp = NULL;
const char *filename = NULL;
const char *zonename = NULL;
size_t znamelen = 0;
FILE *ifp = NULL, *ofp = NULL;
+ isc_boolean_t exclusive = ISC_FALSE;
/* Parse parameters */
CHECK(zone_from_args(server, args, NULL, &zone, &zonename, ISC_TRUE));
goto cleanup;
}
+ result = isc_task_beginexclusive(server->task);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
+ exclusive = ISC_TRUE;
+
/*
* Was this zone originally added at runtime?
* If not, we can't delete it now.
dns_zone_unload(zone);
}
+ /* Clean up stub / slave zone files */
+ dns_zone_getraw(zone, &raw);
+ mayberaw = (raw != NULL) ? raw : zone;
+ if (dns_zone_gettype(mayberaw) == dns_zone_slave ||
+ dns_zone_gettype(mayberaw) == dns_zone_stub) {
+ const char *file;
+ isc_boolean_t first;
+
+ file = dns_zone_getfile(mayberaw);
+ first = inuse(file, ISC_TRUE, text);
+
+ file = dns_zone_getjournal(mayberaw);
+ first = inuse(file, first, text);
+
+ if (zone != mayberaw) {
+ file = dns_zone_getfile(zone);
+ first = inuse(file, first, text);
+
+ file = dns_zone_getjournal(zone);
+ first = inuse(file, first, text);
+ }
+ }
+
CHECK(dns_zt_unmount(view->zonetable, zone));
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
result = ISC_R_SUCCESS;
cleanup:
+ if (exclusive)
+ isc_task_endexclusive(server->task);
if (ifp != NULL)
isc_stdio_close(ifp);
if (ofp != NULL) {
}
if (tmpname != NULL)
isc_mem_free(server->mctx, tmpname);
+ if (raw != NULL)
+ dns_zone_detach(&raw);
if (zone != NULL)
dns_zone_detach(&zone);
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
+echo "I:attempting to delete slave zone with inline signing ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone inlineslave.example 2>&1 > rndc.out2.test$n
+grep '^inlineslave.bk$' rndc.out2.test$n > /dev/null || {
+ echo "I:failed to report inlineslave.bk"; ret=1;
+}
+grep '^inlineslave.bk.signed$' rndc.out2.test$n > /dev/null || {
+ echo "I:failed to report inlineslave.bk.signed"; ret=1;
+}
+n=`expr $n + 1`
+status=`expr $status + $ret`
+
echo "I:reconfiguring server with multiple views"
rm -f ns2/named.conf
cp -f ns2/named2.conf ns2/named.conf