]> granicus.if.org Git - neomutt/commitdiff
Handle BAD as IMAP_AUTH_UNAVAIL (#351)
authorPietro Cerutti <gahr@gahr.ch>
Tue, 31 Jan 2017 15:25:43 +0000 (15:25 +0000)
committerGitHub <noreply@github.com>
Tue, 31 Jan 2017 15:25:43 +0000 (15:25 +0000)
* Handle BAD as IMAP_AUTH_UNAVAIL

Closes #348

imap/auth_plain.c

index fe0bce06170ff6e8014a571de858f5422d3a96e7..a8c8756ff939cb7e34ffb488872fcf9630fec3bc 100644 (file)
@@ -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;
 }