[dovecot-cvs] dovecot/src/auth db-ldap.c, 1.41.2.8, 1.41.2.9 db-ldap.h, 1.20.2.5, 1.20.2.6 passdb-ldap.c, 1.44.2.4, 1.44.2.5

tss at dovecot.org tss at dovecot.org
Sat Nov 4 15:09:57 UTC 2006


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv21807

Modified Files:
      Tag: branch_1_0
	db-ldap.c db-ldap.h passdb-ldap.c 
Log Message:
Crashfixes



Index: db-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.c,v
retrieving revision 1.41.2.8
retrieving revision 1.41.2.9
diff -u -d -r1.41.2.8 -r1.41.2.9
--- db-ldap.c	4 Nov 2006 15:00:28 -0000	1.41.2.8
+++ db-ldap.c	4 Nov 2006 15:09:25 -0000	1.41.2.9
@@ -142,11 +142,9 @@
 {
 	int msgid;
 
-	if (!conn->connected && !conn->connecting) {
-		if (db_ldap_connect(conn) < 0) {
-			request->callback(conn, request, NULL);
-			return;
-		}
+	if (db_ldap_connect(conn) < 0) {
+		request->callback(conn, request, NULL);
+		return;
 	}
 
 	if (conn->last_auth_bind) {
@@ -370,6 +368,7 @@
 	if (msgid == -1) {
 		i_error("ldap_bind(%s) failed: %s",
 			conn->set.dn, ldap_get_error(conn));
+		i_free(ldap_request);
 		return -1;
 	}
 	hash_insert(conn->requests, POINTER_CAST(msgid), ldap_request);
@@ -380,13 +379,26 @@
 	return 0;
 }
 
+static void db_ldap_get_fd(struct ldap_connection *conn)
+{
+	int ret;
+
+	/* get the connection's fd */
+	ret = ldap_get_option(conn->ld, LDAP_OPT_DESC, (void *)&conn->fd);
+	if (ret != LDAP_SUCCESS) {
+		i_fatal("LDAP: Can't get connection fd: %s",
+			ldap_err2string(ret));
+	}
+	i_assert(conn->fd != -1);
+	net_set_nonblock(conn->fd, TRUE);
+}
+
 int db_ldap_connect(struct ldap_connection *conn)
 {
 	unsigned int ldap_version;
 	int ret;
 
-	i_assert(!conn->connecting);
-	if (conn->connected)
+	if (conn->connected || conn->connecting)
 		return 0;
 
 	if (conn->ld == NULL) {
@@ -423,17 +435,7 @@
 			i_fatal("LDAP: Can't set protocol version %u: %s",
 				ldap_version, ldap_err2string(ret));
 		}
-
-		/* get the connection's fd */
-		ret = ldap_get_option(conn->ld, LDAP_OPT_DESC,
-				      (void *)&conn->fd);
-		if (ret != LDAP_SUCCESS) {
-			i_fatal("LDAP: Can't get connection fd: %s",
-				ldap_err2string(ret));
-		}
-		net_set_nonblock(conn->fd, TRUE);
 	}
-	i_assert(conn->fd != -1);
 
 	if (conn->set.tls) {
 #ifdef LDAP_HAVE_START_TLS_S
@@ -469,9 +471,11 @@
 #endif
 		if (db_ldap_connect_finish(conn, ret) < 0)
 			return -1;
+		db_ldap_get_fd(conn);
 	} else {
 		if (db_ldap_bind(conn) < 0)
 			return -1;
+		db_ldap_get_fd(conn);
 	}
 
 	conn->io = io_add(conn->fd, IO_READ, ldap_input, conn);

Index: db-ldap.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.h,v
retrieving revision 1.20.2.5
retrieving revision 1.20.2.6
diff -u -d -r1.20.2.5 -r1.20.2.6
--- db-ldap.h	4 Nov 2006 15:00:28 -0000	1.20.2.5
+++ db-ldap.h	4 Nov 2006 15:09:25 -0000	1.20.2.6
@@ -56,7 +56,7 @@
         struct ldap_settings set;
 
 	LDAP *ld;
-	int fd; /* only set when ld is not NULL */
+	int fd; /* only set when connected/connecting */
 	struct io *io;
 	struct hash_table *requests;
 

Index: passdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-ldap.c,v
retrieving revision 1.44.2.4
retrieving revision 1.44.2.5
diff -u -d -r1.44.2.4 -r1.44.2.5
--- passdb-ldap.c	4 Nov 2006 15:00:28 -0000	1.44.2.4
+++ passdb-ldap.c	4 Nov 2006 15:09:25 -0000	1.44.2.5
@@ -439,11 +439,9 @@
 
 	/* reconnect if needed. this is also done by db_ldap_search(), but
 	   with auth binds we'll have to do it ourself */
-	if (!conn->connected && !conn->connecting) {
-		if (db_ldap_connect(conn)< 0) {
-			callback(PASSDB_RESULT_INTERNAL_FAILURE, request);
-			return;
-		}
+	if (db_ldap_connect(conn)< 0) {
+		callback(PASSDB_RESULT_INTERNAL_FAILURE, request);
+		return;
 	}
 
 	ldap_request = p_new(request->pool, struct passdb_ldap_request, 1);



More information about the dovecot-cvs mailing list