Hello,
this patchset implements support for MODRDN for ordinary records. As noted in
ticket https://fedorahosted.org/bind-dyndb-ldap/ticket/123, we agreed
yesterday that renaming zones is out of scope and seems unnecessarily complex.
This patch set depends on 'metadb' branch. It is also available from:
https://github.com/pspacek/bind-dyndb-ldap/tree/modrdn
Thank you for your time!
--
Petr^2 Spacek
From 6bcb7490416c8a1815e4a637be906bf3e8936e33 Mon Sep 17 00:00:00 2001
From: Petr Spacek pspa...@redhat.com
Date: Tue, 19 May 2015 14:38:40 +0200
Subject: [PATCH] Support LDAP MODRDN for ordinary DNS records.
Renaming of DNS zones and configuration objects is still not supported.
https://fedorahosted.org/bind-dyndb-ldap/ticket/123
---
src/ldap_helper.c | 129 +-
1 file changed, 78 insertions(+), 51 deletions(-)
diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index 8922141724c4351db9435fd73e91756d60606390..5ae774aba2c5e43c240fd9dfa639481ea7356778 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -3690,32 +3690,6 @@ update_zone(isc_task_t *task, isc_event_t *event)
CHECK(ldap_parse_fwd_zoneentry(entry, inst));
}
- /* This code is disabled because we don't have UUID-DN database yet.
- if (SYNCREPL_MODDN(pevent-chgtype)) {
- if (dn_to_dnsname(inst-mctx, pevent-prevdn, prevname, NULL)
- == ISC_R_SUCCESS) {
-CHECK(ldap_delete_zone(inst, pevent-prevdn,
- ISC_TRUE, ISC_FALSE));
- } else {
-log_debug(5, update_zone: old zone wasn't managed
- by plugin, dn '%s', pevent-prevdn);
- }
-
- // fill the cache with records from renamed zone //
- if (objclass LDAP_ENTRYCLASS_MASTER) {
-CHECK(ldap_query(inst, NULL, ldap_qresult_record, pevent-dn,
- LDAP_SCOPE_ONELEVEL, attrs_record, 0,
- (objectClass=idnsRecord)));
-
-for (entry_record = HEAD(ldap_qresult_record-ldap_entries);
- entry_record != NULL;
- entry_record = NEXT(entry_record, link)) {
-
- syncrepl_update(inst, entry_record, NULL);
-}
- }
- }
- */
cleanup:
if (inst != NULL) {
sync_concurr_limit_signal(inst-sctx);
@@ -4047,11 +4021,23 @@ cleanup:
return result;
}
+/**
+ * Create asynchronous ISC event to execute update_config()/zone()/record()
+ * in a task associated with affected DNS zone.
+ *
+ * @param[in,out] entryp (Possibly fake) LDAP entry to parse.
+ * @param[in] chgtype One of LDAP_SYNC_CAPI_ADD/MODIFY/DELETE.
+ *
+ * @pre entryp is valid LDAP entry with class, DNS names, DN, etc.
+ *
+ * @post entryp is NULL.
+ */
static isc_result_t ATTR_NONNULLS ATTR_CHECKRESULT
-syncrepl_update(ldap_instance_t *inst, ldap_entry_t *entry, int chgtype)
+syncrepl_update(ldap_instance_t *inst, ldap_entry_t **entryp, int chgtype)
{
isc_result_t result = ISC_R_SUCCESS;
ldap_syncreplevent_t *pevent = NULL;
+ ldap_entry_t *entry = NULL;
isc_event_t *wait_event = NULL;
dns_name_t *zone_name = NULL;
dns_zone_t *zone_ptr = NULL;
@@ -4062,18 +4048,19 @@ syncrepl_update(ldap_instance_t *inst, ldap_entry_t *entry, int chgtype)
isc_task_t *task = NULL;
sync_state_t sync_state;
+ REQUIRE(entryp != NULL);
+ entry = *entryp;
REQUIRE(entry-class != LDAP_ENTRYCLASS_NONE);
- log_debug(20, syncrepl change type: /*none%d,*/ add%d, del%d, mod%d, /* moddn%d, */
- /* !SYNCREPL_ANY(chgtype), */ SYNCREPL_ADD(chgtype),
- SYNCREPL_DEL(chgtype), SYNCREPL_MOD(chgtype)/*, SYNCREPL_MODDN(chgtype) */ );
+ log_debug(20, syncrepl_update change type: add%d, del%d, mod%d,
+ SYNCREPL_ADD(chgtype), SYNCREPL_DEL(chgtype),
+ SYNCREPL_MOD(chgtype));
isc_mem_attach(inst-mctx, mctx);
CHECKED_MEM_STRDUP(mctx, entry-dn, dn);
CHECKED_MEM_STRDUP(mctx, inst-db_name, dbname);
-
if (entry-class LDAP_ENTRYCLASS_MASTER)
zone_name = entry-fqdn;
else
@@ -4150,6 +4137,7 @@ syncrepl_update(ldap_instance_t *inst, ldap_entry_t *entry, int chgtype)
pevent-entry = entry;
wait_event = (isc_event_t *)pevent;
isc_task_send(task, (isc_event_t **)pevent);
+ *entryp = NULL; /* event handler will deallocate the LDAP entry */
/* Lock syncrepl queue to prevent zone, config and resource records
* from racing with each other. */
@@ -4172,7 +4160,7 @@ cleanup:
isc_mem_free(mctx, dn);
if (mctx != NULL)
isc_mem_detach(mctx);
- ldap_entry_destroy(inst-mctx, entry);
+ ldap_entry_destroy(inst-mctx, entryp);
if (task != NULL)
isc_task_detach(task);
}
@@ -4264,11 +4252,13 @@ int ldap_sync_search_entry (
ldap_sync_refresh_t phase ) {
ldap_instance_t *inst = ls-ls_private;
- ldap_entry_t *entry = NULL;
+ ldap_entry_t *old_entry = NULL;
+ ldap_entry_t *new_entry = NULL;
isc_result_t result;
metadb_node_t *node = NULL;
isc_boolean_t mldap_open = ISC_FALSE;
const char *ldap_base = NULL;
+ isc_boolean_t modrdn = ISC_FALSE;
#ifdef RBTDB_DEBUG
static unsigned int count = 0;
@@ -4281,49 +4271,86 @@ int ldap_sync_search_entry (
mldap_open = ISC_TRUE;