From dce9662ac803b3c600abda1d65adf02a720737c5 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Thu, 3 Aug 2000 08:00:44 +0000 Subject: [PATCH] More IMAP fixes from Brendan. --- imap/BUGS | 8 +------- imap/auth_sasl.c | 33 +++++++++++++++++++++++---------- imap/imap.c | 3 ++- imap/imap_ssl.c | 1 - mutt_sasl.c | 13 ++++++++++--- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/imap/BUGS b/imap/BUGS index 1aa70b1f..cb27ba9e 100644 --- a/imap/BUGS +++ b/imap/BUGS @@ -19,12 +19,6 @@ In no particular order: Tommi Komulainen's keepalive patch for edit sessions may work for you, though. Committed to CVS late November 1999, I think. -* Sometimes hdr->env seems to be NULL, according to other users' core - files. I haven't been able to reproduce this, and am not sure how - to track it down. But it's very naughty indeed. It appears to be the - result of spurious mx_close_mailbox calls handling the untagged - BYE response. - * Mutt is uninterruptible during socket calls. We should handle SIGINT. * Server copy currently doesn't take into account uncommitted changes in @@ -37,4 +31,4 @@ In no particular order: * The mutt_pretty routines don't work well when the delimiter isn't '/'. Brendan Cully -Updated 20000719 +Updated 20000731 diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index 215c128b..8b78151c 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -70,7 +70,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata) rc = sasl_client_start (saslconn, idata->capstr, NULL, NULL, &pc, &olen, &mech); - client_start = (pc != NULL); + client_start = (olen > 0); if (rc != SASL_OK && rc != SASL_CONTINUE) { @@ -92,30 +92,43 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata) goto bail; if (!mutt_strncmp (buf, "+ ", 2)) + { if (sasl_decode64 (buf+2, strlen (buf+2), buf, &len) != SASL_OK) { dprint (1, (debugfile, "imap_auth_sasl: error base64-decoding server response.\n")); goto bail; } + } + else if ((buf[0] == '*')) + { + if (imap_handle_untagged (idata, buf)) + goto bail; + else continue; + } if (!client_start) rc = sasl_client_step (saslconn, buf, len, NULL, &pc, &olen); - client_start = 0; + else + client_start = 0; - if (olen) + /* send out response, or line break if none needed */ + if (olen && sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) + { + dprint (1, (debugfile, "imap_auth_sasl: error base64-encoding client response.\n")); + goto bail; + } + + if (olen || rc == SASL_CONTINUE) { - /* send out response, or line break if none needed */ - if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) - { - dprint (1, (debugfile, "imap_auth_sasl: error base64-encoding client response.\n")); - goto bail; - } - strfcpy (buf + olen, "\r\n", sizeof (buf) - olen); mutt_socket_write (idata->conn, buf); } } + while (mutt_strncmp (buf, idata->seq, SEQLEN)) + if (mutt_socket_readln (buf, sizeof (buf), idata->conn) < 0) + goto bail; + if (rc != SASL_OK) goto bail; diff --git a/imap/imap.c b/imap/imap.c index 991e300c..ca66b2f4 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -168,6 +168,7 @@ int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes) return -1; } +#if 1 if (r == 1 && c != '\n') fputc ('\r', fp); @@ -178,7 +179,7 @@ int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes) } else r = 0; - +#endif fputc (c, fp); #ifdef DEBUG if (debuglevel >= IMAP_LOG_LTRL) diff --git a/imap/imap_ssl.c b/imap/imap_ssl.c index 1a97499e..c1643986 100644 --- a/imap/imap_ssl.c +++ b/imap/imap_ssl.c @@ -190,7 +190,6 @@ int ssl_socket_read (CONNECTION * conn) int ssl_socket_write (CONNECTION * conn, const char *buf) { sslsockdata *data = conn->sockdata; - dprint (1, (debugfile, "ssl_socket_write():%s", buf)); return SSL_write (data->ssl, buf, mutt_strlen (buf)); } diff --git a/mutt_sasl.c b/mutt_sasl.c index b02b5a2f..30764a6f 100644 --- a/mutt_sasl.c +++ b/mutt_sasl.c @@ -25,7 +25,7 @@ #include -static sasl_callback_t mutt_sasl_callbacks[3]; +static sasl_callback_t mutt_sasl_callbacks[4]; /* callbacks */ static int mutt_sasl_cb_log (void* context, int priority, const char* message); @@ -81,6 +81,11 @@ sasl_callback_t* mutt_sasl_get_callbacks (ACCOUNT* account) callback->context = account; callback++; + callback->id = SASL_CB_USER; + callback->proc = mutt_sasl_cb_authname; + callback->context = account; + callback++; + callback->id = SASL_CB_PASS; callback->proc = mutt_sasl_cb_pass; callback->context = account; @@ -101,7 +106,8 @@ static int mutt_sasl_cb_log (void* context, int priority, const char* message) return SASL_OK; } -/* mutt_sasl_cb_authname: callback to retrieve authname from ACCOUNT */ +/* mutt_sasl_cb_authname: callback to retrieve authname or user (mutt + * doesn't distinguish, even if some SASL plugins do) from ACCOUNT */ static int mutt_sasl_cb_authname (void* context, int id, const char** result, unsigned* len) { @@ -114,7 +120,8 @@ static int mutt_sasl_cb_authname (void* context, int id, const char** result, if (!account) return SASL_BADPARAM; - dprint (2, (debugfile, "mutt_sasl_cb_authname: getting user for %s:%u\n", + dprint (2, (debugfile, "mutt_sasl_cb_authname: getting %s for %s:%u\n", + id == SASL_CB_AUTHNAME ? "authname" : "user", account->host, account->port)); if (mutt_account_getuser (account)) -- 2.40.0