Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pspacek committed Aug 12, 2016
1 parent 9ae1320 commit b409762
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
26 changes: 10 additions & 16 deletions src/ldap_helper.c
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -2173,8 +2169,7 @@ ldap_parse_master_zoneentry(ldap_entry_t * const entry, dns_db_t * const olddb,
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));
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/ldap_helper.h
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion src/zone_register.c
Expand Up @@ -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);
Expand Down

0 comments on commit b409762

Please sign in to comment.