From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19897 invoked by alias); 27 Jun 2008 12:55:02 -0000 Received: (qmail 19835 invoked by uid 9452); 27 Jun 2008 12:55:01 -0000 Date: Fri, 27 Jun 2008 12:55:00 -0000 Message-ID: <20080627125500.19820.qmail@sourceware.org> From: ccaulfield@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. cluster-2.99.05-29-gad87670 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 3dc7fc16ed36088e3fc33db82dd485f2c27c4bf2 X-Git-Newrev: ad8767058241f405583b446ee9f86a61fa1be273 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q2/txt/msg00561.txt.bz2 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 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 ----------------------------------------------------------------------- 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 +#include #include -#include #include #include -#include -#include // CC: temp until I tame SASL ... is this necessary? #define LDAP_DEPRECATED 1 @@ -23,21 +20,20 @@ /* openais headers */ #include -#include -#include -#include -#include -#include #include #include -#include +/* 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