]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.11.3 v2.11.3
authorWietse Venema <wietse@porcupine.org>
Sun, 19 Oct 2014 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <postfix-users@dukhovni.org>
Mon, 20 Oct 2014 00:11:56 +0000 (20:11 -0400)
postfix/HISTORY
postfix/makedefs
postfix/src/cleanup/cleanup.h
postfix/src/cleanup/cleanup_message.c
postfix/src/cleanup/cleanup_milter.c
postfix/src/cleanup/cleanup_state.c
postfix/src/global/mail_version.h
postfix/src/milter/milter.c
postfix/src/milter/milter.h
postfix/src/milter/milter8.c
postfix/src/smtpd/smtpd.c

index 3ca24d8c40efbd27ece684ea275c9b28dad6774c..268d9d6246107c93980a9cb9758a474e1b59fa40 100644 (file)
@@ -19600,3 +19600,21 @@ Apologies for any names omitted.
        SPF policy plus DKIM Milter.  PREPENDed headers are now
        added BELOW Postfix's own Received: header and remain visible
        to Milters. File: smtpd/smtpd.c.
+
+20141014
+
+       Portability: Darwin 11.x needs to link with -lresolv. Viktor
+       Dukhovni. File: makedefs.
+
+20141018
+
+       Bugfix (introduced: Postfix 2.3): when a Milter inserted a
+       header ABOVE Postfix's own Received: header, Postfix would
+       expose its own Received: header to Milters (violating
+       protocol) and hide the Milter-inserted header from Milters
+       (wtf).  Files: cleanup/cleanup.h, cleanup/cleanup_message.c,
+       cleanup/cleanup_state.c, milter/milter.[hc], milter/milter8.c.
+
+       Cleanup: revert the workaround that places headers inserted
+       with PREPEND actions or policy requests BELOW Postfix's own
+       Received: message header. File: smtpd/smtpd.c.
index dd5f2564ee24108f1b2e09d2a2de1f9d83d00b79..d68fa6cc5a6ef653b4422a4e86ec552737aeca3c 100644 (file)
@@ -491,9 +491,9 @@ ReliantUNIX-?.5.43) SYSTYPE=ReliantUnix543
                     ?.*) CCARGS="$CCARGS -DRESOLVE_H_NEEDS_NAMESER8_COMPAT_H";;
                       *) CCARGS="$CCARGS -DRESOLVE_H_NEEDS_ARPA_NAMESER_COMPAT_H";;
                esac
-               # Darwin 12.x (MacOS X 10.8.x), maybe earlier, needs libresolv.
+               # Darwin 11.x (MacOS X 10.7.x), maybe earlier, needs libresolv.
                case $RELEASE in
-           ?.*|1[0-1].*) ;;
+               ?.*|10.*) ;;
                       *) SYSLIBS="$SYSLIBS -lresolv";;
                esac
                # kqueue and/or poll are broken in MacOS X 10.5 (Darwin 9).
