dovecot-2.2: auth: Make sure userdb iteration is destroyed if wo...

dovecot at dovecot.org dovecot at dovecot.org
Fri Oct 10 21:45:41 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/c4e587d1e8ac
changeset: 17940:c4e587d1e8ac
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 11 00:02:00 2014 +0300
description:
auth: Make sure userdb iteration is destroyed if worker connection disconnects.

diffstat:

 src/auth/auth-master-connection.c |  13 +++++++++++++
 src/auth/auth-master-connection.h |   2 +-
 2 files changed, 14 insertions(+), 1 deletions(-)

diffs (56 lines):

diff -r a36fe1250606 -r c4e587d1e8ac src/auth/auth-master-connection.c
--- a/src/auth/auth-master-connection.c	Sat Oct 11 00:01:09 2014 +0300
+++ b/src/auth/auth-master-connection.c	Sat Oct 11 00:02:00 2014 +0300
@@ -435,6 +435,9 @@
 
 static void master_input_list_finish(struct master_list_iter_ctx *ctx)
 {
+	i_assert(ctx->conn->iter_ctx == ctx);
+
+	ctx->conn->iter_ctx = NULL;
 	ctx->conn->io = io_add(ctx->conn->fd, IO_READ, master_input, ctx->conn);
 
 	if (ctx->iter != NULL)
@@ -532,6 +535,13 @@
 	}
 	list++;
 
+	if (conn->iter_ctx != NULL) {
+		i_error("Auth client is already iterating users");
+		str = t_strdup_printf("DONE\t%u\tfail\n", id);
+		o_stream_nsend_str(conn->output, str);
+		return TRUE;
+	}
+
 	if (conn->userdb_restricted_uid != 0) {
 		i_error("Auth client doesn't have permissions to list users: %s",
 			auth_restricted_reason(conn));
@@ -587,6 +597,7 @@
 	o_stream_set_flush_callback(conn->output, master_output_list, ctx);
 	ctx->iter = userdb_blocking_iter_init(auth_request,
 					      master_input_list_callback, ctx);
+	conn->iter_ctx = ctx;
 	return TRUE;
 }
 
@@ -766,6 +777,8 @@
 
 	DLLIST_REMOVE(&auth_master_connections, conn);
 
+	if (conn->iter_ctx != NULL)
+		master_input_list_finish(conn->iter_ctx);
 	if (conn->input != NULL)
 		i_stream_close(conn->input);
 	if (conn->output != NULL)
diff -r a36fe1250606 -r c4e587d1e8ac src/auth/auth-master-connection.h
--- a/src/auth/auth-master-connection.h	Sat Oct 11 00:01:09 2014 +0300
+++ b/src/auth/auth-master-connection.h	Sat Oct 11 00:02:00 2014 +0300
@@ -15,7 +15,7 @@
 	struct ostream *output;
 	struct io *io;
 
-	struct auth_request_list *requests;
+	struct master_list_iter_ctx *iter_ctx;
 	/* If non-zero, allow only USER lookups whose returned uid matches
 	   this uid. Don't allow LIST/PASS lookups. */
 	uid_t userdb_restricted_uid;


More information about the dovecot-cvs mailing list