Re: [Freeipa-devel] [PATCH 0339-0363] Implement meta-database

2015-05-25 Thread Petr Spacek
On 22.5.2015 11:10, Tomas Hozza wrote:
> On 05/15/2015 11:37 AM, Petr Spacek wrote:
>> Hello,
>>
>> this patch set adds meta-database which is one of prerequisites for other 
>> work.
>>
>> These changes should not be user-visible. You might compile the plugin with
>> CFLAGS="-DMETADB_DEBUG" and check contect of /tmp/metadb.db after BIND 
>> shutdown.
>>
>> Please see
>> https://fedorahosted.org/bind-dyndb-ldap/ticket/151
>> https://fedorahosted.org/bind-dyndb-ldap/wiki/Design/MetaDB
>> for further information and let me know if you can help you somehow.
>>
> 
> In Patch 351 Rename ldap_entry_create() to ldap_entry_parse(), you should
> rename the functions also in documentation:
> https://github.com/pspacek/bind-dyndb-ldap/blob/4fb7bd42609c2b6a4ffbdf6f3a1e58e00d84fa1e/src/ldap_entry.c#L111
> https://github.com/pspacek/bind-dyndb-ldap/blob/4fb7bd42609c2b6a4ffbdf6f3a1e58e00d84fa1e/src/ldap_entry.h#L101
> 
> Other than that, it looks good.
> 
> I did no functional testing... It compiled, functional testing done by others.
> 
> ACK

Thank you!

Pushed to master:

aaae746022d82b2b08944580f1ab4add7c980d59 Move SOA serial update functions to
zone.c.
068538eacfe7b59e86d6712f83860584fa167787 Add LDAP UUID -> meta-database name
mapping function.
35e79d6794ddf7a3a3472cfde07d983402be0f65 Add basic infratructure for generic
meta-database.
9af629f8b1ccae72aa052744d4ba964d55778913 Add static (compile-time) assert macro.
01ab6db5d0b002f4848446678930a3280742d211 Add basic infratructure for LDAP
meta-database.
ed82a73cbf9f087737073455d5e42c1cecbd4d11 Add functions for populating LDAP
meta-database.
ffcc971fafbf50a0d65c8703e62584e3814064e3 Add meta-LDAP database to LDAP 
instance.
dddb69ddbecec1b28109cc6d552a1643d6410c27 Add LDAP UUID to LDAP entry structure.
b0b0fb542ed42d40e0ba3f8bae34f7fe9aa0a633 Store object class, generation
number, and DNS names into meta-LDAP DB.
472c1f2f739a793ea90044c9c35b32cae58d27d0 Move typedefs to types.h to avoid
cross-include problems.
316ca66683d94345eb7db99499be7e58dc8f06ec Add functions for reading from
generic meta-database.
e64dea627ff965149ca5dc2f5ed29c4307e229c4 Add functions for reading from
meta-LDAP database.
980d00c05d749d5a87ebf3b45e9ed222ac729626 Use information from metaDB for LDAP
object deletion.
808647cb1b35a4d8dbfe79b0c238509342780e36 Rename ldap_entry_create() to
ldap_entry_parse().
f83d99b6cdec9f89f624163996425f8c5eb9d018 Replace ldap_entry_parseclass() by
LDAP entry struct member variable.
7e79bd6e90541131a21dc2a4784cd58abc7423e8 Add pre-parsed DNS names to LDAP
entry structure.
0aa700bae38a5c653bb048b032cc785235591002 Adapt update_record() to use
pre-parsed DNS names in LDAP entry.
32b5764969c64eac9c1783098b35025e99ff Adapt ldap_parse_fwd_zoneentry() to
use pre-parsed DNS names in LDAP entry.
f1ca7432fe363a7175a9aa030ba3d9177863b0e0 Adapt update_zone() to use pre-parsed
DNS names in LDAP entry.
9f64fe6f1d0860a201f6331b7996f76fcaf054fd Adapt ldap_parse_master_zoneentry()
to use pre-parsed DNS names in LDAP entry.
5a203a3ecc49a4bbb6cd32fb2dc669c701c04030 Adapt ldap_sync_search_entry() to use
pre-parsed DNS names in LDAP entry.
414f84d77372ef7d748d33047af0ea60d2282fe9 Adapt syncrepl_update() to use
pre-parsed DNS names and metadata in LDAP entry.
a6513c44d5576f94485630d5a0273c49f5c6c66e Add function for node deletion from
generic meta-database.
a14e1c4044cf6df5f4fc3198c119f877ddd37fc3 Add ability to open existing metaDB
node for writing.
b1a7bbab23e7b8669bb468094fe8faff104ebdd8 Add function for node deletion to
meta-LDAP database API.
d6071339f25e082373cf440f5c81a980e9459a64 Delete metadata about objects deleted
from LDAP.
fff69de438108311c644a61dcf09dc3e367af23c Fix comments regarding
ldap_entry_create().

