Implement real LOGIN auth method for IMAP.
authorAndrej Kacian <ticho@claws-mail.org>
Fri, 19 Feb 2016 16:52:50 +0000 (17:52 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Fri, 19 Feb 2016 16:52:50 +0000 (17:52 +0100)
The "old LOGIN" was in fact just a basic plaintext login method,
using: "LOGIN username password", not the SASL LOGIN method.

src/etpan/imap-thread.c
src/imap.c
src/imap.h
src/prefs_account.c

index ffe0598..76223c4 100644 (file)
@@ -894,7 +894,7 @@ static void login_run(struct etpan_thread_op * op)
        old_debug = mailstream_debug;
        mailstream_debug = 0;
 #endif
        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"))
                r = mailimap_login(param->imap,
                           param->login, param->password);
        else if (!strcmp(param->type, "GSSAPI"))
index 241ad0f..e430c8f 100644 (file)
@@ -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_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;
        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");
                        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 && 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)
        }
 
        if (ok == MAILIMAP_NO_ERROR)
@@ -4091,7 +4096,7 @@ static gint imap_cmd_login(IMAPSession *session,
        int r;
        gint ok;
 
        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
                gint ok = MAILIMAP_ERROR_BAD_STATE;
                if (imap_has_capability(session, "STARTTLS")) {
 #ifdef USE_GNUTLS
index b7eae6c..50569e0 100644 (file)
 
 typedef enum
 {
 
 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_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);
 } IMAPAuthType;
 
 FolderClass *imap_get_class            (void);
index e57dd21..6bd3716 100644 (file)
@@ -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, _("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, "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);
 
        hbox1 = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox1);