From d8566d5412e9890e27dcf51309b25f69436c8a3a Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Tue, 31 Jan 2017 15:25:43 +0000 Subject: [PATCH] Handle BAD as IMAP_AUTH_UNAVAIL (#351) * Handle BAD as IMAP_AUTH_UNAVAIL Closes #348 --- imap/auth_plain.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/imap/auth_plain.c b/imap/auth_plain.c index fe0bce061..a8c8756ff 100644 --- a/imap/auth_plain.c +++ b/imap/auth_plain.c @@ -31,6 +31,8 @@ /* imap_auth_plain: SASL PLAIN support */ imap_auth_res_t imap_auth_plain(IMAP_DATA *idata, const char *method) { + int rc; + imap_auth_res_t res = IMAP_AUTH_SUCCESS; char buf[STRING]; if (mutt_account_getuser(&idata->conn->account)) @@ -44,14 +46,23 @@ imap_auth_res_t imap_auth_plain(IMAP_DATA *idata, const char *method) idata->conn->account.user, idata->conn->account.user, idata->conn->account.pass); - if (!imap_exec(idata, buf, IMAP_CMD_FAIL_OK | IMAP_CMD_PASS)) + imap_cmd_start(idata, buf); + do + rc = imap_cmd_step(idata); + while (rc == IMAP_CMD_CONTINUE); + + if (rc == IMAP_CMD_BAD) { - mutt_clear_error(); /* clear "Logging in...". fixes #3524 */ - return IMAP_AUTH_SUCCESS; + res = IMAP_AUTH_UNAVAIL; + } + else if (rc == IMAP_CMD_NO) + { + mutt_error _("Login failed."); + mutt_sleep(2); + res = IMAP_AUTH_FAILURE; } - mutt_error _("Login failed."); - mutt_sleep(2); - return IMAP_AUTH_FAILURE; + mutt_clear_error(); /* clear "Logging in...". fixes #3524 */ + return res; } -- 2.40.0