-- 
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 0339-0363] Implement meta-database

2015-05-22 Thread Tomas Hozza
On 05/15/2015 11:37 AM, Petr Spacek wrote:
> Hello,
>
> this patch set adds meta-database which is one of prerequisites for other 
> work.
>
> These changes should not be user-visible. You might compile the plugin with
> CFLAGS="-DMETADB_DEBUG" and check contect of /tmp/metadb.db after BIND 
> shutdown.
>
> Please see
> https://fedorahosted.org/bind-dyndb-ldap/ticket/151
> https://fedorahosted.org/bind-dyndb-ldap/wiki/Design/MetaDB
> for further information and let me know if you can help you somehow.
>

In Patch 351 Rename ldap_entry_create() to ldap_entry_parse(), you should
rename the functions also in documentation:
https://github.com/pspacek/bind-dyndb-ldap/blob/4fb7bd42609c2b6a4ffbdf6f3a1e58e00d84fa1e/src/ldap_entry.c#L111
https://github.com/pspacek/bind-dyndb-ldap/blob/4fb7bd42609c2b6a4ffbdf6f3a1e58e00d84fa1e/src/ldap_entry.h#L101

Other than that, it looks good.

I did no functional testing... It compiled, functional testing done by others.

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


[Freeipa-devel] [PATCH 0339-0363] Implement meta-database

2015-05-15 Thread Petr Spacek
Hello,

this patch set adds meta-database which is one of prerequisites for other work.

These changes should not be user-visible. You might compile the plugin with
CFLAGS="-DMETADB_DEBUG" and check contect of /tmp/metadb.db after BIND shutdown.

Please see
https://fedorahosted.org/bind-dyndb-ldap/ticket/151
https://fedorahosted.org/bind-dyndb-ldap/wiki/Design/MetaDB
for further information and let me know if you can help you somehow.

-- 
Petr^2 Spacek
From cb7f1aef90d356b195ddae46e3841627234e9208 Mon Sep 17 00:00:00 2001
From: Petr Spacek 
Date: Wed, 29 Apr 2015 11:13:41 +0200
Subject: [PATCH] Add LDAP UUID -> meta-database name mapping function.

https://fedorahosted.org/bind-dyndb-ldap/ticket/151
---
 configure.ac|  2 ++
 src/Makefile.am |  2 ++
 src/mldap.c | 68 +
 src/mldap.h | 11 ++
 4 files changed, 83 insertions(+)
 create mode 100644 src/mldap.c
 create mode 100644 src/mldap.h

diff --git a/configure.ac b/configure.ac
index 9026f6d70fb008813681ab3f3eb51e9e2fec7be0..d7e64772e43a743d75d1b63b05fabe45acefb12d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,8 @@ AC_CHECK_LIB([ldap], [ldap_initialize], [],
 	AC_MSG_ERROR([Install OpenLDAP development files]))
 AC_CHECK_LIB([krb5], [krb5_cc_initialize], [],
 	AC_MSG_ERROR([Install Kerberos 5 development files]))
+AC_CHECK_LIB([uuid], [uuid_unparse], [],
+	AC_MSG_ERROR([Install UUID library development files]))
 
 # Check version of libdns
 AC_MSG_CHECKING([libdns version])
diff --git a/src/Makefile.am b/src/Makefile.am
index 73aa8a3afa1bea0e63a0ac04ca13f58e4ad512cf..68ddba87582e0e590e51ad05782d18a8fdcfbcd0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,7 @@ HDRS =\
 	ldap_helper.h		\
 	lock.h			\
 	log.h			\
