From 1693a433866d05405edec84a09a377866e5a8fe7 Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Thu, 14 Jun 2007 00:00:00 -0500 Subject: [PATCH] postfix-2.4.4-RC1 --- postfix/HISTORY | 10 +++ postfix/html/postconf.5.html | 2 + postfix/man/man5/postconf.5 | 2 + postfix/proto/postconf.html.prolog | 2 + postfix/proto/postconf.man.prolog | 2 + postfix/src/global/mail_version.h | 4 +- postfix/src/milter/milter8.c | 105 +++++++++++++++++++---------- 7 files changed, 89 insertions(+), 38 deletions(-) diff --git a/postfix/HISTORY b/postfix/HISTORY index 462a94a51..8c8350ede 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -13481,3 +13481,13 @@ Apologies for any names omitted. Portability: Victor helpfully pointed out that change 20070425 broke on non-IPv6 systems. Files: smtpd/smtpd_peer.c, qmqpd/qmqpd_peer.c. + +20070613 + + Bugfix: the Milter client assumed that a Milter application + does not modify the message header or envelope, after that + same Milter application has modified the message body of + that same email message. This is not a problem with updates + by different Milter applications. Problem was triggered + by Jose-Marcio Martins da Cruz. Also simplified the handling + of queue file update errors. File: milter/milter8.c. diff --git a/postfix/html/postconf.5.html b/postfix/html/postconf.5.html index a2d5b12f0..3f5413544 100644 --- a/postfix/html/postconf.5.html +++ b/postfix/html/postconf.5.html @@ -53,6 +53,8 @@ recursively replaced by the value of the named parameter.

"$name" is empty. This form is supported with Postfix version 2.2 and later.