index eca0785c6a77b9494d2fea8c8030312208fd991a..10d40abe8bdbeb17e49cd4128415c2f466a03405 100644 (file)
@@ -61,6 +61,7 @@ typedef struct CLEANUP_STATE {
     char   *orig_rcpt;                 /* original recipient address */
     char   *return_receipt;            /* return-receipt address */
     char   *errors_to;                 /* errors-to address */
+    ARGV   *auto_hdrs;                 /* MTA's own header(s) */
     int     flags;                     /* processing options, status flags */
     int     qmgr_opts;                 /* qmgr processing options */
     int     errs;                      /* any badness experienced */
index aa1fe6c5bbb36f180d19339867258c1674cdd3d2..cde3b7c932ac3917f6fb36fd5ec04b65a435476c 100644 (file)
@@ -479,6 +479,10 @@ static void cleanup_header_callback(void *context, int header_class,
     if (hdr_opts && (hdr_opts->flags & HDR_OPT_MIME))
        header_class = MIME_HDR_MULTIPART;
 
+    /* Update the Received: header count before maybe dropping headers below. */
+    if (hdr_opts && hdr_opts->type == HDR_RECEIVED)
+       state->hop_count += 1;
+
     if ((state->flags & CLEANUP_FLAG_FILTER)
        && (CHECK(MIME_HDR_PRIMARY, cleanup_header_checks, VAR_HEADER_CHECKS)
     || CHECK(MIME_HDR_MULTIPART, cleanup_mimehdr_checks, VAR_MIMEHDR_CHECKS)
@@ -579,9 +583,13 @@ static void cleanup_header_callback(void *context, int header_class,
            msg_info("%s: message-id=%s", state->queue_id, hdrval);
        if (hdr_opts->type == HDR_RESENT_MESSAGE_ID)
            msg_info("%s: resent-message-id=%s", state->queue_id, hdrval);
-       if (hdr_opts->type == HDR_RECEIVED)
-           if (++state->hop_count >= var_hopcount_limit)
+       if (hdr_opts->type == HDR_RECEIVED) {
+           if (state->hop_count >= var_hopcount_limit)
                state->errs |= CLEANUP_STAT_HOPS;
+           /* Save our Received: header after maybe updating headers above. */
+           if (state->hop_count == 1)
+               argv_add(state->auto_hdrs, vstring_str(header_buf), ARGV_END);
+       }
        if (CLEANUP_OUT_OK(state)) {
            if (hdr_opts->flags & HDR_OPT_RR)
                state->resent = "Resent-";
index db38c911f10dc06d731f4a03e7d7ac839b2f4129..2894fa011ff29ba095238098ff6e1bedd0755fc2 100644 (file)
@@ -2020,7 +2020,7 @@ void    cleanup_milter_inspect(CLEANUP_STATE *state, MILTERS *milters)
      * filter library.
      */
     if ((resp = milter_message(milters, state->handle->stream,
-                              state->data_offset)) != 0)
+                              state->data_offset, state->auto_hdrs)) != 0)
        cleanup_milter_apply(state, "END-OF-MESSAGE", resp);
 
     /*
index 50e90f158f0042172063828cb0a6d4559a72ddf4..563ea1c5ed7db30463a434b37a31185f7961b098 100644 (file)
@@ -78,6 +78,7 @@ CLEANUP_STATE *cleanup_state_alloc(VSTREAM *src)
     state->orig_rcpt = 0;
     state->return_receipt = 0;
     state->errors_to = 0;
+    state->auto_hdrs = argv_alloc(1);
     state->flags = 0;
     state->qmgr_opts = 0;
     state->errs = 0;
@@ -151,6 +152,7 @@ void    cleanup_state_free(CLEANUP_STATE *state)
        myfree(state->return_receipt);
     if (state->errors_to)
        myfree(state->errors_to);
+    argv_free(state->auto_hdrs);
     if (state->queue_name)
        myfree(state->queue_name);
     if (state->queue_id)
index 9a3f2c6af5acd6afcc7d41931b084f7a91348a34..1754f3bbf61399ec959ad71d398cb713031bfdf4 100644 (file)
@@ -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      "20141013"
-#define MAIL_VERSION_NUMBER    "2.11.2"
+#define MAIL_RELEASE_DATE      "20141019"
+#define MAIL_VERSION_NUMBER    "2.11.3"
 
 #ifdef SNAPSHOT
 #define MAIL_VERSION_DATE      "-" MAIL_RELEASE_DATE
index f912add48cc8c872081dd1b1083a90a7136b0ade..5e310d7f37e1596b0e4032cea2d219189f62482b 100644 (file)
 /*     const char *milter_other_event(milters)
 /*     MILTERS *milters;
 /*
-/*     const char *milter_message(milters, qfile, data_offset)
+/*     const char *milter_message(milters, qfile, data_offset, auto_hdrs)
 /*     MILTERS *milters;
 /*     VSTREAM *qfile;
 /*     off_t   data_offset;
+/*     ARGV    *auto_hdrs;
 /*
 /*     const char *milter_abort(milters)
 /*     MILTERS *milters;
@@ -481,7 +482,8 @@ const char *milter_other_event(MILTERS *milters)
 
 /* milter_message - inspect message content */
 
-const char *milter_message(MILTERS *milters, VSTREAM *fp, off_t data_offset)
+const char *milter_message(MILTERS *milters, VSTREAM *fp, off_t data_offset,
+                                  ARGV *auto_hdrs)
 {
     const char *resp;
     MILTER *m;
@@ -495,7 +497,8 @@ const char *milter_message(MILTERS *milters, VSTREAM *fp, off_t data_offset)
     for (resp = 0, m = milters->milter_list; resp == 0 && m != 0; m = m->next) {
        any_eoh_macros = MILTER_MACRO_EVAL(global_eoh_macros, m, milters, eoh_macros);
        any_eod_macros = MILTER_MACRO_EVAL(global_eod_macros, m, milters, eod_macros);
-       resp = m->message(m, fp, data_offset, any_eoh_macros, any_eod_macros);
+       resp = m->message(m, fp, data_offset, any_eoh_macros, any_eod_macros,
+                         auto_hdrs);
        if (any_eoh_macros != global_eoh_macros)
            argv_free(any_eoh_macros);
        if (any_eod_macros != global_eod_macros)
index 17d163dc42a3d0c42bea40736e5c087b6b0d56d5..bf25fccc040ef9b08832f9be6c98a5c02e1926cd 100644 (file)
@@ -40,7 +40,7 @@ typedef struct MILTER {
     const char *(*mail_event) (struct MILTER *, const char **, ARGV *);
     const char *(*rcpt_event) (struct MILTER *, const char **, ARGV *);
     const char *(*data_event) (struct MILTER *, ARGV *);
-    const char *(*message) (struct MILTER *, VSTREAM *, off_t, ARGV *, ARGV *);
+    const char *(*message) (struct MILTER *, VSTREAM *, off_t, ARGV *, ARGV *, ARGV *);
     const char *(*unknown_event) (struct MILTER *, const char *, ARGV *);
     const char *(*other_event) (struct MILTER *);
     void    (*abort) (struct MILTER *);
@@ -136,7 +136,7 @@ extern const char *milter_helo_event(MILTERS *, const char *, int);
 extern const char *milter_mail_event(MILTERS *, const char **);
 extern const char *milter_rcpt_event(MILTERS *, int, const char **);
 extern const char *milter_data_event(MILTERS *);
-extern const char *milter_message(MILTERS *, VSTREAM *, off_t);
+extern const char *milter_message(MILTERS *, VSTREAM *, off_t, ARGV *);
 extern const char *milter_unknown_event(MILTERS *, const char *);
 extern const char *milter_other_event(MILTERS *);
 extern void milter_abort(MILTERS *);
index 5941c5aa6da15e5ead6cf3ff16aed6fa933e75dd..3c5a48ff24d6712f1c34b13f5916a19fe7b875f6 100644 (file)
@@ -2285,6 +2285,8 @@ typedef struct {
     MILTER8 *milter;                   /* milter client */
     ARGV   *eoh_macros;                        /* end-of-header macros */
     ARGV   *eod_macros;                        /* end-of-body macros */
+    ARGV   *auto_hdrs;                 /* auto-generated headers */
+    int     auto_done;                 /* good enough for now */
     int     first_header;              /* first header */
     int     first_body;                        /* first body line */
     const char *resp;                  /* milter application response */
@@ -2301,6 +2303,8 @@ static void milter8_header(void *ptr, int unused_header_class,
     MILTER8 *milter = msg_ctx->milter;
     char   *cp;
     int     skip_reply;
+    char  **cpp;
+    unsigned done;
 
     /*
      * XXX Workaround: mime_state_update() may invoke multiple call-backs
@@ -2329,10 +2333,11 @@ static void milter8_header(void *ptr, int unused_header_class,
      * XXX Sendmail compatibility. It eats the first space (not tab) after the
      * header label and ":".
      */
-    if (msg_ctx->first_header) {
-       msg_ctx->first_header = 0;
-       return;
-    }
+    for (cpp = msg_ctx->auto_hdrs->argv, done = 1; *cpp; cpp++, done <<= 1)
+       if ((msg_ctx->auto_done & done) == 0 && strcmp(*cpp, STR(buf)) == 0) {
+           msg_ctx->auto_done |= done;
+           return;
+       }
 
     /*
      * Sendmail 8 sends multi-line headers as text separated by newline.
@@ -2507,7 +2512,8 @@ static void milter8_eob(void *ptr)
 static const char *milter8_message(MILTER *m, VSTREAM *qfile,
                                           off_t data_offset,
                                           ARGV *eoh_macros,
-                                          ARGV *eod_macros)
+                                          ARGV *eod_macros,
+                                          ARGV *auto_hdrs)
 {
     const char *myname = "milter8_message";
     MILTER8 *milter = (MILTER8 *) m;
@@ -2541,6 +2547,8 @@ static const char *milter8_message(MILTER *m, VSTREAM *qfile,
        msg_ctx.milter = milter;
        msg_ctx.eoh_macros = eoh_macros;
        msg_ctx.eod_macros = eod_macros;
+       msg_ctx.auto_hdrs = auto_hdrs;
+       msg_ctx.auto_done = 0;
        msg_ctx.first_header = 1;
        msg_ctx.first_body = 1;
        msg_ctx.resp = 0;
index 7aa69f6c2b55e61b22bb02c3c490e736dd8261c4..1c4b9ede8be06ad13f5e54723695e0a93ea787d0 100644 (file)
@@ -2984,6 +2984,13 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
        rec_fputs(state->cleanup, REC_TYPE_MESG, "");
     }
 
+    /*
+     * PREPEND message headers above our own Received: header.
+     */
+    if (state->prepend)
+       for (cpp = state->prepend->argv; *cpp; cpp++)
+           out_fprintf(out_stream, REC_TYPE_NORM, "%s", *cpp);
+
     /*
      * Suppress our own Received: header in the unlikely case that we are an
      * intermediate proxy.
@@ -3074,17 +3081,6 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
 #endif
     }
 
-    /*
-     * PREPEND message headers below our own Received: header. According
-     * https://www.milter.org/developers/api/smfi_insheader, Milters see only
-     * headers that have been sent by the SMTP client and those header
-     * modifications by earlier filters. Based on this we allow Milters to
-     * see headers added by access map or by policy service.
-     */
-    if (state->prepend)
-       for (cpp = state->prepend->argv; *cpp; cpp++)
-           out_fprintf(out_stream, REC_TYPE_NORM, "%s", *cpp);
-
     smtpd_chat_reply(state, "354 End data with <CR><LF>.<CR><LF>");
     state->where = SMTPD_AFTER_DATA;