summaryrefslogtreecommitdiff
path: root/daemon/ldap.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-08-09 18:35:56 +0000
committerStef Walter <stef@memberwebs.com>2004-08-09 18:35:56 +0000
commit670eba73c474230e31d688e9568fcd540b4e3b39 (patch)
tree624502f0713a9c6f3b0520416134b405f150f356 /daemon/ldap.c
parentb0e50bbeb12e6247dd52dfd9e44c62f558c8a3a0 (diff)
- added request parameter to ha_message...
- combined ha_request and ha_response
Diffstat (limited to 'daemon/ldap.c')
-rw-r--r--daemon/ldap.c200
1 files changed, 100 insertions, 100 deletions
diff --git a/daemon/ldap.c b/daemon/ldap.c
index e0349fb..719ac0d 100644
--- a/daemon/ldap.c
+++ b/daemon/ldap.c
@@ -72,8 +72,8 @@ typedef struct ldap_context
ldap_context_t;
/* Forward declarations for callbacks */
-static int complete_digest(const ha_request_t* req, const char* user, unsigned char* ha1);
-static int validate_basic(const ha_request_t* req, const char* user, const char* password);
+static int complete_digest(ha_request_t* rq, const char* user, unsigned char* ha1);
+static int validate_basic(ha_request_t* rq, const char* user, const char* password);
/* The defaults for the context */
static const ldap_context_t ldap_defaults =
@@ -101,20 +101,20 @@ static const ldap_context_t ldap_defaults =
* Internal Functions
*/
-static int report_ldap(const char* msg, int code)
+static int report_ldap(const ha_request_t* rq, const char* msg, int code)
{
ASSERT(code != LDAP_SUCCESS);
switch(code)
{
case LDAP_NO_MEMORY:
- ha_messagex(LOG_CRIT, "out of memory");
+ ha_messagex(NULL, LOG_CRIT, "out of memory");
return HA_CRITERROR;
default:
if(!msg)
msg = "error";
- ha_messagex(LOG_ERR, "ldap: %s: %s", msg, ldap_err2string(code));
+ ha_messagex(rq, LOG_ERR, "%s: %s", msg, ldap_err2string(code));
return HA_FAILED;
};
}
@@ -159,49 +159,49 @@ static const char* escape_ldap(ha_buffer_t* buf, const char* str)
return ha_bufdata(buf);
}
-static const char* substitute_params(ldap_context_t* ctx, const ha_request_t* req,
+static const char* substitute_params(const ha_request_t* rq, ldap_context_t* ctx,
const char* user, const char* str)
{
const char* t;
- ASSERT(ctx && req && user && str);
+ ASSERT(ctx && rq && user && str);
/* TODO: We need to be escaping the user and realm properly */
/* This starts a new block to join */
- ha_bufcpy(req->buf, "");
+ ha_bufcpy(rq->buf, "");
while(str[0])
{
t = strchr(str, '%');
if(!t)
{
- ha_bufjoin(req->buf);
- ha_bufcpy(req->buf, str);
+ ha_bufjoin(rq->buf);
+ ha_bufcpy(rq->buf, str);
break;
}
- ha_bufjoin(req->buf);
- ha_bufncpy(req->buf, str, t - str);
+ ha_bufjoin(rq->buf);
+ ha_bufncpy(rq->buf, str, t - str);
t++;
switch(t[0])
{
case 'u':
- ha_bufjoin(req->buf);
- escape_ldap(req->buf, user);
+ ha_bufjoin(rq->buf);
+ escape_ldap(rq->buf, user);
t++;
break;
case 'r':
- ha_bufjoin(req->buf);
- escape_ldap(req->buf, req->context->realm);
+ ha_bufjoin(rq->buf);
+ escape_ldap(rq->buf, rq->context->realm);
t++;
break;
case '%':
- ha_bufjoin(req->buf);
- ha_bufcpy(req->buf, "%");
+ ha_bufjoin(rq->buf);
+ ha_bufcpy(rq->buf, "%");
t++;
break;
};
@@ -209,7 +209,7 @@ static const char* substitute_params(ldap_context_t* ctx, const ha_request_t* re
str = t;
}
- return ha_bufdata(req->buf);
+ return ha_bufdata(rq->buf);
}
static const char* make_password_md5(ha_buffer_t* buf, const char* clearpw)
@@ -295,17 +295,17 @@ static const char* find_cleartext_password(ha_buffer_t* buf, const char** pws)
return NULL;
}
-static int parse_ldap_ha1(ha_buffer_t* buf, struct berval* bv, unsigned char* ha1)
+static int parse_ldap_ha1(const ha_request_t* rq, struct berval* bv, unsigned char* ha1)
{
size_t len;
void* d;
- ASSERT(buf && bv && ha1);
+ ASSERT(rq && bv && ha1);
/* Raw binary */
if(bv->bv_len == MD5_LEN)
{
- ha_messagex(LOG_DEBUG, "ldap: found ha1 in raw binary format");
+ ha_messagex(rq, LOG_DEBUG, "found ha1 in raw binary format");
memcpy(ha1, bv->bv_val, MD5_LEN);
return HA_OK;
}
@@ -314,11 +314,11 @@ static int parse_ldap_ha1(ha_buffer_t* buf, struct berval* bv, unsigned char* ha
else if(bv->bv_len == (MD5_LEN * 2))
{
len = MD5_LEN;
- d = ha_bufdechex(buf, bv->bv_val, &len);
+ d = ha_bufdechex(rq->buf, bv->bv_val, &len);
if(d && len == MD5_LEN)
{
- ha_messagex(LOG_DEBUG, "ldap: found ha1 in hex encoded format");
+ ha_messagex(rq, LOG_DEBUG, "found ha1 in hex encoded format");
memcpy(ha1, d, MD5_LEN);
return HA_OK;
}
@@ -328,21 +328,21 @@ static int parse_ldap_ha1(ha_buffer_t* buf, struct berval* bv, unsigned char* ha
else
{
len = MD5_LEN;
- d = ha_bufdec64(buf, bv->bv_val, &len);
+ d = ha_bufdec64(rq->buf, bv->bv_val, &len);
if(d && len == MD5_LEN)
{
- ha_messagex(LOG_DEBUG, "ldap: found ha1 in b64 encoded format");
- memcpy(ha1, ha_bufdata(buf), MD5_LEN);
+ ha_messagex(rq, LOG_DEBUG, "found ha1 in b64 encoded format");
+ memcpy(ha1, ha_bufdata(rq->buf), MD5_LEN);
return HA_OK;
}
}
- return ha_buferr(buf) ? HA_CRITERROR : HA_FALSE;
+ return ha_buferr(rq->buf) ? HA_CRITERROR : HA_FALSE;
}
-static int validate_ldap_password(ldap_context_t* ctx, LDAP* ld, LDAPMessage* entry,
- ha_buffer_t* buf, const char* user, const char* clearpw)
+static int validate_ldap_password(const ha_request_t* rq, ldap_context_t* ctx, LDAP* ld,
+ LDAPMessage* entry, const char* user, const char* clearpw)
{
char** pws;
char** t;
@@ -352,7 +352,7 @@ static int validate_ldap_password(ldap_context_t* ctx, LDAP* ld, LDAPMessage* en
int res = HA_FALSE;
int unknown = 0;
- ASSERT(entry && ld && ctx && clearpw);
+ ASSERT(entry && ld && ctx && clearpw && rq);
ASSERT(ctx->pw_attr);
pws = ldap_get_values(ld, entry, ctx->pw_attr);
@@ -371,7 +371,7 @@ static int validate_ldap_password(ldap_context_t* ctx, LDAP* ld, LDAPMessage* en
break;
case LDAP_PW_MD5:
- p = make_password_md5(buf, clearpw);
+ p = make_password_md5(rq->buf, clearpw);
break;
case LDAP_PW_CRYPT:
@@ -382,7 +382,7 @@ static int validate_ldap_password(ldap_context_t* ctx, LDAP* ld, LDAPMessage* en
break;
case LDAP_PW_SHA:
- p = make_password_sha(buf, clearpw);
+ p = make_password_sha(rq->buf, clearpw);
break;
case LDAP_PW_UNKNOWN:
@@ -402,7 +402,7 @@ static int validate_ldap_password(ldap_context_t* ctx, LDAP* ld, LDAPMessage* en
if(strcmp(pw, p) == 0)
{
- ha_messagex(LOG_DEBUG, "ldap: successful validate against password");
+ ha_messagex(rq, LOG_DEBUG, "successful validate against password");
res = HA_OK;
break;
}
@@ -412,13 +412,13 @@ static int validate_ldap_password(ldap_context_t* ctx, LDAP* ld, LDAPMessage* en
}
if(res == HA_FALSE && unknown)
- ha_messagex(LOG_ERR, "ldap: server does not contain any compatible passwords for user: %s", user);
+ ha_messagex(rq, LOG_ERR, "server does not contain any compatible passwords for user: %s", user);
return res;
}
-static int validate_ldap_ha1(ldap_context_t* ctx, LDAP* ld, LDAPMessage* entry,
- ha_buffer_t* buf, const char* user, const char* realm,
+static int validate_ldap_ha1(const ha_request_t* rq, ldap_context_t* ctx, LDAP* ld,
+ LDAPMessage* entry, const char* user, const char* realm,
const char* clearpw)
{
struct berval** ha1s;
@@ -428,7 +428,7 @@ static int validate_ldap_ha1(ldap_context_t* ctx, LDAP* ld, LDAPMessage* entry,
int r, first = 1;
int res = HA_FALSE;
- ASSERT(ctx && ld && entry && buf && user && clearpw);
+ ASSERT(ctx && ld && entry && rq && user && clearpw);
if(!ctx->ha1_attr)
return HA_FALSE;
@@ -441,7 +441,7 @@ static int validate_ldap_ha1(ldap_context_t* ctx, LDAP* ld, LDAPMessage* entry,
for(b = ha1s ; *b; b++)
{
- r = parse_ldap_ha1(buf, *b, k);
+ r = parse_ldap_ha1(rq, *b, k);
if(r < 0)
{
res = r;
@@ -451,7 +451,7 @@ static int validate_ldap_ha1(ldap_context_t* ctx, LDAP* ld, LDAPMessage* entry,
if(r == HA_FALSE)
{
if(first)
- ha_messagex(LOG_ERR, "ldap: server contains invalid HA1 digest hash for user: %s", user);
+ ha_messagex(rq, LOG_ERR, "server contains invalid HA1 digest hash for user: %s", user);
first = 0;
continue;
@@ -459,7 +459,7 @@ static int validate_ldap_ha1(ldap_context_t* ctx, LDAP* ld, LDAPMessage* entry,
if(memcmp(key, k, MD5_LEN) == 0)
{
- ha_messagex(LOG_DEBUG, "ldap: successful validate against ha1");
+ ha_messagex(rq, LOG_DEBUG, "successful validate against ha1");
res = HA_OK;
break;
}
@@ -471,7 +471,7 @@ static int validate_ldap_ha1(ldap_context_t* ctx, LDAP* ld, LDAPMessage* entry,
return res;
}
-static LDAP* get_ldap_connection(ldap_context_t* ctx)
+static LDAP* get_ldap_connection(const ha_request_t* rq, ldap_context_t* ctx)
{
LDAP* ld;
int i, r;
@@ -483,7 +483,7 @@ static LDAP* get_ldap_connection(ldap_context_t* ctx)
/* An open connection in the pool */
if(ctx->pool[i])
{
- ha_messagex(LOG_DEBUG, "ldap: using cached connection");
+ ha_messagex(rq, LOG_DEBUG, "using cached connection");
ld = ctx->pool[i];
ctx->pool[i] = NULL;
return ld;
@@ -492,14 +492,14 @@ static LDAP* get_ldap_connection(ldap_context_t* ctx)
if(ctx->pool_mark >= ctx->ldap_max)
{
- ha_messagex(LOG_ERR, "ldap: too many open connections");
+ ha_messagex(rq, LOG_ERR, "too many open connections");
return NULL;
}
ld = ldap_init(ctx->servers, ctx->port);
if(!ld)
{
- ha_message(LOG_ERR, "ldap: couldn't initialize connection");
+ ha_message(rq, LOG_ERR, "couldn't initialize connection");
return NULL;
}
@@ -509,25 +509,25 @@ static LDAP* get_ldap_connection(ldap_context_t* ctx)
ctx->password ? ctx->password : "");
if(r != LDAP_SUCCESS)
{
- report_ldap("ldap: couldn't bind to LDAP server", r);
+ report_ldap(rq, "couldn't bind to LDAP server", r);
ldap_unbind_s(ld);
return NULL;
}
}
ctx->pool_mark++;
- ha_messagex(LOG_DEBUG, "ldap: opened new connection (total %d)", ctx->pool_mark);
+ ha_messagex(rq, LOG_DEBUG, "opened new connection (total %d)", ctx->pool_mark);
return ld;
}
-static void discard_ldap_connection(ldap_context_t* ctx, LDAP* ld)
+static void discard_ldap_connection(const ha_request_t* rq, ldap_context_t* ctx, LDAP* ld)
{
ldap_unbind_s(ld);
ctx->pool_mark--;
- ha_messagex(LOG_DEBUG, "ldap: discarding connection (total %d)", ctx->pool_mark);
+ ha_messagex(rq, LOG_DEBUG, "discarding connection (total %d)", ctx->pool_mark);
}
-static void save_ldap_connection(ldap_context_t* ctx, LDAP* ld)
+static void save_ldap_connection(const ha_request_t* rq, ldap_context_t* ctx, LDAP* ld)
{
int i, e;
@@ -544,7 +544,7 @@ static void save_ldap_connection(ldap_context_t* ctx, LDAP* ld)
case LDAP_SERVER_DOWN:
case LDAP_LOCAL_ERROR:
case LDAP_NO_MEMORY:
- discard_ldap_connection(ctx, ld);
+ discard_ldap_connection(rq, ctx, ld);
break;
default:
@@ -553,7 +553,7 @@ static void save_ldap_connection(ldap_context_t* ctx, LDAP* ld)
/* An open connection in the pool */
if(!ctx->pool[i])
{
- ha_messagex(LOG_DEBUG, "ldap: caching connection for later use");
+ ha_messagex(rq, LOG_DEBUG, "caching connection for later use");
ctx->pool[i] = ld;
ld = NULL;
break;
@@ -563,7 +563,7 @@ static void save_ldap_connection(ldap_context_t* ctx, LDAP* ld)
};
}
-static int retrieve_user_entry(ldap_context_t* ctx, const ha_request_t* req, LDAP* ld,
+static int retrieve_user_entry(const ha_request_t* rq, ldap_context_t* ctx, LDAP* ld,
const char* user, const char** dn,
LDAPMessage** entry, LDAPMessage** result)
{
@@ -574,12 +574,12 @@ static int retrieve_user_entry(ldap_context_t* ctx, const ha_request_t* req, LDA
int scope;
int r;
- ASSERT(ctx && req && ld && user && dn && entry && result);
+ ASSERT(ctx && rq && ld && user && dn && entry && result);
if(ctx->filter)
{
/* Filters can also have %u and %r */
- filter = substitute_params(ctx, req, user, ctx->filter);
+ filter = substitute_params(rq, ctx, user, ctx->filter);
if(!filter)
return HA_CRITERROR;
}
@@ -598,7 +598,7 @@ static int retrieve_user_entry(ldap_context_t* ctx, const ha_request_t* req, LDA
base = *dn ? *dn : ctx->base;
scope = *dn ? LDAP_SCOPE_BASE : ctx->scope;
- ha_messagex(LOG_DEBUG, "ldap: performing search: [ base: %s / scope: %d / filter: %s ]",
+ ha_messagex(rq, LOG_DEBUG, "performing search: [ base: %s / scope: %d / filter: %s ]",
base, scope, filter);
r = ldap_search_st(ld, base, scope, filter, (char**)attrs, 0, &tv, result);
@@ -607,11 +607,11 @@ static int retrieve_user_entry(ldap_context_t* ctx, const ha_request_t* req, LDA
{
if(r == LDAP_NO_SUCH_OBJECT)
{
- ha_messagex(LOG_WARNING, "ldap: user not found in LDAP: %s", user);
+ ha_messagex(rq, LOG_WARNING, "user not found in %s", user);
return HA_FALSE;
}
- return report_ldap("couldn't search LDAP server", r);
+ return report_ldap(rq, "couldn't search LDAP server", r);
}
@@ -623,25 +623,25 @@ static int retrieve_user_entry(ldap_context_t* ctx, const ha_request_t* req, LDA
if(!(*dn))
{
*dn = ldap_get_dn(ld, *entry);
- ha_messagex(LOG_DEBUG, "ldap: found entry for user: %s", *dn);
+ ha_messagex(rq, LOG_DEBUG, "found entry for user: %s", *dn);
}
return HA_OK;
case 0:
- ha_messagex(LOG_WARNING, "ldap: user not found in LDAP: %s", user);
+ ha_messagex(rq, LOG_WARNING, "user not found in %s", user);
break;
default:
- ha_messagex(LOG_WARNING, "ldap: more than one user found for filter: %s", filter);
+ ha_messagex(rq, LOG_WARNING, "more than one user found for filter: %s", filter);
break;
};
return HA_FALSE;
}
-static int complete_digest(const ha_request_t* req, const char* user, unsigned char* ha1)
+static int complete_digest(ha_request_t* rq, const char* user, unsigned char* ha1)
{
- ldap_context_t* ctx = (ldap_context_t*)req->context->ctx_data;
+ ldap_context_t* ctx = (ldap_context_t*)rq->context->ctx_data;
LDAP* ld = NULL; /* freed in finally */
LDAPMessage* results = NULL; /* freed in finally */
LDAPMessage* entry = NULL; /* no need to free */
@@ -651,9 +651,9 @@ static int complete_digest(const ha_request_t* req, const char* user, unsigned c
const char* dn = NULL;
int r;
- ASSERT(req && ha1 && user);
+ ASSERT(rq && ha1 && user);
- ld = get_ldap_connection(ctx);
+ ld = get_ldap_connection(rq, ctx);
if(!ld)
{
ret = HA_FAILED;
@@ -668,18 +668,18 @@ static int complete_digest(const ha_request_t* req, const char* user, unsigned c
if(ctx->dnmap)
{
/* The map can have %u and %r to denote user and realm */
- dn = substitute_params(ctx, req, user, ctx->dnmap);
+ dn = substitute_params(rq, ctx, user, ctx->dnmap);
if(!dn)
{
ret = HA_FAILED;
goto finally;
}
- ha_messagex(LOG_INFO, "ldap: mapped %s to %s", user, dn);
+ ha_messagex(rq, LOG_INFO, "mapped %s to %s", user, dn);
}
/* Okay now we contact the LDAP server. */
- r = retrieve_user_entry(ctx, req, ld, user, &dn, &entry, &results);
+ r = retrieve_user_entry(rq, ctx, ld, user, &dn, &entry, &results);
if(r != HA_OK)
{
ret = r;
@@ -694,15 +694,15 @@ static int complete_digest(const ha_request_t* req, const char* user, unsigned c
{
if(*ha1s)
{
- ret = parse_ldap_ha1(req->buf, *ha1s, ha1);
+ ret = parse_ldap_ha1(rq, *ha1s, ha1);
if(ret != HA_OK)
{
if(ret == HA_FALSE)
- ha_messagex(LOG_ERR, "ldap: server contains invalid HA1 for user: %s", user);
+ ha_messagex(rq, LOG_ERR, "server contains invalid HA1 for user: %s", user);
}
}
- ha_messagex(LOG_DEBUG, "ldap: using HA1 from ldap");
+ ha_messagex(rq, LOG_DEBUG, "using HA1 from ldap");
ldap_value_free_len(ha1s);
goto finally;
}
@@ -713,11 +713,11 @@ static int complete_digest(const ha_request_t* req, const char* user, unsigned c
if(pws)
{
/* Find a cleartext password */
- const char* t = find_cleartext_password(req->buf, (const char**)pws);
+ const char* t = find_cleartext_password(rq->buf, (const char**)pws);
if(t)
{
- digest_makeha1(ha1, user, req->context->realm, t);
+ digest_makeha1(ha1, user, rq->context->realm, t);
ret = HA_OK;
}
@@ -725,17 +725,17 @@ static int complete_digest(const ha_request_t* req, const char* user, unsigned c
if(ret == HA_OK)
{
- ha_messagex(LOG_DEBUG, "ldap: using clear password from ldap");
+ ha_messagex(rq, LOG_DEBUG, "using clear password from ldap");
goto finally;
}
}
- ha_messagex(LOG_ERR, "ldap: server contains no clear password or HA1 for user: %s", user);
+ ha_messagex(rq, LOG_ERR, "server contains no clear password or HA1 for user: %s", user);
finally:
if(ld)
- save_ldap_connection(ctx, ld);
+ save_ldap_connection(rq, ctx, ld);
if(results)
ldap_msgfree(results);
@@ -743,9 +743,9 @@ finally:
return ret;
}
-static int validate_basic(const ha_request_t* req, const char* user, const char* password)
+static int validate_basic(ha_request_t* rq, const char* user, const char* password)
{
- ldap_context_t* ctx = (ldap_context_t*)req->context->ctx_data;
+ ldap_context_t* ctx = (ldap_context_t*)rq->context->ctx_data;
LDAP* ld = NULL;
LDAPMessage* entry = NULL;
LDAPMessage* results = NULL;
@@ -754,9 +754,9 @@ static int validate_basic(const ha_request_t* req, const char* user, const char*
int found = 0;
int r;
- ASSERT(req && user && password);
+ ASSERT(rq && user && password);
- ld = get_ldap_connection(ctx);
+ ld = get_ldap_connection(rq, ctx);
if(!ld)
{
ret = HA_FAILED;
@@ -772,14 +772,14 @@ static int validate_basic(const ha_request_t* req, const char* user, const char*
if(ctx->dnmap)
{
/* The map can have %u and %r to denote user and realm */
- dn = substitute_params(ctx, req, user, ctx->dnmap);
+ dn = substitute_params(rq, ctx, user, ctx->dnmap);
if(!dn)
{
ret = HA_CRITERROR;
goto finally;
}
- ha_messagex(LOG_INFO, "ldap: mapped %s to %s", user, dn);
+ ha_messagex(rq, LOG_INFO, "mapped %s to %s", user, dn);
}
@@ -800,7 +800,7 @@ static int validate_basic(const ha_request_t* req, const char* user, const char*
if(!ctx->dobind || !dn || ctx->filter)
{
- r = retrieve_user_entry(ctx, req, ld, user, &dn, &entry, &results);
+ r = retrieve_user_entry(rq, ctx, ld, user, &dn, &entry, &results);
if(r != HA_OK)
{
ret = r;
@@ -818,17 +818,17 @@ static int validate_basic(const ha_request_t* req, const char* user, const char*
if(r != LDAP_SUCCESS)
{
if(r == LDAP_INVALID_CREDENTIALS)
- ha_messagex(LOG_WARNING, "ldap: basic authentication (via bind) failed for user: %s",
+ ha_messagex(rq, LOG_WARNING, "basic authentication (via bind) failed for user: %s",
user);
else
- report_ldap("couldn't bind to LDAP server", r);
+ report_ldap(rq, "couldn't bind to LDAP server", r);
goto finally;
}
/* It worked! */
- ha_messagex(LOG_NOTICE, "ldap: validated basic user using bind: %s", user);
+ ha_messagex(rq, LOG_NOTICE, "validated basic user using bind: %s", user);
found = 1;
/* Now we have to rebind the connection back to the main user */
@@ -836,10 +836,10 @@ static int validate_basic(const ha_request_t* req, const char* user, const char*
ctx->password ? ctx->password : "");
if(r != LDAP_SUCCESS)
{
- report_ldap("ldap: couldn't rebind LDAP connection back to auth credentials", r);
+ report_ldap(rq, "couldn't rebind LDAP connection back to auth credentials", r);
/* Discard the connection since it's useless to us */
- discard_ldap_connection(ctx, ld);
+ discard_ldap_connection(rq, ctx, ld);
ld = NULL;
}
}
@@ -848,27 +848,27 @@ static int validate_basic(const ha_request_t* req, const char* user, const char*
/* Otherwise we compare the password attribute */
else
{
- ret = validate_ldap_password(ctx, ld, entry, req->buf, user, password);
+ ret = validate_ldap_password(rq, ctx, ld, entry, user, password);
if(ret == HA_FALSE)
- ret = validate_ldap_ha1(ctx, ld, entry, req->buf, user,
- req->context->realm, password);
+ ret = validate_ldap_ha1(rq, ctx, ld, entry, user,
+ rq->context->realm, password);
if(ret == HA_OK)
{
- ha_messagex(LOG_NOTICE, "ldap: validated basic user password/ha1: %s", user);
+ ha_messagex(rq, LOG_NOTICE, "validated basic user password/ha1: %s", user);
found = 1;
}
else
{
- ha_messagex(LOG_WARNING, "ldap: invalid, unreadable or unrecognized password for user: %s", user);
+ ha_messagex(rq, LOG_WARNING, "invalid, unreadable or unrecognized password for user: %s", user);
}
}
finally:
if(ld)
- save_ldap_connection(ctx, ld);
+ save_ldap_connection(rq, ctx, ld);
if(results)
ldap_msgfree(results);
@@ -946,7 +946,7 @@ int ldap_config(ha_context_t* context, const char* name, const char* value)
ctx->scope = LDAP_SCOPE_ONELEVEL;
else
{
- ha_messagex(LOG_ERR, "invalid value for '%s' (must be 'sub', 'base' or 'one')", name);
+ ha_messagex(NULL, LOG_ERR, "invalid value for '%s' (must be 'sub', 'base' or 'one')", name);
return HA_FAILED;
}
@@ -987,14 +987,14 @@ int ldap_inithand(ha_context_t* context)
/* Check for mandatory configuration */
if(!ctx->servers)
{
- ha_messagex(LOG_ERR, "ldap: configuration incomplete. "
+ ha_messagex(NULL, LOG_ERR, "configuration incomplete. "
"Must have LDAPServers.");
return HA_FAILED;
}
if(!ctx->dnmap && (!ctx->filter || !ctx->base))
{
- ha_messagex(LOG_ERR, "ldap: configuration incomplete. "
+ ha_messagex(NULL, LOG_ERR, "configuration incomplete. "
"When not using LDAPDNMap must specify LDAPBase and LDAPFilter.");
return HA_FAILED;
}
@@ -1010,12 +1010,12 @@ int ldap_inithand(ha_context_t* context)
ctx->pool = (LDAP**)malloc(sizeof(LDAP*) * ctx->ldap_max);
if(!ctx->pool)
{
- ha_messagex(LOG_CRIT, "out of memory");
+ ha_messagex(NULL, LOG_CRIT, "out of memory");
return HA_CRITERROR;
}
memset(ctx->pool, 0, sizeof(LDAP*) * ctx->ldap_max);
- ha_messagex(LOG_INFO, "ldap: initialized handler");
+ ha_messagex(NULL, LOG_INFO, "initialized handler");
}
return HA_OK;
@@ -1046,7 +1046,7 @@ void ldap_destroy(ha_context_t* context)
}
bd_destroy(context);
- ha_messagex(LOG_INFO, "ldap: uninitialized handler");
+ ha_messagex(NULL, LOG_INFO, "uninitialized ldap handler");
}