]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.11-20131126
authorWietse Venema <wietse@porcupine.org>
Tue, 26 Nov 2013 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <postfix-users@dukhovni.org>
Wed, 27 Nov 2013 01:49:28 +0000 (20:49 -0500)
postfix/HISTORY
postfix/mantools/ccformat
postfix/src/cleanup/Makefile.in
postfix/src/cleanup/cleanup.h
postfix/src/cleanup/cleanup_milter.c
postfix/src/cleanup/cleanup_state.c
postfix/src/global/mail_version.h
postfix/src/global/xtext.c
postfix/src/global/xtext.h
postfix/src/milter/test-milter.c

index 5b94ef6ced618a2038a47386b02becb433bc5018..3e1e222496ae65cb21fba1522443444a6a96ebc3 100644 (file)
@@ -19217,10 +19217,24 @@ Apologies for any names omitted.
        html/Makefile.in, man/Makefile.in, proto/DATABASE_README.html,
        postconf/postconf.c, proto/socketmap_table, proto/lmdb_table.
 
-20121122
+20131122
 
        Documentation: missing database hyperlinks, refined text
        about partial lookup keys. Files: mantools/postlink,
        proto/DATABASE_README.html, proto/lmdb_table,
        proto/socketmap_table.
 
+20131123
+
+       Feature: support for NOTIFY parameter in the Milter
+       SMFIR_ADDRCPT_PAR request. Contributed by by Andrew Ayer.
+       Wietse added support for ORCPT.  Files: cleanup/cleanup.h,
+       cleanup/cleanup_milter.c, cleanup/cleanup_state.c,
+       global/xtext.c, global/xtext.h, milter/test-milter.c.
+
+20131124
+
+       Cleanup: remove extra blank line from ccformat output,
+       making it compatible with the script that Wietse actually
+       uses (this line was part of a test to detect file truncation,
+       but it is now obsolete).  File: mantools/ccformat.
index 3573a6dc8f32c5ef52dcc52c52ce0bc8b5390962..c9ec6aeb629450d774380c411ece21d0017701e6 100755 (executable)
@@ -64,7 +64,8 @@ case $# in
            { # some versions of indent return garbage exit status -- gack!
            (indent $FLAGS <$i 2>.ind.$$ >$TMPF || test ! -s .ind.$$) >$TMPF &&
            # try a device full check
-           echo >>$TMPF && (
+           # echo >>$TMPF && 
+           (
                # ignore interrupts while we overwrite the original file
                trap '' 1 2 3 15; cp $TMPF $i 
            ) && echo replaced; } || { echo replacement FAILED; exit 1; }
index 28afe9df65c668f57a764ed658ef481d27aabeee..289cea2629c50f48df7dfd8f0661809944506e0b 100644 (file)
@@ -1024,6 +1024,7 @@ cleanup_milter.o: ../../include/tok822.h
 cleanup_milter.o: ../../include/vbuf.h
 cleanup_milter.o: ../../include/vstream.h
 cleanup_milter.o: ../../include/vstring.h
+cleanup_milter.o: ../../include/xtext.h
 cleanup_milter.o: cleanup.h
 cleanup_milter.o: cleanup_milter.c
 cleanup_out.o: ../../include/argv.h
index 9b9d6279d2a92b775636a6d704c8e4b245428c3b..eca0785c6a77b9494d2fea8c8030312208fd991a 100644 (file)
@@ -114,6 +114,7 @@ typedef struct CLEANUP_STATE {
     VSTRING *milter_err_text;          /* milter call-back reply */
     HBC_CHECKS *milter_hbc_checks;     /* Milter header checks */
     VSTRING *milter_hbc_reply;         /* Milter header checks reply */
+    VSTRING *milter_orcpt_buf;         /* add_rcpt_par() orcpt */
 
     /*
      * Support for Milter body replacement requests.
index e6a74e84d881dbe448cdcc340bf24a9673d2188f..db38c911f10dc06d731f4a03e7d7ac839b2f4129 100644 (file)
 #include <is_header.h>
 #include <quote_821_local.h>
 #include <dsn_util.h>
+#include <xtext.h>
 
 /* Application-specific. */
 
@@ -1388,9 +1389,10 @@ static const char *cleanup_chg_from(void *context, const char *ext_from,
     return (CLEANUP_OUT_OK(state) ? 0 : cleanup_milter_error(state, 0));
 }
 
-/* cleanup_add_rcpt - append recipient address */
+/* cleanup_add_rcpt_par - append recipient address, with ESMTP arguments */
 
-static const char *cleanup_add_rcpt(void *context, const char *ext_rcpt)
+static const char *cleanup_add_rcpt_par(void *context, const char *ext_rcpt,
+                                               const char *esmtp_args)
 {
     const char *myname = "cleanup_add_rcpt";
     CLEANUP_STATE *state = (CLEANUP_STATE *) context;
@@ -1400,7 +1402,45 @@ static const char *cleanup_add_rcpt(void *context, const char *ext_rcpt)
     TOK822 *tree;
     TOK822 *tp;
     VSTRING *int_rcpt_buf;
-
+    ARGV   *esmtp_argv;
+    int     dsn_notify = 0;
+    const char *dsn_orcpt_info = 0;
+    size_t  type_len;
+    int     i;
+    const char *arg;
+    const char *arg_val;
+
+    if (esmtp_args[0]) {
+       esmtp_argv = argv_split(esmtp_args, " ");
+       for (i = 0; i < esmtp_argv->argc; ++i) {
+           arg = esmtp_argv->argv[i];
+           if (strncasecmp(arg, "NOTIFY=", 7) == 0) {  /* RFC 3461 */
+               if (dsn_notify || (dsn_notify = dsn_notify_mask(arg + 7)) == 0)
+                   msg_warn("%s: Bad NOTIFY parameter from MILTER: \"%.100s\"",
+                            state->queue_id, arg);
+           } else if (strncasecmp(arg, "ORCPT=", 6) == 0) {    /* RFC 3461 */
+               if (state->milter_orcpt_buf == 0)
+                   state->milter_orcpt_buf = vstring_alloc(100);
+               if (dsn_orcpt_info
+                   || (type_len = strcspn(arg_val = arg + 6, ";")) == 0
+                   || (arg_val)[type_len] != ';'
+                   || xtext_unquote_append(
+                                   vstring_sprintf(state->milter_orcpt_buf,
+                                                   "%.*s;", (int) type_len,
+                                                   arg_val),
+                                           arg_val + type_len + 1) == 0) {
+                   msg_warn("%s: Bad ORCPT parameter from MILTER: \"%.100s\"",
+                            state->queue_id, arg);
+               } else {
+                   dsn_orcpt_info = STR(state->milter_orcpt_buf);
+               }
+           } else {
+               msg_warn("%s: ignoring ESMTP argument from MILTER: \"%.100s\"",
+                        state->queue_id, arg);
+           }
+       }
+       argv_free(esmtp_argv);
+    }
     if (msg_verbose)
        msg_info("%s: \"%s\"", myname, ext_rcpt);
 
@@ -1426,8 +1466,6 @@ static const char *cleanup_add_rcpt(void *context, const char *ext_rcpt)
      * overwrite the old "recipient append" pointer with the forward pointer
      * to the new recipient.
      */
-#define NO_DSN_ORCPT   ((char *) 0)
-
     if ((new_rcpt_offset = vstream_fseek(state->dst, (off_t) 0, SEEK_END)) < 0) {
        msg_warn("%s: seek file %s: %m", myname, cleanup_path);
        return (cleanup_milter_error(state, errno));
@@ -1454,7 +1492,8 @@ static const char *cleanup_add_rcpt(void *context, const char *ext_rcpt)
        }
     }
     tok822_free_tree(tree);
-    cleanup_addr_bcc_dsn(state, STR(int_rcpt_buf), NO_DSN_ORCPT, DEF_DSN_NOTIFY);
+    cleanup_addr_bcc_dsn(state, STR(int_rcpt_buf), dsn_orcpt_info,
+                        dsn_notify ? dsn_notify : DEF_DSN_NOTIFY);
     vstring_free(int_rcpt_buf);
     if (addr_count == 0) {
        msg_warn("%s: ignoring attempt from Milter to add null recipient",
@@ -1494,18 +1533,11 @@ static const char *cleanup_add_rcpt(void *context, const char *ext_rcpt)
     return (CLEANUP_OUT_OK(state) ? 0 : cleanup_milter_error(state, 0));
 }
 
-/* cleanup_add_rcpt_par - append recipient address, ignore ESMTP arguments */
+/* cleanup_add_rcpt - append recipient address */
 
-static const char *cleanup_add_rcpt_par(void *context, const char *ext_rcpt,
-                                               const char *esmtp_args)
+static const char *cleanup_add_rcpt(void *context, const char *ext_rcpt)
 {
-    const char *myname = "cleanup_add_rcpt";
-    CLEANUP_STATE *state = (CLEANUP_STATE *) context;
-
-    if (esmtp_args[0])
-       msg_warn("%s: %s: ignoring ESMTP arguments \"%.100s\"",
-                state->queue_id, myname, esmtp_args);
-    return (cleanup_add_rcpt(context, ext_rcpt));
+    return (cleanup_add_rcpt_par(context, ext_rcpt, ""));
 }
 
 /* cleanup_del_rcpt - remove recipient and all its expansions */
index 8d9085262a68fd490cc794405b121da24b4af63e..50e90f158f0042172063828cb0a6d4559a72ddf4 100644 (file)
@@ -101,6 +101,7 @@ CLEANUP_STATE *cleanup_state_alloc(VSTREAM *src)
     state->append_meta_pt_target = -1;
     state->milter_hbc_checks = 0;
     state->milter_hbc_reply = 0;
+    state->milter_orcpt_buf = 0;
     state->rcpt_count = 0;
     state->reason = 0;
     state->smtp_reply = 0;
@@ -159,6 +160,8 @@ void    cleanup_state_free(CLEANUP_STATE *state)
        myfree(state->reason);
     if (state->smtp_reply)
        myfree(state->smtp_reply);
+    if (state->milter_orcpt_buf)
+       vstring_free(state->milter_orcpt_buf);
     nvtable_free(state->attr);
     if (state->mime_state)
        mime_state_free(state->mime_state);
index 10cbb6eb2a3567b50ef9e97d3545ce946815695b..00973bb0198e31632e8b3c5599443d496c79c4c0 100644 (file)
@@ -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      "20131122"
+#define MAIL_RELEASE_DATE      "20131126"
 #define MAIL_VERSION_NUMBER    "2.11"
 
 #ifdef SNAPSHOT
index 3bcb8c3d462d32330c57294ef9eda2d1685565a1..4e73733443c61c248e0986a6247afb7beba7e468 100644 (file)
 /*     VSTRING *xtext_unquote(unquoted, quoted)
 /*     VSTRING *unquoted;
 /*     const char *quoted;
+/*
+/*     VSTRING *xtext_unquote_append(unquoted, quoted)
+/*     VSTRING *unquoted;
+/*     const char *quoted;
 /* DESCRIPTION
 /*     xtext_quote() takes a null-terminated string and replaces characters
 /*     +, <33(10) and >126(10), as well as characters specified with "special"
@@ -31,6 +35,9 @@
 /*     understands lowercase, uppercase, and mixed case +XX sequences. The
 /*     result value is the unquoted argument in case of success, a null pointer
 /*     otherwise.
+/*
+/*     xtext_unquote_append() is like xtext_unquote(), but appends
+/*     the conversion result to the result buffer.
 /* BUGS
 /*     This module cannot process null characters in data.
 /* LICENSE
@@ -90,14 +97,13 @@ VSTRING *xtext_quote(VSTRING *quoted, const char *unquoted, const char *special)
     return (quoted);
 }
 
-/* xtext_unquote - quoted data to unquoted */
+/* xtext_unquote_append - quoted data to unquoted */
 
-VSTRING *xtext_unquote(VSTRING *unquoted, const char *quoted)
+VSTRING *xtext_unquote_append(VSTRING *unquoted, const char *quoted)
 {
     const char *cp;
     int     ch;
 
-    VSTRING_RESET(unquoted);
     for (cp = quoted; (ch = *cp) != 0; cp++) {
        if (ch == '+') {
            if (ISDIGIT(cp[1]))
@@ -123,6 +129,14 @@ VSTRING *xtext_unquote(VSTRING *unquoted, const char *quoted)
     VSTRING_TERMINATE(unquoted);
     return (unquoted);
 }
+/* xtext_unquote - quoted data to unquoted */
+
+VSTRING *xtext_unquote(VSTRING *unquoted, const char *quoted)
+{
+    VSTRING_RESET(unquoted);
+    xtext_unquote_append(unquoted, quoted);
+    return (unquoted);
+}
 
 #ifdef TEST
 
index 1515242d32ada4d7f57e349cdd3bcc6f723f3112..c7680622df73529dd301064e59e7e9c173ab1602 100644 (file)
@@ -22,6 +22,7 @@
 extern VSTRING *xtext_quote(VSTRING *, const char *, const char *);
 extern VSTRING *xtext_quote_append(VSTRING *, const char *, const char *);
 extern VSTRING *xtext_unquote(VSTRING *, const char *);
+extern VSTRING *xtext_unquote_append(VSTRING *, const char *);
 
 /* LICENSE
 /* .ad
index 26be0f7c222c7ef6ec6bdf2162c9fbc693eb0a94..a89ae34fffb4128e160e3ba66307ece48beabce0 100644 (file)
@@ -20,8 +20,8 @@
 /*     Specifies a non-default reply for the MTA command specified
 /*     with \fB-c\fR. The default is \fBtempfail\fR.
 /* .IP "\fB-A address\fR"
-/*     Add the specified recipient address. Multiple -A options
-/*     are supported.
+/*     Add the specified recipient address (specify ESMTP parameters
+/*     separated by space). Multiple -A options are supported.
 /* .IP "\fB-b pathname
 /*     Replace the message body by the content of the specified file.
 /* .IP "\fB-c connect|helo|mail|rcpt|data|header|eoh|body|eom|unknown|close|abort\fR"
@@ -358,10 +358,20 @@ static sfsistat test_eom(SMFICTX *ctx)
 #endif
     {
        int     count;
-
-       for (count = 0; count < add_rcpt_count; count++)
-           if (smfi_addrcpt(ctx, add_rcpt[count]) == MI_FAILURE)
-               fprintf(stderr, "smfi_addrcpt `%s' failed\n", add_rcpt[count]);
+       char *args;
+
+       for (count = 0; count < add_rcpt_count; count++) {
+           if ((args = strchr(add_rcpt[count], ' ')) != 0) {
+               *args++ = 0;
+               if (smfi_addrcpt_par(ctx, add_rcpt[count], args) == MI_FAILURE)
+                   fprintf(stderr, "smfi_addrcpt_par `%s' `%s' failed\n",
+                           add_rcpt[count], args);
+           } else {
+               if (smfi_addrcpt(ctx, add_rcpt[count]) == MI_FAILURE)
+                   fprintf(stderr, "smfi_addrcpt `%s' failed\n",
+                           add_rcpt[count]);
+           }
+       }
 
        for (count = 0; count < del_rcpt_count; count++)
            if (smfi_delrcpt(ctx, del_rcpt[count]) == MI_FAILURE)