Re: [Freeipa-devel] [PATCH 0368-0371] Support LDAP MODRDN for ordinary DNS records

2015-05-26 Thread Tomas Hozza
On 05/20/2015 09:06 AM, Petr Spacek wrote:
 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!
 

I did formal review. Everything looks OK.

ACK

Regards,
-- 
Tomas Hozza
Software Engineer - EMEA ENG Developer Experience

PGP: 1D9F3C2D
Red Hat Inc.   http://cz.redhat.com

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 0368-0371] Support LDAP MODRDN for ordinary DNS records

2015-05-26 Thread Petr Spacek
On 26.5.2015 10:17, Tomas Hozza wrote:
 On 05/20/2015 09:06 AM, Petr Spacek wrote:
 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!

 
 I did formal review. Everything looks OK.
 
 ACK

Thank you very much!

Pushed to master:

9f4a95a3f36ce98e3b51f894090b521e4c444c38 Move SOA serial update functions to
zone.c.
37236dd1a4fe20b3e7254d12bb03498e5174e161 Add LDAP UUID - meta-database name
mapping function.
9ccc78af80661403a7c13df41d77cc8dd5658273 Store object class, generation
number, and DNS names into meta-LDAP DB.
ea561ba7e4af91eeef2f56834e32e3581d8e4123 Support LDAP MODRDN for ordinary DNS
records.
a1f960e1edd4c6317d81e48a9b57f9c87c581e22 Add memory context to ldap_entry_t.
fd7ad464d072a2abd7805a52d3bcd0e5b4f0fa9e Remove dangling declarations for
ldap_entrylist_*.
eb599ae5b3b7a3f86237f60830357bd53deab012 Remove dependency on entry-dn to
avoid problems with reconstructed entries.

-- 
Petr^2 Spacek

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 0368-0371] Support LDAP MODRDN for ordinary DNS records

2015-05-21 Thread Matus Honek
Hello,

patches seem to work all right. Thus ACK.

Matúš Honěk


- Original Message -
From: Petr Spacek pspa...@redhat.com
To: tho...@redhat.com, Matus Honek mho...@redhat.com
Cc: freeipa-devel@redhat.com
Sent: Wednesday, May 20, 2015 9:06:47 AM
Subject: [PATCH 0368-0371] Support LDAP MODRDN for ordinary DNS records

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

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

[Freeipa-devel] [PATCH 0368-0371] Support LDAP MODRDN for ordinary DNS records

2015-05-20 Thread Petr Spacek
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;