talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 74e15427f6a0e237ff74f2a001ca3c5759bf2320
parent 7047fa7f29ac1837915c139bc4ca71b153886d3e
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Fri, 19 Feb 2016 17:52:50 +0100

Implement real LOGIN auth method for IMAP.

The "old LOGIN" was in fact just a basic plaintext login method,
using: "LOGIN username password", not the SASL LOGIN method.

Diffstat:
Msrc/etpan/imap-thread.c | 2+-
Msrc/imap.c | 11++++++++---
Msrc/imap.h | 5+++--
Msrc/prefs_account.c | 3++-
4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/etpan/imap-thread.c b/src/etpan/imap-thread.c @@ -894,7 +894,7 @@ static void login_run(struct etpan_thread_op * op) old_debug = mailstream_debug; mailstream_debug = 0; #endif - if (!strcmp(param->type, "LOGIN")) + if (!strcmp(param->type, "plaintext")) r = mailimap_login(param->imap, param->login, param->password); else if (!strcmp(param->type, "GSSAPI")) diff --git a/src/imap.c b/src/imap.c @@ -908,6 +908,9 @@ static gint imap_auth(IMAPSession *session, const gchar *user, const gchar *pass case IMAP_AUTH_LOGIN: ok = imap_cmd_login(session, user, pass, "LOGIN"); break; + case IMAP_AUTH_PLAINTEXT: + ok = imap_cmd_login(session, user, pass, "plaintext"); + break; case IMAP_AUTH_GSSAPI: ok = imap_cmd_login(session, user, pass, "GSSAPI"); break; @@ -935,10 +938,12 @@ static gint imap_auth(IMAPSession *session, const gchar *user, const gchar *pass ok = imap_cmd_login(session, user, pass, "SCRAM-SHA-1"); if (ok == MAILIMAP_ERROR_LOGIN && imap_has_capability(session, "PLAIN")) ok = imap_cmd_login(session, user, pass, "PLAIN"); + if (ok == MAILIMAP_ERROR_LOGIN && imap_has_capability(session, "LOGIN")) + ok = imap_cmd_login(session, user, pass, "LOGIN"); if (ok == MAILIMAP_ERROR_LOGIN && imap_has_capability(session, "GSSAPI")) ok = imap_cmd_login(session, user, pass, "GSSAPI"); - if (ok == MAILIMAP_ERROR_LOGIN) /* we always try LOGIN before giving up */ - ok = imap_cmd_login(session, user, pass, "LOGIN"); + if (ok == MAILIMAP_ERROR_LOGIN) /* we always try plaintext login before giving up */ + ok = imap_cmd_login(session, user, pass, "plaintext"); } if (ok == MAILIMAP_NO_ERROR) @@ -4091,7 +4096,7 @@ static gint imap_cmd_login(IMAPSession *session, int r; gint ok; - if (!strcmp(type, "LOGIN") && imap_has_capability(session, "LOGINDISABLED")) { + if (!strcmp(type, "plaintext") && imap_has_capability(session, "LOGINDISABLED")) { gint ok = MAILIMAP_ERROR_BAD_STATE; if (imap_has_capability(session, "STARTTLS")) { #ifdef USE_GNUTLS diff --git a/src/imap.h b/src/imap.h @@ -24,13 +24,14 @@ typedef enum { - IMAP_AUTH_LOGIN = 1 << 0, + IMAP_AUTH_PLAINTEXT = 1 << 0, IMAP_AUTH_CRAM_MD5 = 1 << 1, IMAP_AUTH_ANON = 1 << 2, IMAP_AUTH_GSSAPI = 1 << 3, IMAP_AUTH_DIGEST_MD5 = 1 << 4, IMAP_AUTH_SCRAM_SHA1 = 1 << 5, - IMAP_AUTH_PLAIN = 1 << 6 + IMAP_AUTH_PLAIN = 1 << 6, + IMAP_AUTH_LOGIN = 1 << 7 } IMAPAuthType; FolderClass *imap_get_class (void); diff --git a/src/prefs_account.c b/src/prefs_account.c @@ -1578,13 +1578,14 @@ static void receive_create_widget_func(PrefsPage * _page, COMBOBOX_ADD (menu, _("Automatic"), 0); COMBOBOX_ADD (menu, NULL, 0); - COMBOBOX_ADD (menu, "LOGIN", IMAP_AUTH_LOGIN); + COMBOBOX_ADD (menu, _("Plain text"), IMAP_AUTH_PLAINTEXT); COMBOBOX_ADD (menu, "CRAM-MD5", IMAP_AUTH_CRAM_MD5); COMBOBOX_ADD (menu, "ANONYMOUS", IMAP_AUTH_ANON); COMBOBOX_ADD (menu, "GSSAPI", IMAP_AUTH_GSSAPI); COMBOBOX_ADD (menu, "DIGEST-MD5", IMAP_AUTH_DIGEST_MD5); COMBOBOX_ADD (menu, "SCRAM-SHA-1", IMAP_AUTH_SCRAM_SHA1); COMBOBOX_ADD (menu, "PLAIN", IMAP_AUTH_PLAIN); + COMBOBOX_ADD (menu, "LOGIN", IMAP_AUTH_LOGIN); hbox1 = gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox1);