+
  • Specify "$$" to produce a single "$" character.

    +
  • When the same parameter is defined multiple times, only diff --git a/postfix/man/man5/postconf.5 b/postfix/man/man5/postconf.5 index 7d56391ad..60ac612d5 100644 --- a/postfix/man/man5/postconf.5 +++ b/postfix/man/man5/postconf.5 @@ -42,6 +42,8 @@ version 2.2 and later. The expression "${name:value}" expands to "value" when "$name" is empty. This form is supported with Postfix version 2.2 and later. +.IP \(bu +Specify "$$" to produce a single "$" character. .RE .IP \(bu When the same parameter is defined multiple times, only the last diff --git a/postfix/proto/postconf.html.prolog b/postfix/proto/postconf.html.prolog index 5b8c4806f..3963e7e6d 100644 --- a/postfix/proto/postconf.html.prolog +++ b/postfix/proto/postconf.html.prolog @@ -53,6 +53,8 @@ recursively replaced by the value of the named parameter.

    "$name" is empty. This form is supported with Postfix version 2.2 and later.

    +
  • Specify "$$" to produce a single "$" character.

    +
  • When the same parameter is defined multiple times, only diff --git a/postfix/proto/postconf.man.prolog b/postfix/proto/postconf.man.prolog index a3f50bf14..37afa4e88 100644 --- a/postfix/proto/postconf.man.prolog +++ b/postfix/proto/postconf.man.prolog @@ -42,6 +42,8 @@ version 2.2 and later. The expression "${name:value}" expands to "value" when "$name" is empty. This form is supported with Postfix version 2.2 and later. +.IP \(bu +Specify "$$" to produce a single "$" character. .RE .IP \(bu When the same parameter is defined multiple times, only the last diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 220e0fc81..7ec6309ed 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,8 +20,8 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20070531" -#define MAIL_VERSION_NUMBER "2.4.3" +#define MAIL_RELEASE_DATE "20070614" +#define MAIL_VERSION_NUMBER "2.4.4-RC1" #ifdef SNAPSHOT # define MAIL_VERSION_DATE "-" MAIL_RELEASE_DATE diff --git a/postfix/src/milter/milter8.c b/postfix/src/milter/milter8.c index 2ccd7e749..a3b2e364e 100644 --- a/postfix/src/milter/milter8.c +++ b/postfix/src/milter/milter8.c @@ -475,6 +475,28 @@ static int milter8_comm_error(MILTER8 *milter) return (milter->state = MILTER8_STAT_ERROR); } +/* milter8_edit_error - local queue file update error */ + +static void milter8_edit_error(MILTER8 *milter, const char *reply) +{ + + /* + * Close the socket, so we don't have to skip pending replies from this + * Milter instance. + */ + if (milter->fp != 0) { + (void) vstream_fclose(milter->fp); + milter->fp = 0; + } + + /* + * Set the socket state to ERROR, so we don't try to send further MTA + * events to this Milter instance. + */ + milter8_def_reply(milter, reply); + milter->state = MILTER8_STAT_ERROR; +} + /* milter8_close_stream - close stream to milter application */ static void milter8_close_stream(MILTER8 *milter) @@ -1002,6 +1024,27 @@ static const char *milter8_event(MILTER8 *milter, int event, msg_info("reply: %s data %ld bytes", (smfir_name = str_name_code(smfir_table, cmd)) != 0 ? smfir_name : "unknown", (long) data_size); + + /* + * Handle unfinished message body replacement first. + */ + if (body_line_buf != 0 && cmd != SMFIR_REPLBODY) { + /* In case the last body replacement line didn't end in CRLF. */ + if (LEN(body_line_buf) > 0) + edit_resp = parent->repl_body(parent->chg_context, + MILTER_BODY_LINE, + body_line_buf); + if (edit_resp == 0) + edit_resp = parent->repl_body(parent->chg_context, + MILTER_BODY_END, + (VSTRING *) 0); + if (edit_resp) { + milter8_edit_error(milter, edit_resp); + MILTER8_EVENT_BREAK(milter->def_reply); + } + vstring_free(body_line_buf); + body_line_buf = 0; + } switch (cmd) { /* @@ -1212,8 +1255,10 @@ static const char *milter8_event(MILTER8 *milter, int event, edit_resp = parent->del_header(parent->chg_context, (ssize_t) index, STR(milter->buf)); - if (edit_resp) - MILTER8_EVENT_BREAK(edit_resp); + if (edit_resp) { + milter8_edit_error(milter, edit_resp); + MILTER8_EVENT_BREAK(milter->def_reply); + } continue; #endif @@ -1229,8 +1274,10 @@ static const char *milter8_event(MILTER8 *milter, int event, edit_resp = parent->add_header(parent->chg_context, STR(milter->buf), STR(milter->body)); - if (edit_resp) - MILTER8_EVENT_BREAK(edit_resp); + if (edit_resp) { + milter8_edit_error(milter, edit_resp); + MILTER8_EVENT_BREAK(milter->def_reply); + } continue; /* @@ -1257,8 +1304,10 @@ static const char *milter8_event(MILTER8 *milter, int event, (ssize_t) index + 1, STR(milter->buf), STR(milter->body)); - if (edit_resp) - MILTER8_EVENT_BREAK(edit_resp); + if (edit_resp) { + milter8_edit_error(milter, edit_resp); + MILTER8_EVENT_BREAK(milter->def_reply); + } continue; #endif @@ -1272,8 +1321,10 @@ static const char *milter8_event(MILTER8 *milter, int event, MILTER8_EVENT_BREAK(milter->def_reply); edit_resp = parent->add_rcpt(parent->chg_context, STR(milter->buf)); - if (edit_resp) - MILTER8_EVENT_BREAK(edit_resp); + if (edit_resp) { + milter8_edit_error(milter, edit_resp); + MILTER8_EVENT_BREAK(milter->def_reply); + } continue; /* @@ -1286,8 +1337,10 @@ static const char *milter8_event(MILTER8 *milter, int event, MILTER8_EVENT_BREAK(milter->def_reply); edit_resp = parent->del_rcpt(parent->chg_context, STR(milter->buf)); - if (edit_resp) - MILTER8_EVENT_BREAK(edit_resp); + if (edit_resp) { + milter8_edit_error(milter, edit_resp); + MILTER8_EVENT_BREAK(milter->def_reply); + } continue; /* @@ -1323,6 +1376,10 @@ static const char *milter8_event(MILTER8 *milter, int event, VSTRING_ADDCH(body_line_buf, ch); } } + if (edit_resp) { + milter8_edit_error(milter, edit_resp); + MILTER8_EVENT_BREAK(milter->def_reply); + } continue; } } @@ -1348,35 +1405,11 @@ static const char *milter8_event(MILTER8 *milter, int event, } /* - * Finish message body replacement. + * Clean up after aborted message body replacement. */ - if (body_line_buf != 0) { - if (edit_resp == 0) { - /* In case the last body replacement line didn't end in CRLF. */ - if (LEN(body_line_buf) > 0) - edit_resp = parent->repl_body(parent->chg_context, - MILTER_BODY_LINE, - body_line_buf); - if (edit_resp == 0) - edit_resp = parent->repl_body(parent->chg_context, - MILTER_BODY_END, - (VSTRING *) 0); - } + if (body_line_buf) vstring_free(body_line_buf); - /* - * Override a non-reject/discard result value after body replacement - * failure. - * - * XXX Some cleanup clients ask the cleanup server to bounce mail for - * them. In that case we must override a hard reject retval result - * after queue file update failure. This is not a big problem; the - * odds are small that a Milter application sends a hard reject after - * replacing the message body. - */ - if (edit_resp && (retval == 0 || strchr("DS4", retval[0]) == 0)) - retval = edit_resp; - } return (retval); }