dovecot-2.1: doveadm: Fixed sending commands to doveadm server w...

dovecot at dovecot.org dovecot at dovecot.org
Wed Sep 21 13:43:16 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/1d8009c7b67e
changeset: 13528:1d8009c7b67e
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 19 17:10:11 2011 +0300
description:
doveadm: Fixed sending commands to doveadm server when it didn't require authentication.

diffstat:

 src/doveadm/server-connection.c |  28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)

diffs (59 lines):

diff -r b97c53c54f72 -r 1d8009c7b67e src/doveadm/server-connection.c
--- a/src/doveadm/server-connection.c	Wed Sep 21 12:34:02 2011 +0300
+++ b/src/doveadm/server-connection.c	Mon Sep 19 17:10:11 2011 +0300
@@ -158,6 +158,15 @@
 	i_stream_skip(conn->input, size);
 }
 
+static void server_connection_authenticated(struct server_connection *conn)
+{
+	conn->authenticated = TRUE;
+	if (conn->delayed_cmd != NULL) {
+		o_stream_send_str(conn->output, conn->delayed_cmd);
+		conn->delayed_cmd = NULL;
+	}
+}
+
 static int
 server_connection_authenticate(struct server_connection *conn)
 {
@@ -180,10 +189,7 @@
 	str_append_c(cmd, '\n');
 
 	o_stream_send(conn->output, cmd->data, cmd->used);
-	if (conn->delayed_cmd != NULL) {
-		o_stream_send_str(conn->output, conn->delayed_cmd);
-		conn->delayed_cmd = NULL;
-	}
+	server_connection_authenticated(conn);
 	return 0;
 }
 
@@ -202,7 +208,7 @@
 
 		conn->handshaked = TRUE;
 		if (strcmp(line, "+") == 0)
-			conn->authenticated = TRUE;
+			server_connection_authenticated(conn);
 		else if (strcmp(line, "-") == 0) {
 			if (server_connection_authenticate(conn) < 0) {
 				server_connection_destroy(&conn);
@@ -222,18 +228,6 @@
 		return;
 	}
 
-	if (!conn->authenticated) {
-		if ((line = i_stream_next_line(conn->input)) == NULL)
-			return;
-		if (strcmp(line, "+") == 0)
-			conn->authenticated = TRUE;
-		else {
-			i_error("doveadm authentication failed (%s)", line+1);
-			server_connection_destroy(&conn);
-			return;
-		}
-	}
-
 	data = i_stream_get_data(conn->input, &size);
 	if (size == 0)
 		return;


More information about the dovecot-cvs mailing list