From 35a49b518f8a355f4f2a895d96f0a42f2e080db4 Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Mon, 12 Dec 2005 00:00:00 -0500 Subject: [PATCH] postfix-2.3-20051212 --- postfix/HISTORY | 10 ++++++++++ postfix/src/global/mail_version.h | 2 +- postfix/src/smtp/smtp_proto.c | 26 +++++++++++++++++--------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/postfix/HISTORY b/postfix/HISTORY index e0498678a..ebce17863 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -11549,6 +11549,16 @@ Apologies for any names omitted. logic for address list and fallback relay processing. Still need to simplify deferred recipient handling. +20051210 + + Bugfix: after a failed TLS session, the 20051210 SMTP client + code cleanup broke sessions with backup servers, causing the + client to get out of step with the backup server. This in + turn exposed a one-year old missing exception handling + context in the EHLO handstake after sending STARTTLS. Victim + was Ralf Hildebrandt, detectives Victor Duchovni and Wietse. + File: smtp/smtp_proto.c. + Open problems: "postsuper -r" no longer resets the message arrival time, diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 3fbce5fe7..317e55d5c 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20051210" +#define MAIL_RELEASE_DATE "20051212" #define MAIL_VERSION_NUMBER "2.3" #ifdef SNAPSHOT diff --git a/postfix/src/smtp/smtp_proto.c b/postfix/src/smtp/smtp_proto.c index c8adb4c4c..bb92a2000 100644 --- a/postfix/src/smtp/smtp_proto.c +++ b/postfix/src/smtp/smtp_proto.c @@ -260,8 +260,17 @@ int smtp_helo(SMTP_STATE *state) #ifdef USE_TLS int saved_features = session->features; + int tls_helo_status; #endif + const char *NOCLOBBER where; + + /* + * Prepare for disaster. + */ + smtp_timeout_setup(state->session->stream, var_smtp_helo_tmout); + if ((except = vstream_setjmp(state->session->stream)) != 0) + return (smtp_stream_except(state, except, where)); /* * If not recursing after STARTTLS, examine the server greeting banner @@ -269,17 +278,10 @@ int smtp_helo(SMTP_STATE *state) */ if ((state->misc_flags & SMTP_MISC_FLAG_IN_STARTTLS) == 0) { - /* - * Prepare for disaster. - */ - smtp_timeout_setup(state->session->stream, var_smtp_helo_tmout); - if ((except = vstream_setjmp(state->session->stream)) != 0) - return (smtp_stream_except(state, except, - "receiving the initial server greeting")); - /* * Read and parse the server's SMTP greeting banner. */ + where = "receiving the initial server greeting"; switch ((resp = smtp_chat_resp(session))->code / 100) { case 2: break; @@ -343,12 +345,14 @@ int smtp_helo(SMTP_STATE *state) * heuristic failed. */ if ((state->misc_flags & SMTP_MISC_FLAG_USE_LMTP) == 0) { + where = "performing the EHLO handshake"; if (session->features & SMTP_FEATURE_ESMTP) { smtp_chat_cmd(session, "EHLO %s", var_smtp_helo_name); if ((resp = smtp_chat_resp(session))->code / 100 != 2) session->features &= ~SMTP_FEATURE_ESMTP; } if ((session->features & SMTP_FEATURE_ESMTP) == 0) { + where = "performing the HELO handshake"; smtp_chat_cmd(session, "HELO %s", var_smtp_helo_name); if ((resp = smtp_chat_resp(session))->code / 100 != 2) return (smtp_site_fail(state, session->host, resp, @@ -358,6 +362,7 @@ int smtp_helo(SMTP_STATE *state) return (0); } } else { + where = "performing the LHLO handshake"; smtp_chat_cmd(session, "LHLO %s", var_smtp_helo_name); if ((resp = smtp_chat_resp(session))->code / 100 != 2) return (smtp_site_fail(state, session->host, resp, @@ -541,8 +546,11 @@ int smtp_helo(SMTP_STATE *state) } #endif session->features = saved_features; + /* XXX Mix-up of per-session and per-request flags. */ state->misc_flags |= SMTP_MISC_FLAG_IN_STARTTLS; - return (smtp_start_tls(state)); + tls_helo_status = smtp_start_tls(state); + state->misc_flags &= ~SMTP_MISC_FLAG_IN_STARTTLS; + return (tls_helo_status); } /*