From ccd5c1a264eba6e4d7f6f0c6a911f495bf5c9727 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Wed, 14 Feb 2001 20:19:36 +0000 Subject: STARTTLS patch from Brendan Cully. --- imap/auth.c | 2 +- imap/imap.c | 34 +++++++++++++++++++++++++++++++++- imap/message.c | 7 ++++--- 3 files changed, 38 insertions(+), 5 deletions(-) (limited to 'imap') 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 #include @@ -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 - * Copyright (C) 1999-2000 Brendan Cully + * Copyright (C) 1999-2001 Brendan Cully * * 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) { -- cgit v1.2.3