Cluster Project branch, master, updated. cluster-2.99.05-29-gad87670

ccaulfield@sourceware.org ccaulfield@sourceware.org
Fri Jun 27 12:55:00 GMT 2008


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=ad8767058241f405583b446ee9f86a61fa1be273

The branch, master has been updated
       via  ad8767058241f405583b446ee9f86a61fa1be273 (commit)
      from  3dc7fc16ed36088e3fc33db82dd485f2c27c4bf2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ad8767058241f405583b446ee9f86a61fa1be273
Author: Christine Caulfield <ccaulfie@redhat.com>
Date:   Fri Jun 27 13:54:14 2008 +0100

    [CONFIG] Improve LDAP error reporting
    
    and tidy up the include list too.
    
    Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>

-----------------------------------------------------------------------

Summary of changes:
 config/plugins/ldap/configldap.c |   45 +++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/config/plugins/ldap/configldap.c b/config/plugins/ldap/configldap.c
index 91edab8..d378fbf 100644
--- a/config/plugins/ldap/configldap.c
+++ b/config/plugins/ldap/configldap.c
@@ -9,13 +9,10 @@
 **
 *******************************************************************************
 ******************************************************************************/
-#include <stdio.h>
+#include <sys/types.h>
 #include <stdlib.h>
-#include <stdint.h>
 #include <string.h>
 #include <errno.h>
-#include <netinet/in.h>
-#include <stdio.h>
 
 // CC: temp until I tame SASL ... is this necessary?
 #define LDAP_DEPRECATED 1
@@ -23,21 +20,20 @@
 
 /* openais headers */
 #include <openais/service/objdb.h>
-#include <openais/service/swab.h>
-#include <openais/totem/totemip.h>
-#include <openais/totem/totempg.h>
-#include <openais/totem/aispoll.h>
-#include <openais/service/service.h>
 #include <openais/service/config.h>
 #include <openais/lcr/lcr_comp.h>
-#include <openais/service/swab.h>
 
+/* These are defaults. they can be overridden with environment variables
+ *  LDAP_URL & LDAP_BASEDN
+ */
 #define DEFAULT_LDAP_URL "ldap:///"
 #define DEFAULT_LDAP_BASEDN "dc=chrissie,dc=net"
 
 static int ldap_readconfig(struct objdb_iface_ver0 *objdb, char **error_string);
-static int init_config(struct objdb_iface_ver0 *objdb, char *error_string);
+static int init_config(struct objdb_iface_ver0 *objdb);
 static char error_reason[1024];
+static char *ldap_url = DEFAULT_LDAP_URL;
+static char *ldap_basedn = DEFAULT_LDAP_BASEDN;
 
 /*
  * Exports the interface for the service
@@ -78,7 +74,7 @@ static int ldap_readconfig(struct objdb_iface_ver0 *objdb, char **error_string)
 	int ret;
 
 	/* Read config tree from LDAP */
-	if (!(ret = init_config(objdb, error_reason)))
+	if (!(ret = init_config(objdb)))
 	    sprintf(error_reason, "%s", "Successfully read config from LDAP\n");
 
         *error_string = error_reason;
@@ -86,10 +82,6 @@ static int ldap_readconfig(struct objdb_iface_ver0 *objdb, char **error_string)
 	return ret;
 }
 
-/* Specify the search criteria here. */
-static char *ldap_url = DEFAULT_LDAP_URL;
-static char *ldap_basedn = DEFAULT_LDAP_BASEDN;
-
 /*
  * Convert hyphens to underscores in all attribute names
  */
@@ -176,8 +168,11 @@ static int read_config_for(LDAP *ld, struct objdb_iface_ver0 *objdb, unsigned in
 	rc = ldap_search_ext_s(ld, search_dn, LDAP_SCOPE_SUBTREE, "(objectClass=*)", NULL, 0,
 			       NULL, NULL, NULL, 0, &result);
 	if (rc != LDAP_SUCCESS) {
-		fprintf(stderr, "ldap_search_ext_s: %s\n", ldap_err2string(rc));
-		return 1;
+		sprintf(error_reason, "ldap_search_ext_s: %s\n", ldap_err2string(rc));
+		if (rc == LDAP_NO_SUCH_OBJECT)
+			return 0;
+		else
+			return -1;
 	}
 	for (e = ldap_first_entry(ld, result); e != NULL;
 	     e = ldap_next_entry(ld, e)) {
@@ -188,7 +183,7 @@ static int read_config_for(LDAP *ld, struct objdb_iface_ver0 *objdb, unsigned in
 
 			/* Make it parsable so we can discern the hierarchy */
 			if (ldap_str2dn(dn, &parsed_dn, LDAP_DN_PEDANTIC)) {
-				strcpy(error_reason, strerror(errno));
+				sprintf(error_reason, "ldap_str2dn failed: %s\n", ldap_err2string(rc));
 				return -1;
 			}
 
@@ -265,7 +260,7 @@ static int read_config_for(LDAP *ld, struct objdb_iface_ver0 *objdb, unsigned in
 }
 
 /* The real work starts here */
-static int init_config(struct objdb_iface_ver0 *objdb, char *error_string)
+static int init_config(struct objdb_iface_ver0 *objdb)
 {
 	LDAP *ld;
 	int version, rc;
@@ -277,7 +272,7 @@ static int init_config(struct objdb_iface_ver0 *objdb, char *error_string)
 
 	/* Connect to the LDAP server */
 	if (ldap_initialize(&ld, ldap_url)) {
-		perror("ldap_initialize");
+		sprintf(error_reason, "ldap_simple_bind failed: %s\n", strerror(errno));
 		return -1;
 	}
 	version = LDAP_VERSION3;
@@ -288,13 +283,15 @@ static int init_config(struct objdb_iface_ver0 *objdb, char *error_string)
 	 */
 	rc = ldap_simple_bind_s(ld, getenv("LDAP_BINDDN"), getenv("LDAP_BINDPWD"));
 	if (rc != LDAP_SUCCESS) {
-		fprintf(stderr, "ldap_simple_bind_s: %s\n", ldap_err2string(rc));
+		sprintf(error_reason, "ldap_simple_bind failed: %s\n", ldap_err2string(rc));
 		return -1;
 	}
 
 	rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "cluster", "cn=cluster", 1);
-	rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "totem", "cn=totem,cn=cluster", 1);
-	rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "logging", "cn=logging,cn=cluster", 1);
+	if (!rc)
+		rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "totem", "cn=totem,cn=cluster", 1);
+	if (!rc)
+		rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "logging", "cn=logging,cn=cluster", 1);
 
 	ldap_unbind(ld);
 	return 0;


hooks/post-receive
--
Cluster Project



More information about the Cluster-cvs mailing list