Browse Source

added auto-reconnect to ldap (fixes #294), patch from joerg@netbsd.org

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@818 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.8
Jan Kneschke 17 years ago
parent
commit
ea7b9aba9b
  1. 10
      src/http_auth.c
  2. 29
      src/mod_auth.c

10
src/http_auth.c

@ -49,6 +49,8 @@ static struct pam_conv conv = {
};
#endif
handler_t auth_ldap_init(server *srv, mod_auth_plugin_config *s);
static const char base64_pad = '=';
static const short base64_reverse_table[256] = {
@ -577,11 +579,17 @@ static int http_auth_basic_password_compare(server *srv, mod_auth_plugin_data *p
/* 2. */
if (LDAP_SUCCESS != (ret = ldap_search_s(p->conf.ldap, p->conf.auth_ldap_basedn->ptr, LDAP_SCOPE_SUBTREE, p->ldap_filter->ptr, attrs, 0, &lm))) {
if (p->conf.ldap == NULL ||
LDAP_SUCCESS != (ret = ldap_search_s(p->conf.ldap, p->conf.auth_ldap_basedn->ptr, LDAP_SCOPE_SUBTREE, p->ldap_filter->ptr, attrs, 0, &lm))) {
if (auth_ldap_init(srv, &p->conf) != HANDLER_GO_ON)
return -1;
if (LDAP_SUCCESS != (ret = ldap_search_s(p->conf.ldap, p->conf.auth_ldap_basedn->ptr, LDAP_SCOPE_SUBTREE, p->ldap_filter->ptr, attrs, 0, &lm))) {
log_error_write(srv, __FILE__, __LINE__, "sssb",
"ldap:", ldap_err2string(ret), "filter:", p->ldap_filter);
return -1;
}
}
if (NULL == (first = ldap_first_entry(p->conf.ldap, lm))) {

29
src/mod_auth.c

@ -12,6 +12,8 @@
#include "log.h"
#include "response.h"
handler_t auth_ldap_init(server *srv, mod_auth_plugin_config *s);
/**
* the basic and digest auth framework
@ -505,8 +507,25 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) {
close(fd);
}
break;
case AUTH_BACKEND_LDAP:
case AUTH_BACKEND_LDAP: {
handler_t ret = auth_ldap_init(srv, s);
if (ret == HANDLER_ERROR)
return (ret);
break;
}
default:
break;
}
}
return HANDLER_GO_ON;
}
handler_t
auth_ldap_init(server *srv, mod_auth_plugin_config *s)
{
#ifdef USE_LDAP
int ret;
#if 0
if (s->auth_ldap_basedn->used == 0) {
log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.base-dn has to be set");
@ -586,13 +605,7 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) {
log_error_write(srv, __FILE__, __LINE__, "s", "no ldap support available");
return HANDLER_ERROR;
#endif
break;
default:
break;
}
}
return HANDLER_GO_ON;
return HANDLER_GO_ON;
}
int mod_auth_plugin_init(plugin *p) {

Loading…
Cancel
Save