changeset 13546:46e90b44d378

doveadm server: Previous non-authentication fix broken authentication.
author Timo Sirainen <tss@iki.fi>
date Fri, 23 Sep 2011 00:46:19 +0300
parents e932f81eba48
children ed97724884a2
files src/doveadm/server-connection.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/server-connection.c	Fri Sep 23 00:04:11 2011 +0300
+++ b/src/doveadm/server-connection.c	Fri Sep 23 00:46:19 2011 +0300
@@ -189,7 +189,6 @@
 	str_append_c(cmd, '\n');
 
 	o_stream_send(conn->output, cmd->data, cmd->used);
-	server_connection_authenticated(conn);
 	return 0;
 }
 
@@ -214,6 +213,7 @@
 				server_connection_destroy(&conn);
 				return;
 			}
+			return;
 		} else {
 			i_error("doveadm server sent invalid handshake: %s",
 				line);
@@ -228,6 +228,18 @@
 		return;
 	}
 
+	if (!conn->authenticated) {
+		if ((line = i_stream_next_line(conn->input)) == NULL)
+			return;
+		if (strcmp(line, "+") == 0)
+			server_connection_authenticated(conn);
+		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;