+	mldap.h			\
 	rbt_helper.h		\
 	rdlist.h		\
 	semaphore.h		\
@@ -38,6 +39,7 @@ ldap_la_SOURCES =		\
 	ldap_helper.c		\
 	lock.c			\
 	log.c			\
+	mldap.c			\
 	rbt_helper.c		\
 	rdlist.c		\
 	semaphore.c		\
diff --git a/src/mldap.c b/src/mldap.c
new file mode 100644
index ..0b2d0db43624131fc569b05e1492fbc6a7f68c30
--- /dev/null
+++ b/src/mldap.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2015  bind-dyndb-ldap authors; see COPYING for license
+ *
+ * Meta-database for LDAP-specific information which are not represented in
+ * DNS data.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "mldap.h"
+#include "util.h"
+
+/* name "ldap.uuid." */
+static unsigned char uuid_rootname_ndata[]
+	= { 4, 'u', 'u', 'i', 'd', 4, 'l', 'd', 'a', 'p', 0 };
+static unsigned char uuid_rootname_offsets[] = { 0, 5, 10 };
+static dns_name_t uuid_rootname =
+{
+	DNS_NAME_MAGIC,
+	uuid_rootname_ndata,
+	sizeof(uuid_rootname_ndata),
+	sizeof(uuid_rootname_offsets),
+	DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE,
+	uuid_rootname_offsets,
+	NULL,
+	{ (void *)-1, (void *)-1 },
+	{ NULL, NULL }
+};
+
+/**
+ * Convert UUID to "01234567-89ab-cdef-0123-456789abcdef.uuid.ldap." DNS name.
+ *
+ * @param[in]  beruuid
+ * @param[out] nameuuid
+ */
+void
+ldap_uuid_to_mname(struct berval *beruuid, dns_name_t *nameuuid) {
+	/* UUID string representation according to RFC 4122 section 3 */
+	char label_buf[sizeof("01234567-89ab-cdef-0123-456789abcdef") + 1];
+	/* uncompressed label format, length 36 octets; RFC 1034 section 3.1 */
+	label_buf[0] = 36;
+
+	isc_region_t label_reg;
+	label_reg.base = (unsigned char *)label_buf;
+	label_reg.length = sizeof(label_buf) - 1; /* omit final \0 */
+
+	dns_name_t relative_name;
+	DNS_NAME_INIT(&relative_name, NULL);
+
+	/* RFC 4530 section 2.1 format = 16 octets is required */
+	REQUIRE(beruuid != NULL && beruuid->bv_len == 16);
+
+	/* fill-in string representation into label buffer */
+	uuid_unparse((*(const uuid_t *) beruuid->bv_val), label_buf + 1);
+	dns_name_fromregion(&relative_name, &label_reg);
+
+	INSIST(dns_name_concatenate(&relative_name, &uuid_rootname,
+nameuuid, NULL) == ISC_R_SUCCESS);
+
+	return;
+}
diff --git a/src/mldap.h b/src/mldap.h
new file mode 100644
index ..dcf2556326ccea5037b32e71ab5da216f0f44ba4
--- /dev/null
+++ b/src/mldap.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2015  bind-dyndb-ldap authors; see COPYING for license
+ */
+
+#ifndef SRC_MLDAP_H_
+#define SRC_MLDAP_H_
+
+void
+ldap_uuid_to_mname(struct berval *beruuid, dns_name_t *nameuuid);
+
+#endif /* SRC_MLDAP_H_ */
-- 
2.1.0

From 7c556a58ff4fb919c089f3f65ad2ed8d415a1fa0 Mon Sep 17 00:00:00 2001
From: Petr Spacek 
Date: Tue, 12 May 2015 13:04:41 +0200
Subject: [PATCH] Add basic infratructure for generic meta-database.

https://fedorahosted.org/bind-dyndb-ldap/ticket/151
---
 src/Makefile.am |   2 +
 src/metadb.c| 256 
 src/metadb.h|  52 
 3 files changed, 310 insertions(+)
 create mode 100644 src/metadb.c
 create mode 100644 src/metadb.h

diff --git a/src/Makefile.a