cluster: STABLE3 - config: fix LDAP loader

Christine Caulfield chrissie at fedoraproject.org
Mon Oct 5 09:56:31 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=2c2cb2df4119df2f7173f5091cb5e964213f1cd0
Commit:        2c2cb2df4119df2f7173f5091cb5e964213f1cd0
Parent:        e7f1d826947338a043d781b22b5b0cb67ac82f62
Author:        Christine Caulfield <ccaulfie at redhat.com>
AuthorDate:    Mon Oct 5 10:54:48 2009 +0100
Committer:     Christine Caulfield <ccaulfie at redhat.com>
CommitterDate: Mon Oct 5 10:54:48 2009 +0100

config: fix LDAP loader

The LDAP loader was broken by the change from cn=cluster to name=cluster.

The fix is slightly hacky, it simply bypasses the "name=" check on the first
LDAP entry, which is guaranteed to be "name=cluster". At least, if it isn't
then the whole configuration is badly broken anyway.

Signed-off-by: Christine Caulfield <ccaulfie at redhat.com>
---
 config/plugins/ldap/configldap.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/config/plugins/ldap/configldap.c b/config/plugins/ldap/configldap.c
index c3e8b4c..4877f61 100644
--- a/config/plugins/ldap/configldap.c
+++ b/config/plugins/ldap/configldap.c
@@ -146,10 +146,11 @@ static hdb_handle_t find_parent(struct objdb_iface_ver0 *objdb, LDAPDN dn, int s
 
 
 static int read_config_for(LDAP *ld, struct objdb_iface_ver0 *objdb, hdb_handle_t parent,
-			   const char *object, const char *sub_dn, int always_create)
+			   const char *object, const char *sub_dn)
 {
 	char search_dn[4096];
 	int rc;
+	int first_entry = 1;
 	char *dn;
 	LDAPMessage *result, *e;
 	hdb_handle_t parent_handle = OBJECT_PARENT_HANDLE;
@@ -187,12 +188,13 @@ static int read_config_for(LDAP *ld, struct objdb_iface_ver0 *objdb, hdb_handle_
 			 */
 			convert_dn_underscores(parsed_dn);
 
-			/* Create a new object if the top-level is NOT name= */
-			if (strncmp(parsed_dn[0][0][0].la_attr.bv_val, "name", 4)) {
+			/* Create a new object if the top-level is NOT name= OR we are the first "cluster" entry */
+			if (strncmp(parsed_dn[0][0][0].la_attr.bv_val, "name", 4) || first_entry) {
 				parent_handle = find_parent(objdb, parsed_dn, 0, object);
 
 				objdb->object_create(parent_handle, &object_handle, parsed_dn[0][0][0].la_value.bv_val,
 						     parsed_dn[0][0][0].la_value.bv_len);
+				first_entry = 0;
 			}
 			else {
  			        /* Remove redundant empty parent. */
@@ -282,7 +284,7 @@ static int init_config(struct objdb_iface_ver0 *objdb)
 		return -1;
 	}
 
-	rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "cluster", "name=cluster", 1);
+	rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "cluster", "name=cluster");
 
 	ldap_unbind(ld);
 	return 0;


More information about the cluster-commits mailing list