changeset 21935:6bcbb61a2943

lib-imap-client: Disconnection during LOGIN should still have state=disconnected It's not an authentication failure, which would imply that the user or password was wrong.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 10 Apr 2017 16:44:52 +0300
parents 76fdf3886569
children 0f114c9e9fce
files src/lib-imap-client/imapc-client.h src/lib-imap-client/imapc-connection.c
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap-client/imapc-client.h	Mon Apr 10 16:18:46 2017 +0300
+++ b/src/lib-imap-client/imapc-client.h	Mon Apr 10 16:44:52 2017 +0300
@@ -10,7 +10,9 @@
 	IMAPC_COMMAND_STATE_OK,
 	IMAPC_COMMAND_STATE_NO,
 	IMAPC_COMMAND_STATE_BAD,
+	/* Authentication to IMAP server failed (NO or BAD) */
 	IMAPC_COMMAND_STATE_AUTH_FAILED,
+	/* Client was unexpectedly disconnected. */
 	IMAPC_COMMAND_STATE_DISCONNECTED
 };
 
--- a/src/lib-imap-client/imapc-connection.c	Mon Apr 10 16:18:46 2017 +0300
+++ b/src/lib-imap-client/imapc-connection.c	Mon Apr 10 16:44:52 2017 +0300
@@ -164,7 +164,9 @@
 		  const char *error)
 {
 	struct imapc_command_reply reply = *_reply;
-	reply.state = IMAPC_COMMAND_STATE_AUTH_FAILED;
+
+	if (reply.state != IMAPC_COMMAND_STATE_DISCONNECTED)
+		reply.state = IMAPC_COMMAND_STATE_AUTH_FAILED;
 	reply.text_without_resp = reply.text_full =
 		t_strdup_printf("Authentication failed: %s", error);
 	i_error("imapc(%s): %s", conn->name, reply.text_full);