From: Wietse Venema Date: Mon, 28 Nov 2005 05:00:00 +0000 (-0500) Subject: postfix-2.3-20051128 X-Git-Tag: v2.3-RC1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65d3673b7268be8a38acc5995035fb7da9360c92;p=thirdparty%2Fpostfix.git postfix-2.3-20051128 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 4faa2d5e1..7dfc871a4 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -11466,6 +11466,15 @@ Apologies for any names omitted. Log warning when REDIRECT or FILTER are used in smtpd_etrn_restrictions. File: smtpd/smtpd_check.c. +20051128 + + Bugfix: moved code around from one place to another to make + REDIRECT, FILTER, HOLD and DISCARD access(5) table actions + work in smtpd_end_of_data_restrictions. PREPEND will not + be fixed; it must be specified before the message content + is received. Files: smtpd/smtpd.c, smtpd/smtpd_check.c, + cleanup/cleanup_extracted.c, pickup/pickup.c. + Open problems: "postsuper -r" no longer resets the message arrival time, diff --git a/postfix/conf/access b/postfix/conf/access index af9435ee3..bacefdaa6 100644 --- a/postfix/conf/access +++ b/postfix/conf/access @@ -221,7 +221,7 @@ # transport(5) table to direct mail to the discard(8) # service. # -# Note: this action currently does not work in +# Note: this action does not work in Postfix 2.2 # smtpd_end_of_data_restrictions. # # This feature is available in Postfix 2.0 and later. @@ -245,7 +245,7 @@ # tent_filter setting, and currently affects all # recipients of the message. # -# Note: this action currently does not work in +# Note: this action does not work in Postfix 2.2 # smtpd_end_of_data_restrictions. # # This feature is available in Postfix 2.0 and later. @@ -268,7 +268,7 @@ # Note: this action currently affects all recipients # of the message. # -# Note: this action currently does not work in +# Note: this action does not work in Postfix 2.2 # smtpd_end_of_data_restrictions. # # This feature is available in Postfix 2.0 and later. @@ -282,6 +282,10 @@ # Note: this action does not support multi-line mes- # sage headers. # +# Note: this action must be used before the message +# content is received; it cannot be used in +# smtpd_end_of_data_restrictions. +# # This feature is available in Postfix 2.1 and later. # # REDIRECT user@domain @@ -292,7 +296,7 @@ # Note: this action overrides the FILTER action, and # currently affects all recipients of the message. # -# Note: this action currently does not work in +# Note: this action does not work in Postfix 2.2 # smtpd_end_of_data_restrictions. # # This feature is available in Postfix 2.1 and later. diff --git a/postfix/html/access.5.html b/postfix/html/access.5.html index a9ec6353e..3890e73a9 100644 --- a/postfix/html/access.5.html +++ b/postfix/html/access.5.html @@ -227,7 +227,7 @@ ACCESS(5) ACCESS(5) transport(5) table to direct mail to the discard(8) service. - Note: this action currently does not work in + Note: this action does not work in Postfix 2.2 smtpd_end_of_data_restrictions. This feature is available in Postfix 2.0 and later. @@ -251,7 +251,7 @@ ACCESS(5) ACCESS(5) tent_filter setting, and currently affects all recipients of the message. - Note: this action currently does not work in + Note: this action does not work in Postfix 2.2 smtpd_end_of_data_restrictions. This feature is available in Postfix 2.0 and later. @@ -274,7 +274,7 @@ ACCESS(5) ACCESS(5) Note: this action currently affects all recipients of the message. - Note: this action currently does not work in + Note: this action does not work in Postfix 2.2 smtpd_end_of_data_restrictions. This feature is available in Postfix 2.0 and later. @@ -288,6 +288,10 @@ ACCESS(5) ACCESS(5) Note: this action does not support multi-line mes- sage headers. + Note: this action must be used before the message + content is received; it cannot be used in + smtpd_end_of_data_restrictions. + This feature is available in Postfix 2.1 and later. REDIRECT user@domain @@ -298,7 +302,7 @@ ACCESS(5) ACCESS(5) Note: this action overrides the FILTER action, and currently affects all recipients of the message. - Note: this action currently does not work in + Note: this action does not work in Postfix 2.2 smtpd_end_of_data_restrictions. This feature is available in Postfix 2.1 and later. diff --git a/postfix/html/smtpd.8.html b/postfix/html/smtpd.8.html index 9509bc555..15a9c85ce 100644 --- a/postfix/html/smtpd.8.html +++ b/postfix/html/smtpd.8.html @@ -599,7 +599,7 @@ SMTPD(8) SMTPD(8) delivering mail. smtpd_error_sleep_time (1s) - With Postfix 2.1 and later: the SMTP server + With Postfix version 2.1 and later: the SMTP server response delay after a client has made more than $smtpd_soft_error_limit errors, and fewer than $smtpd_hard_error_limit errors, without delivering diff --git a/postfix/man/man5/access.5 b/postfix/man/man5/access.5 index 496f58a26..8f7df2a13 100644 --- a/postfix/man/man5/access.5 +++ b/postfix/man/man5/access.5 @@ -212,7 +212,7 @@ Note: this action currently affects all recipients of the message. To discard only one recipient without discarding the entire message, use the transport(5) table to direct mail to the discard(8) service. .sp -Note: this action currently does not work in +Note: this action does not work in Postfix 2.2 \fBsmtpd_end_of_data_restrictions\fR. .sp This feature is available in Postfix 2.0 and later. @@ -232,7 +232,7 @@ about external content filters is in the Postfix FILTER_README file. Note: this action overrides the \fBmain.cf content_filter\fR setting, and currently affects all recipients of the message. .sp -Note: this action currently does not work in +Note: this action does not work in Postfix 2.2 \fBsmtpd_end_of_data_restrictions\fR. .sp This feature is available in Postfix 2.0 and later. @@ -252,7 +252,7 @@ or \fB$bounce_queue_lifetime\fR, or longer. .sp Note: this action currently affects all recipients of the message. .sp -Note: this action currently does not work in +Note: this action does not work in Postfix 2.2 \fBsmtpd_end_of_data_restrictions\fR. .sp This feature is available in Postfix 2.0 and later. @@ -263,6 +263,9 @@ header appears before the second etc. prepended header. .sp Note: this action does not support multi-line message headers. .sp +Note: this action must be used before the message content +is received; it cannot be used in \fBsmtpd_end_of_data_restrictions\fR. +.sp This feature is available in Postfix 2.1 and later. .IP "\fBREDIRECT \fIuser@domain\fR" After the message is queued, send the message to the specified @@ -271,7 +274,7 @@ address instead of the intended recipient(s). Note: this action overrides the FILTER action, and currently affects all recipients of the message. .sp -Note: this action currently does not work in +Note: this action does not work in Postfix 2.2 \fBsmtpd_end_of_data_restrictions\fR. .sp This feature is available in Postfix 2.1 and later. diff --git a/postfix/man/man8/smtpd.8 b/postfix/man/man8/smtpd.8 index 19ea129ce..16de5979e 100644 --- a/postfix/man/man8/smtpd.8 +++ b/postfix/man/man8/smtpd.8 @@ -495,7 +495,7 @@ run-away software. The behavior is controlled by an error counter that counts the number of errors within an SMTP session that a client makes without delivering mail. .IP "\fBsmtpd_error_sleep_time (1s)\fR" -With Postfix 2.1 and later: the SMTP server response delay after +With Postfix version 2.1 and later: the SMTP server response delay after a client has made more than $smtpd_soft_error_limit errors, and fewer than $smtpd_hard_error_limit errors, without delivering mail. .IP "\fBsmtpd_soft_error_limit (10)\fR" diff --git a/postfix/proto/access b/postfix/proto/access index c6a1d97ae..289b68f11 100644 --- a/postfix/proto/access +++ b/postfix/proto/access @@ -192,7 +192,7 @@ # To discard only one recipient without discarding the entire message, # use the transport(5) table to direct mail to the discard(8) service. # .sp -# Note: this action currently does not work in +# Note: this action does not work in Postfix 2.2 # \fBsmtpd_end_of_data_restrictions\fR. # .sp # This feature is available in Postfix 2.0 and later. @@ -212,7 +212,7 @@ # Note: this action overrides the \fBmain.cf content_filter\fR setting, # and currently affects all recipients of the message. # .sp -# Note: this action currently does not work in +# Note: this action does not work in Postfix 2.2 # \fBsmtpd_end_of_data_restrictions\fR. # .sp # This feature is available in Postfix 2.0 and later. @@ -232,7 +232,7 @@ # .sp # Note: this action currently affects all recipients of the message. # .sp -# Note: this action currently does not work in +# Note: this action does not work in Postfix 2.2 # \fBsmtpd_end_of_data_restrictions\fR. # .sp # This feature is available in Postfix 2.0 and later. @@ -243,6 +243,9 @@ # .sp # Note: this action does not support multi-line message headers. # .sp +# Note: this action must be used before the message content +# is received; it cannot be used in \fBsmtpd_end_of_data_restrictions\fR. +# .sp # This feature is available in Postfix 2.1 and later. # .IP "\fBREDIRECT \fIuser@domain\fR" # After the message is queued, send the message to the specified @@ -251,7 +254,7 @@ # Note: this action overrides the FILTER action, and currently affects # all recipients of the message. # .sp -# Note: this action currently does not work in +# Note: this action does not work in Postfix 2.2 # \fBsmtpd_end_of_data_restrictions\fR. # .sp # This feature is available in Postfix 2.1 and later. diff --git a/postfix/src/cleanup/cleanup_envelope.c b/postfix/src/cleanup/cleanup_envelope.c index 3d9b2da7b..002d14f7c 100644 --- a/postfix/src/cleanup/cleanup_envelope.c +++ b/postfix/src/cleanup/cleanup_envelope.c @@ -123,7 +123,7 @@ static void cleanup_envelope_process(CLEANUP_STATE *state, int type, if (type == REC_TYPE_FLGS) { /* Not part of queue file format. */ - extra_opts = atol(buf); + extra_opts = atoi(buf); if (extra_opts & ~CLEANUP_FLAG_MASK_EXTRA) msg_warn("%s: ignoring bad extra flags: 0x%x", state->queue_id, extra_opts); diff --git a/postfix/src/cleanup/cleanup_extracted.c b/postfix/src/cleanup/cleanup_extracted.c index 4746b214e..30ca702d5 100644 --- a/postfix/src/cleanup/cleanup_extracted.c +++ b/postfix/src/cleanup/cleanup_extracted.c @@ -99,18 +99,26 @@ void cleanup_extracted_process(CLEANUP_STATE *state, int type, const char *buf, ssize_t len) { const char *encoding; - const char generated_by_cleanup[] = { - REC_TYPE_FILT, REC_TYPE_RDR, REC_TYPE_ATTR, - REC_TYPE_RRTO, REC_TYPE_ERTO, 0, - }; char *attr_name; char *attr_value; const char *error_text; + int extra_opts; int junk; if (msg_verbose) msg_info("extracted envelope %c %.*s", type, (int) len, buf); + if (type == REC_TYPE_FLGS) { + /* Not part of queue file format. */ + extra_opts = atoi(buf); + if (extra_opts & ~CLEANUP_FLAG_MASK_EXTRA) + msg_warn("%s: ignoring bad extra flags: 0x%x", + state->queue_id, extra_opts); + else + state->flags |= extra_opts; + return; + } + if (strchr(REC_TYPE_EXTRACT, type) == 0) { msg_warn("%s: message rejected: " "unexpected record type %d in extracted envelope", @@ -237,22 +245,12 @@ void cleanup_extracted_process(CLEANUP_STATE *state, int type, /* * Extracted envelope non-recipient record processing. - * - * XXX We currently cannot have FILTER, REDIRECT etc. action records after - * the message content, as that would break the use of "postsuper -r" to - * reset such information. See also smtpd/smtpd_check.c. */ if (state->flags & CLEANUP_FLAG_INRCPT) /* Tell qmgr that recipient records are mixed with other information. */ state->qmgr_opts |= QMGR_READ_FLAG_MIXED_RCPT_OTHER; - if (strchr(generated_by_cleanup, type) != 0) { - /* Use our own header/body info instead. */ - return; - } else { - /* Pass on other non-recipient record. */ - cleanup_out(state, type, buf, len); - return; - } + cleanup_out(state, type, buf, len); + return; } /* cleanup_extracted_finish - complete the third message segment */ diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 80974246f..9ddaf21a2 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 "20051126" +#define MAIL_RELEASE_DATE "20051128" #define MAIL_VERSION_NUMBER "2.3" #ifdef SNAPSHOT diff --git a/postfix/src/pickup/Makefile.in b/postfix/src/pickup/Makefile.in index 3a47b3255..fdfc1ce2a 100644 --- a/postfix/src/pickup/Makefile.in +++ b/postfix/src/pickup/Makefile.in @@ -57,6 +57,7 @@ depend: $(MAKES) # do not edit below this line - it is generated by 'make depend' pickup.o: ../../include/attr.h pickup.o: ../../include/cleanup_user.h +pickup.o: ../../include/dsn_attr_map.h pickup.o: ../../include/input_transp.h pickup.o: ../../include/iostuff.h pickup.o: ../../include/lex_822.h @@ -74,6 +75,7 @@ pickup.o: ../../include/record.h pickup.o: ../../include/safe_open.h pickup.o: ../../include/scan_dir.h pickup.o: ../../include/set_ugid.h +pickup.o: ../../include/stringops.h pickup.o: ../../include/sys_defs.h pickup.o: ../../include/vbuf.h pickup.o: ../../include/vstream.h diff --git a/postfix/src/pickup/pickup.c b/postfix/src/pickup/pickup.c index fa352280b..29b7bb25a 100644 --- a/postfix/src/pickup/pickup.c +++ b/postfix/src/pickup/pickup.c @@ -124,6 +124,7 @@ #include #include #include +#include /* Global library. */ @@ -139,6 +140,7 @@ #include #include #include +#include /* Single-threaded server skeleton. */ @@ -199,6 +201,8 @@ static int copy_segment(VSTREAM *qfile, VSTREAM *cleanup, PICKUP_INFO *info, int type; int check_first = (*expected == REC_TYPE_CONTENT[0]); int time_seen = 0; + char *attr_name; + char *attr_value; /* * Limit the input record size. All front-end programs should protect the @@ -235,9 +239,28 @@ static int copy_segment(VSTREAM *qfile, VSTREAM *cleanup, PICKUP_INFO *info, * XXX Workaround: REC_TYPE_FILT (used in envelopes) == REC_TYPE_CONT * (used in message content). */ - if (type == REC_TYPE_FILT && *expected != REC_TYPE_CONTENT[0]) - /* Use our own content filter settings instead. */ - continue; + if (*expected != REC_TYPE_CONTENT[0]) { + if (type == REC_TYPE_FILT) + /* Discard FILTER record after "postsuper -r". */ + continue; + if (type == REC_TYPE_RDR) + /* Discard REDIRECT record after "postsuper -r". */ + continue; + } + if (*expected == REC_TYPE_EXTRACT[0]) { + if (type == REC_TYPE_RRTO) + /* Discard return-receipt record after "postsuper -r". */ + continue; + if (type == REC_TYPE_ERTO) + /* Discard errors-to record after "postsuper -r". */ + continue; + if (type == REC_TYPE_ATTR + && split_nameval(vstring_str(buf), + &attr_name, &attr_value) == 0 + && dsn_attr_map(attr_name) == 0) + /* Discard other/header/body action after "postsuper -r". */ + continue; + } /* * XXX Force an empty record when the queue file content begins with diff --git a/postfix/src/smtpd/smtpd.c b/postfix/src/smtpd/smtpd.c index 5ad9a1f75..952722ae5 100644 --- a/postfix/src/smtpd/smtpd.c +++ b/postfix/src/smtpd/smtpd.c @@ -455,7 +455,7 @@ /* that counts the number of errors within an SMTP session that a /* client makes without delivering mail. /* .IP "\fBsmtpd_error_sleep_time (1s)\fR" -/* With Postfix 2.1 and later: the SMTP server response delay after +/* With Postfix version 2.1 and later: the SMTP server response delay after /* a client has made more than $smtpd_soft_error_limit errors, and /* fewer than $smtpd_hard_error_limit errors, without delivering mail. /* .IP "\fBsmtpd_soft_error_limit (10)\fR" @@ -2117,19 +2117,15 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv) } /* - * Flush out any access table actions that are delegated to the cleanup - * server, and that may trigger before we accept the first valid - * recipient. + * Flush out a first batch of access table actions that are delegated to + * the cleanup server, and that may trigger before we accept the first + * valid recipient. There will be more after end-of-data. * * Terminate the message envelope segment. Start the message content * segment, and prepend our own Received: header. If there is only one * recipient, list the recipient address. */ if (state->cleanup) { - if (state->saved_filter) - rec_fprintf(state->cleanup, REC_TYPE_FILT, "%s", state->saved_filter); - if (state->saved_redirect) - rec_fprintf(state->cleanup, REC_TYPE_RDR, "%s", state->saved_redirect); if (state->saved_flags) rec_fprintf(state->cleanup, REC_TYPE_FLGS, "%d", state->saved_flags); rec_fputs(state->cleanup, REC_TYPE_MESG, ""); @@ -2301,13 +2297,28 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv) } /* - * Send the end-of-segment markers and finish the queue file record - * stream. + * Flush out access table actions that are delegated to the cleanup + * server. There is similar code at the beginning of the DATA command. + * + * Send the end-of-segment markers and finish the queue file record stream. */ else { + if (state->err == CLEANUP_STAT_OK) { + rec_fputs(state->cleanup, REC_TYPE_XTRA, ""); + if (state->saved_filter) + rec_fprintf(state->cleanup, REC_TYPE_FILT, "%s", + state->saved_filter); + if (state->saved_redirect) + rec_fprintf(state->cleanup, REC_TYPE_RDR, "%s", + state->saved_redirect); + if (state->saved_flags) + rec_fprintf(state->cleanup, REC_TYPE_FLGS, "%d", + state->saved_flags); + if (vstream_ferror(state->cleanup)) + state->err = CLEANUP_STAT_WRITE; + } if (state->err == CLEANUP_STAT_OK) - if (rec_fputs(state->cleanup, REC_TYPE_XTRA, "") < 0 - || rec_fputs(state->cleanup, REC_TYPE_END, "") < 0 + if (rec_fputs(state->cleanup, REC_TYPE_END, "") < 0 || vstream_fflush(state->cleanup)) state->err = CLEANUP_STAT_WRITE; if (state->err == 0) { diff --git a/postfix/src/smtpd/smtpd_check.c b/postfix/src/smtpd/smtpd_check.c index 46f3f1a85..8910cd905 100644 --- a/postfix/src/smtpd/smtpd_check.c +++ b/postfix/src/smtpd/smtpd_check.c @@ -1836,17 +1836,6 @@ static int can_delegate_action(SMTPD_STATE *state, const char *table, return (0); } - /* - * XXX We currently cannot have FILTER, REDIRECT etc. action records - * after the message content, as that would break the use of "postsuper - * -r" to reset such information. See cleanup/cleanup_extracted.c. - */ - if (strcmp(state->where, SMTPD_AFTER_DOT) == 0) { - msg_warn("access table %s: action %s is unavailable in %s", - table, action, VAR_EOD_CHECKS); - return (0); - } - /* * ETRN does not receive mail so we can't store queue file records. */ @@ -2074,6 +2063,11 @@ static int check_table_result(SMTPD_STATE *state, const char *table, if (not_in_client_helo(state, table, "PREPEND", reply_class) == 0) return (SMTPD_CHECK_DUNNO); #endif + if (strcmp(state->where, SMTPD_AFTER_DOT) == 0) { + msg_warn("access table %s: action PREPEND must be used before %s", + table, VAR_EOD_CHECKS); + return (SMTPD_CHECK_DUNNO); + } if (*cmd_text == 0 || is_header(cmd_text) == 0) { msg_warn("access table %s entry \"%s\" requires header: text", table, datum);