dovecot-2.2: auth ldap: Call ldap_init*() already at db_ldap_ini...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Mar 16 21:15:40 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/804dc641f448
changeset: 18358:804dc641f448
user: Timo Sirainen <tss at iki.fi>
date: Mon Mar 16 23:14:49 2015 +0200
description:
auth ldap: Call ldap_init*() already at db_ldap_init().
ldap_init*() doesn't start connecting yet, but this way we can verify that
all the settings are correct.
diffstat:
src/auth/db-ldap.c | 49 ++++++++++++++++++++++++++++---------------------
1 files changed, 28 insertions(+), 21 deletions(-)
diffs (73 lines):
diff -r b3fd99432298 -r 804dc641f448 src/auth/db-ldap.c
--- a/src/auth/db-ldap.c Mon Mar 16 23:03:10 2015 +0200
+++ b/src/auth/db-ldap.c Mon Mar 16 23:14:49 2015 +0200
@@ -1114,6 +1114,30 @@
db_ldap_set_tls_options(conn);
}
+static void db_ldap_init_ld(struct ldap_connection *conn)
+{
+ int ret;
+
+ if (conn->set.uris != NULL) {
+#ifdef LDAP_HAVE_INITIALIZE
+ ret = ldap_initialize(&conn->ld, conn->set.uris);
+ if (ret != LDAP_SUCCESS) {
+ i_fatal("LDAP: ldap_initialize() failed with uris %s: %s",
+ conn->set.uris, ldap_err2string(ret));
+ }
+#else
+ i_unreached(); /* already checked at init */
+#endif
+ } else {
+ conn->ld = ldap_init(conn->set.hosts, LDAP_PORT);
+ if (conn->ld == NULL) {
+ i_fatal("LDAP: ldap_init() failed with hosts: %s",
+ conn->set.hosts);
+ }
+ }
+ db_ldap_set_options(conn);
+}
+
int db_ldap_connect(struct ldap_connection *conn)
{
bool debug = atoi(conn->set.debug_level) > 0;
@@ -1128,27 +1152,8 @@
memset(&start, 0, sizeof(start));
}
i_assert(conn->pending_count == 0);
- if (conn->ld == NULL) {
- if (conn->set.uris != NULL) {
-#ifdef LDAP_HAVE_INITIALIZE
- ret = ldap_initialize(&conn->ld, conn->set.uris);
- if (ret != LDAP_SUCCESS) {
- i_fatal("LDAP: ldap_initialize() failed with uris %s: %s",
- conn->set.uris, ldap_err2string(ret));
- conn->ld = NULL;
- }
-#else
- i_unreached(); /* already checked at init */
-#endif
- } else {
- conn->ld = ldap_init(conn->set.hosts, LDAP_PORT);
- if (conn->ld == NULL) {
- i_fatal("LDAP: ldap_init() failed with hosts: %s",
- conn->set.hosts);
- }
- }
- db_ldap_set_options(conn);
- }
+ if (conn->ld == NULL)
+ db_ldap_init_ld(conn);
if (conn->set.tls) {
#ifdef LDAP_HAVE_START_TLS_S
@@ -1827,6 +1832,8 @@
conn->next = ldap_connections;
ldap_connections = conn;
+
+ db_ldap_init_ld(conn);
return conn;
}
More information about the dovecot-cvs
mailing list