diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 2001-02-14 20:19:36 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 2001-02-14 20:19:36 +0000 |
commit | ccd5c1a264eba6e4d7f6f0c6a911f495bf5c9727 (patch) | |
tree | 6139cdc6cf17d8b2ca0f2282f0c089d2d8b33138 /imap | |
parent | 6dedb2b6ece9c17553080a6eda28d4142af9b19a (diff) |
STARTTLS patch from Brendan Cully.
Diffstat (limited to 'imap')
-rw-r--r-- | imap/auth.c | 2 | ||||
-rw-r--r-- | imap/imap.c | 34 | ||||
-rw-r--r-- | imap/message.c | 7 |
3 files changed, 38 insertions, 5 deletions
diff --git a/imap/auth.c b/imap/auth.c index fa485bfe..97ac5d12 100644 --- a/imap/auth.c +++ b/imap/auth.c @@ -48,7 +48,7 @@ int imap_authenticate (IMAP_DATA* idata) imap_auth_t* authenticator = imap_authenticators; int r = -1; - while (authenticator) + while (*authenticator) { if ((r = (*authenticator)(idata)) != IMAP_AUTH_UNAVAIL) return r; diff --git a/imap/imap.c b/imap/imap.c index ba96e782..2b479601 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -29,6 +29,9 @@ #include "browser.h" #include "message.h" #include "imap_private.h" +#ifdef USE_SSL +# include "mutt_ssl.h" +#endif #include <unistd.h> #include <ctype.h> @@ -309,6 +312,7 @@ IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags) int imap_open_connection (IMAP_DATA* idata) { char buf[LONG_STRING]; + int rc; if (mutt_socket_open (idata->conn) < 0) { @@ -324,8 +328,36 @@ int imap_open_connection (IMAP_DATA* idata) if (mutt_strncmp ("* OK", idata->cmd.buf, 4) == 0) { - if (imap_check_capabilities (idata) || imap_authenticate (idata)) + /* TODO: Parse new tagged CAPABILITY data (* OK [CAPABILITY...]) */ + if (imap_check_capabilities (idata)) + goto bail; +#if defined(USE_SSL) && !defined(USE_NSS) + /* Attempt STARTTLS if available. TODO: make STARTTLS configurable. */ + if (mutt_bit_isset (idata->capabilities, STARTTLS)) + { + if ((rc = imap_exec (idata, "STARTTLS", IMAP_CMD_FAIL_OK)) == -1) + goto bail; + if (rc != -2) + { + if (mutt_ssl_starttls (idata->conn)) + { + dprint (1, (debugfile, "imap_open_connection: STARTTLS failed\n")); + goto bail; + } + else + { + /* RFC 2595 demands we recheck CAPABILITY after TLS is negotiated. */ + if (imap_exec (idata, "CAPABILITY", 0)) + goto bail; + } + } + } +#endif + if (imap_authenticate (idata)) goto bail; + if (idata->conn->ssf) + dprint (2, (debugfile, "Communication encrypted at %d bits\n", + idata->conn->ssf)); } else if (mutt_strncmp ("* PREAUTH", idata->cmd.buf, 9) == 0) { diff --git a/imap/message.c b/imap/message.c index adaf142b..b3a14e83 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1,6 +1,6 @@ /* * Copyright (C) 1996-9 Brandon Long <blong@fiction.net> - * Copyright (C) 1999-2000 Brendan Cully <brendan@kublai.com> + * Copyright (C) 1999-2001 Brendan Cully <brendan@kublai.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -89,8 +89,9 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend) for (msgno = msgbegin; msgno <= msgend ; msgno++) { - mutt_message (_("Fetching message headers... [%d/%d]"), msgno + 1, - msgend + 1); + if (ReadInc && (!msgno || ((msgno+1) % ReadInc == 0))) + mutt_message (_("Fetching message headers... [%d/%d]"), msgno + 1, + msgend + 1); if (msgno + 1 > fetchlast) { |