Blob Blame History Raw
From 3b44a3d73a0d1980b43e9022d9249c4c19ba56d2 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspacek@redhat.com>
Date: Thu, 11 Aug 2016 12:40:39 +0200
Subject: [PATCH] Remove preserve_forwarding parameter from
 ldap_delete_zone2().

The parameter was TRUE only when called from zone_security_change().
zone_security_change() is calling ldap_delete_zone2() in exclusive mode
anyway so there is no need to optimize this.

Removal of the parameter will make easier to centralize forwarding
configuration on one place.

https://fedorahosted.org/bind-dyndb-ldap/ticket/167
---
 src/ldap_helper.c   | 26 ++++++++++----------------
 src/ldap_helper.h   |  3 +--
 src/zone_register.c |  2 +-
 3 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index 12a743b095ba400373cb87653d26af82cc95c2ea..696a755fb8001993ff1a16fa034a9286cbb5ad89 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -1285,8 +1285,7 @@ configure_zone_ssutable(dns_zone_t *zone, const char *update_str)
 
 /* Delete zone by dns zone name */
 isc_result_t
-ldap_delete_zone2(ldap_instance_t *inst, dns_name_t *name, isc_boolean_t lock,
-		  isc_boolean_t preserve_forwarding)
+ldap_delete_zone2(ldap_instance_t *inst, dns_name_t *name, isc_boolean_t lock)
 {
 	isc_result_t result;
 	isc_result_t isforward = ISC_R_NOTFOUND;
@@ -1302,13 +1301,11 @@ ldap_delete_zone2(ldap_instance_t *inst, dns_name_t *name, isc_boolean_t lock,
 	if (lock)
 		run_exclusive_enter(inst, &lock_state);
 
-	if (!preserve_forwarding) {
-		CHECK(fwd_delete_table(inst->view, name, "zone",
-				       zone_name_char));
-		isforward = fwdr_zone_ispresent(inst->fwd_register, name);
-		if (isforward == ISC_R_SUCCESS)
-			CHECK(fwdr_del_zone(inst->fwd_register, name));
-	}
+	CHECK(fwd_delete_table(inst->view, name, "zone",
+			       zone_name_char));
+	isforward = fwdr_zone_ispresent(inst->fwd_register, name);
+	if (isforward == ISC_R_SUCCESS)
+		CHECK(fwdr_del_zone(inst->fwd_register, name));
 
 	result = zr_get_zone_ptr(inst->zone_register, name, &raw, &secure);
 	if (result == ISC_R_NOTFOUND || result == DNS_R_PARTIALMATCH) {
@@ -1487,8 +1484,7 @@ ldap_parse_fwd_zoneentry(ldap_entry_t *entry, ldap_instance_t *inst)
 	if (HEAD(values) != NULL &&
 	    strcasecmp(HEAD(values)->value, "TRUE") != 0) {
 		/* Zone is not active */
-		result = ldap_delete_zone2(inst, &entry->fqdn,
-					   ISC_TRUE, ISC_FALSE);
+		result = ldap_delete_zone2(inst, &entry->fqdn, ISC_TRUE);
 		goto cleanup;
 	}
 
@@ -1990,7 +1986,7 @@ zone_security_change(ldap_entry_t * const entry, dns_name_t * const name,
 	 * in period where old zone was deleted but the new zone was not
 	 * created yet. */
 	run_exclusive_enter(inst, &lock_state);
-	CHECK(ldap_delete_zone2(inst, name, ISC_FALSE, ISC_TRUE));
+	CHECK(ldap_delete_zone2(inst, name, ISC_FALSE));
 	CHECK(ldap_parse_master_zoneentry(entry, olddb, inst, task));
 
 cleanup:
@@ -2173,8 +2169,7 @@ cleanup:
 		log_error_r("%s: publishing failed, rolling back due to",
 			    ldap_entry_logname(entry));
 		/* TODO: verify this */
-		result = ldap_delete_zone2(inst, &entry->fqdn,
-					   ISC_TRUE, ISC_FALSE);
+		result = ldap_delete_zone2(inst, &entry->fqdn, ISC_TRUE);
 		if (result != ISC_R_SUCCESS)
 			log_error_r("%s: rollback failed: ",
 				    ldap_entry_logname(entry));
@@ -3671,8 +3666,7 @@ update_zone(isc_task_t *task, isc_event_t *event)
 	INSIST(task == inst->task); /* For task-exclusive mode */
 
 	if (SYNCREPL_DEL(pevent->chgtype)) {
-		CHECK(ldap_delete_zone2(inst, &entry->fqdn,
-					ISC_TRUE, ISC_FALSE));
+		CHECK(ldap_delete_zone2(inst, &entry->fqdn, ISC_TRUE));
 	} else {
 		if (entry->class & LDAP_ENTRYCLASS_MASTER)
 			CHECK(ldap_parse_master_zoneentry(entry, NULL, inst,
diff --git a/src/ldap_helper.h b/src/ldap_helper.h
index 0368ec7343ef7b16e7afb25b17f3067bf7c09f76..a491baeb41105b9a352dbad6949c3fab008ab69b 100644
--- a/src/ldap_helper.h
+++ b/src/ldap_helper.h
@@ -46,8 +46,7 @@ new_ldap_instance(isc_mem_t *mctx, const char *db_name,
 void destroy_ldap_instance(ldap_instance_t **ldap_inst) ATTR_NONNULLS;
 
 isc_result_t
-ldap_delete_zone2(ldap_instance_t *inst, dns_name_t *name,
-		  isc_boolean_t lock, isc_boolean_t preserve_forwarding)
+ldap_delete_zone2(ldap_instance_t *inst, dns_name_t *name, isc_boolean_t lock)
 		  ATTR_NONNULLS;
 
 /* Functions for writing to LDAP. */
diff --git a/src/zone_register.c b/src/zone_register.c
index 3f8c070b3adfb0ecc5092eb1e84f3956ba3b4fb8..bde4a7c308a6a62ebe6b9123b3212a404603310a 100644
--- a/src/zone_register.c
+++ b/src/zone_register.c
@@ -163,7 +163,7 @@ zr_destroy(zone_register_t **zrp)
 		if (result == ISC_R_SUCCESS) {
 			rbt_iter_stop(&iter);
 			result = ldap_delete_zone2(zr->ldap_inst,
-						   &name, ISC_FALSE, ISC_FALSE);
+						   &name, ISC_FALSE);
 			RUNTIME_CHECK(result == ISC_R_SUCCESS);
 		}
 	} while (result == ISC_R_SUCCESS);
-- 
2.7.4