From: Wietse Venema Date: Sat, 12 Feb 2005 05:00:00 +0000 (-0500) Subject: postfix-2.2-20050212 X-Git-Tag: v2.2.0-RC1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da78e2f4be67220e57261e8f269fae3792406e45;p=thirdparty%2Fpostfix.git postfix-2.2-20050212 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 0c03540b5..47091f3e8 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -10356,21 +10356,34 @@ Apologies for any names omitted. is renamed to "generic", for consistency with "canonical" and "virtual". +20050212 + + Cleanup: remove old trace(8) logfile before attempting + delivery (and after locking the message file exclusively). + Files: *qmgr/qmgr_message.c. + + Cleanup: don't parse-then-regenerate message headers when + no address is changed by address rewriting operations. This + behavior was copied from the SMTP client's generic mapping + code. Files: cleanup/cleanup_rewrite.c, cleanup/cleanup_map11.c, + cleanup/cleanup_masquerade.c, cleanup/cleanup_message.c.. + Open problems: - Low: 9kbyte memory leak when an expired in-memory session - is removed by SSL_CTX_flush_sessions(). The occurrance of - this is rare enough that it is a low priority. + Med: disable header address rewriting after XCLIENT? + Introduce a better concept of original submission? - Med: local and remote source port and IP address for smtpd - policy hook. + Low: 9kbyte memory leak when expired in-memory session + information is removed by SSL_CTX_flush_sessions(); found + by setting the expiry time shorter than the time to deliver + one or two messages. Postfix processes are short-lived, + and the occurrance of this leak is rare enough that it is + a low priority. - Med: canonical/generic/virtual mapping always append - myorigin/mydomain and never remote_header_rewrite_domain; - this needs to be clear from documentation. + Low: configurable order of local(8) delivery methods. - Med: disable address rewriting after XCLIENT? Introduce a - better concept of original submission? + Med: local and remote source port and IP address for smtpd + policy hook. Med: smtp_connect_timeout_budget (default: 3x smtp_connect_timeout) to limit the total time spent trying to connect. @@ -10435,9 +10448,6 @@ Open problems: Low: make post-install a "postfix-only script" so it can take data from the environment instead of main.cf. - Low: qmgr should truncate trace logfile before attempting - delivery. - Low: randomize deferred mail backoff. Med: separate ulimit for delivery to command? @@ -10455,9 +10465,6 @@ Open problems: Med: postsuper -r should do something with recipients in bounce logfiles. - Low: qmgr_move should not reset time stamps on queue files - without shared lock (i.e. not open by a delivery agent). - Low: postsuper re-run after renaming files, but only a limited number of times. @@ -10465,6 +10472,9 @@ Open problems: Med: make qmgr recipient bounce/defer activity asynchronous or add a multi-recipient operation that reduces overhead. + One possibility is to pass delivery requests to a retry(8) + delivery agent which is error(8) in disguise, and which + calls defer_append() instead of bounce_append(). Low: postmap/postalias should not try to open a bogus file when given an unsupported dictionary type. diff --git a/postfix/README_FILES/ADDRESS_REWRITING_README b/postfix/README_FILES/ADDRESS_REWRITING_README index b91a9a725..11a09d8a7 100644 --- a/postfix/README_FILES/ADDRESS_REWRITING_README +++ b/postfix/README_FILES/ADDRESS_REWRITING_README @@ -164,16 +164,18 @@ table will help you to quickly find what you need. |mapping |SMTP |smtp(8) |smtp_generic_maps |none | |table |mail | | | | |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |Local alias |all mail|local(8)|alias_maps |none | - |database | | | | | + |Local alias |local | | | | + |database |mail |local(8)|alias_maps |none | + | |only | | | | |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |Local per- | | | | | - |user |all mail|local(8)|forward_path |none | - |.forward | | | | | + |Local per- |local | | | | + |user |mail |local(8)|forward_path |none | + |.forward |only | | | | |files | | | | | |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |Local catch-|all mail|local(8)|luser_relay |none | - |all address | | | | | + |Local catch-|local | | | | + |all address |mail |local(8)|luser_relay |none | + | |only | | | | |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | AAddddrreessss rreewwrriittiinngg wwhheenn mmaaiill iiss rreecceeiivveedd diff --git a/postfix/README_FILES/STANDARD_CONFIGURATION_README b/postfix/README_FILES/STANDARD_CONFIGURATION_README index 627ca056d..b400191a5 100644 --- a/postfix/README_FILES/STANDARD_CONFIGURATION_README +++ b/postfix/README_FILES/STANDARD_CONFIGURATION_README @@ -478,8 +478,8 @@ hosts without a real Internet hostname". /usr/sbin/sendmail -q (whenever the Internet link is up) - The exact location of the sendmail command is system-specific. Use the - command "ppoossttccoonnff sseennddmmaaiill__ppaatthh" to find out where the Postfix sendmail + The exact location of the Postfix sendmail command is system-specific. Use + the command "ppoossttccoonnff sseennddmmaaiill__ppaatthh" to find out where the Postfix sendmail command is located on your machine. In order to find out if the mail queue is flushed, use something like: @@ -515,7 +515,7 @@ with non-existent domain names. Note: the following information is Postfix version dependent. To find out what Postfix version you have, execute the command "ppoossttccoonnff mmaaiill__vveerrssiioonn". -PPoossttffiixx vveerrssiioonn 22..22 aanndd llaatteerr +SSoolluuttiioonn 11:: PPoossttffiixx vveerrssiioonn 22..22 aanndd llaatteerr Postfix 2.2 uses the generic(5) address mapping to replace local fantasy email addresses by valid Internet addresses. This mapping happens ONLY when mail @@ -549,7 +549,7 @@ To find out what lookup tables Postfix supports, use the command "ppoossttc Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//ggeenneerriicc" whenever you change the generic table. -PPoossttffiixx vveerrssiioonn 22..11 aanndd eeaarrlliieerr +SSoolluuttiioonn 22:: PPoossttffiixx vveerrssiioonn 22..11 aanndd eeaarrlliieerr The solution with older Postfix systems is to use valid Internet addresses where possible, and to let Postfix map valid Internet addresses to local diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index a4d2ff29b..c8af0e056 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -7,6 +7,14 @@ snapshot release). Patches are issued for the official release and change the patchlevel and the release date. Patches are never issued for snapshot releases. +Major changes with snapshot Postfix-2.2-20050212 +================================================ + +When header address rewriting is enabled, Postfix now updates a +message header only when at least one address address in that header +is modified. Older Postfix versions first parse and then unparse +a header so that there may be subtle changes in formatting. + Major changes with snapshot Postfix-2.2-20050211 ================================================ diff --git a/postfix/conf/generic b/postfix/conf/generic index 101d304a4..f8666fe77 100644 --- a/postfix/conf/generic +++ b/postfix/conf/generic @@ -212,8 +212,9 @@ # README FILES # Use "postconf readme_directory" or "postconf html_direc- # tory" to locate this information. -# DATABASE_README, Postfix lookup table overview # ADDRESS_REWRITING_README, address rewriting guide +# DATABASE_README, Postfix lookup table overview +# STANDARD_CONFIGURATION_README, configuration examples # # LICENSE # The Secure Mailer license must be distributed with this diff --git a/postfix/html/ADDRESS_REWRITING_README.html b/postfix/html/ADDRESS_REWRITING_README.html index 149f465f0..d426b7600 100644 --- a/postfix/html/ADDRESS_REWRITING_README.html +++ b/postfix/html/ADDRESS_REWRITING_README.html @@ -348,15 +348,15 @@ outgoing SMTP mail smtp(8) none Local alias database -all mail local(8) alias_maps none +local mail only local(8) alias_maps none Local per-user .forward files - all mail local(8) forward_path + local mail only local(8) forward_path none Local catch-all address - all mail local(8) luser_relay + local mail only local(8) luser_relay none diff --git a/postfix/html/STANDARD_CONFIGURATION_README.html b/postfix/html/STANDARD_CONFIGURATION_README.html index b73113ff4..00411616a 100644 --- a/postfix/html/STANDARD_CONFIGURATION_README.html +++ b/postfix/html/STANDARD_CONFIGURATION_README.html @@ -659,7 +659,7 @@ calls from being placed, disable spontaneous SMTP mail deliveries.

/usr/sbin/sendmail -q (whenever the Internet link is up) -

The exact location of the sendmail command is system-specific. +

The exact location of the Postfix sendmail command is system-specific. Use the command "postconf sendmail_path" to find out where the Postfix sendmail command is located on your machine.

@@ -705,7 +705,7 @@ non-existent domain names.

To find out what Postfix version you have, execute the command "postconf mail_version".

-

Postfix version 2.2 and later

+

Solution 1: Postfix version 2.2 and later

Postfix 2.2 uses the generic(5) address mapping to replace local fantasy email addresses by valid Internet addresses. This @@ -751,7 +751,7 @@ tables Postfix supports, use the command "postconf -m".

Execute the command "postmap /etc/postfix/generic" whenever you change the generic table.

-

Postfix version 2.1 and earlier

+

Solution 2: Postfix version 2.1 and earlier

The solution with older Postfix systems is to use valid Internet addresses where possible, and to let Postfix map valid diff --git a/postfix/html/generic.5.html b/postfix/html/generic.5.html index e0e0138e5..25b7ce665 100644 --- a/postfix/html/generic.5.html +++ b/postfix/html/generic.5.html @@ -216,8 +216,9 @@ GENERIC(5) GENERIC(5) smtp(8), Postfix SMTP client README FILES - DATABASE_README, Postfix lookup table overview ADDRESS_REWRITING_README, address rewriting guide + DATABASE_README, Postfix lookup table overview + STANDARD_CONFIGURATION_README, configuration examples LICENSE The Secure Mailer license must be distributed with this diff --git a/postfix/man/man5/generic.5 b/postfix/man/man5/generic.5 index c71cdc73d..8966548bf 100644 --- a/postfix/man/man5/generic.5 +++ b/postfix/man/man5/generic.5 @@ -233,8 +233,9 @@ Use "\fBpostconf readme_directory\fR" or "\fBpostconf html_directory\fR" to locate this information. .na .nf -DATABASE_README, Postfix lookup table overview ADDRESS_REWRITING_README, address rewriting guide +DATABASE_README, Postfix lookup table overview +STANDARD_CONFIGURATION_README, configuration examples .SH "LICENSE" .na .nf diff --git a/postfix/proto/ADDRESS_REWRITING_README.html b/postfix/proto/ADDRESS_REWRITING_README.html index 3b8560b4c..04fcf3a2f 100644 --- a/postfix/proto/ADDRESS_REWRITING_README.html +++ b/postfix/proto/ADDRESS_REWRITING_README.html @@ -348,15 +348,15 @@ outgoing SMTP mail smtp(8) smtp_generic_maps none Local alias database -all mail local(8) alias_maps none +local mail only local(8) alias_maps none Local per-user .forward files - all mail local(8) forward_path + local mail only local(8) forward_path none Local catch-all address - all mail local(8) luser_relay + local mail only local(8) luser_relay none diff --git a/postfix/proto/STANDARD_CONFIGURATION_README.html b/postfix/proto/STANDARD_CONFIGURATION_README.html index 16553c3b1..e97ff32fb 100644 --- a/postfix/proto/STANDARD_CONFIGURATION_README.html +++ b/postfix/proto/STANDARD_CONFIGURATION_README.html @@ -659,7 +659,7 @@ calls from being placed, disable spontaneous SMTP mail deliveries.

/usr/sbin/sendmail -q (whenever the Internet link is up) -

The exact location of the sendmail command is system-specific. +

The exact location of the Postfix sendmail command is system-specific. Use the command "postconf sendmail_path" to find out where the Postfix sendmail command is located on your machine.

@@ -705,7 +705,7 @@ non-existent domain names.

To find out what Postfix version you have, execute the command "postconf mail_version".

-

Postfix version 2.2 and later

+

Solution 1: Postfix version 2.2 and later

Postfix 2.2 uses the generic(5) address mapping to replace local fantasy email addresses by valid Internet addresses. This @@ -751,7 +751,7 @@ tables Postfix supports, use the command "postconf -m".

Execute the command "postmap /etc/postfix/generic" whenever you change the generic table.

-

Postfix version 2.1 and earlier

+

Solution 2: Postfix version 2.1 and earlier

The solution with older Postfix systems is to use valid Internet addresses where possible, and to let Postfix map valid diff --git a/postfix/proto/generic b/postfix/proto/generic index 97a847dfc..ce27e5db8 100644 --- a/postfix/proto/generic +++ b/postfix/proto/generic @@ -205,8 +205,9 @@ # "\fBpostconf html_directory\fR" to locate this information. # .na # .nf -# DATABASE_README, Postfix lookup table overview # ADDRESS_REWRITING_README, address rewriting guide +# DATABASE_README, Postfix lookup table overview +# STANDARD_CONFIGURATION_README, configuration examples # LICENSE # .ad # .fi diff --git a/postfix/src/cleanup/cleanup.h b/postfix/src/cleanup/cleanup.h index f592df81e..65a42c4df 100644 --- a/postfix/src/cleanup/cleanup.h +++ b/postfix/src/cleanup/cleanup.h @@ -174,16 +174,16 @@ extern void cleanup_extracted(CLEANUP_STATE *, int, const char *, int); /* * cleanup_rewrite.c */ -extern void cleanup_rewrite_external(const char *, VSTRING *, const char *); -extern void cleanup_rewrite_internal(const char *, VSTRING *, const char *); -extern void cleanup_rewrite_tree(const char *, TOK822 *); +extern int cleanup_rewrite_external(const char *, VSTRING *, const char *); +extern int cleanup_rewrite_internal(const char *, VSTRING *, const char *); +extern int cleanup_rewrite_tree(const char *, TOK822 *); /* * cleanup_map11.c */ -extern void cleanup_map11_external(CLEANUP_STATE *, VSTRING *, MAPS *, int); -extern void cleanup_map11_internal(CLEANUP_STATE *, VSTRING *, MAPS *, int); -extern void cleanup_map11_tree(CLEANUP_STATE *, TOK822 *, MAPS *, int); +extern int cleanup_map11_external(CLEANUP_STATE *, VSTRING *, MAPS *, int); +extern int cleanup_map11_internal(CLEANUP_STATE *, VSTRING *, MAPS *, int); +extern int cleanup_map11_tree(CLEANUP_STATE *, TOK822 *, MAPS *, int); /* * cleanup_map1n.c @@ -193,9 +193,9 @@ ARGV *cleanup_map1n_internal(CLEANUP_STATE *, const char *, MAPS *, int); /* * cleanup_masquerade.c */ -extern void cleanup_masquerade_external(VSTRING *, ARGV *); -extern void cleanup_masquerade_internal(VSTRING *, ARGV *); -extern void cleanup_masquerade_tree(TOK822 *, ARGV *); +extern int cleanup_masquerade_external(VSTRING *, ARGV *); +extern int cleanup_masquerade_internal(VSTRING *, ARGV *); +extern int cleanup_masquerade_tree(TOK822 *, ARGV *); /* * cleanup_recipient.c diff --git a/postfix/src/cleanup/cleanup_map11.c b/postfix/src/cleanup/cleanup_map11.c index 6d699d348..7673667a8 100644 --- a/postfix/src/cleanup/cleanup_map11.c +++ b/postfix/src/cleanup/cleanup_map11.c @@ -6,19 +6,19 @@ /* SYNOPSIS /* #include /* -/* void cleanup_map11_external(state, addr, maps, propagate) +/* int cleanup_map11_external(state, addr, maps, propagate) /* CLEANUP_STATE *state; /* VSTRING *addr; /* MAPS *maps; /* int propagate; /* -/* void cleanup_map11_internal(state, addr, maps, propagate) +/* int cleanup_map11_internal(state, addr, maps, propagate) /* CLEANUP_STATE *state; /* VSTRING *addr; /* MAPS *maps; /* int propagate; /* -/* void cleanup_map11_tree(state, tree, maps, propagate) +/* int cleanup_map11_tree(state, tree, maps, propagate) /* CLEANUP_STATE *state; /* TOK822 *tree; /* MAPS *maps; @@ -32,6 +32,7 @@ /* or until an unreasonable recursion level is reached. /* An unmatched address extension is propagated when /* \fIpropagate\fR is non-zero. +/* These functions return non-zero when the address was changed. /* /* cleanup_map11_external() looks up the external (quoted) string /* form of an address in the maps specified via the \fImaps\fR argument. @@ -90,13 +91,14 @@ /* cleanup_map11_external - one-to-one table lookups */ -void cleanup_map11_external(CLEANUP_STATE *state, VSTRING *addr, +int cleanup_map11_external(CLEANUP_STATE *state, VSTRING *addr, MAPS *maps, int propagate) { int count; int expand_to_self; ARGV *new_addr; char *saved_addr; + int did_rewrite = 0; /* * Produce sensible output even in the face of a recoverable error. This @@ -110,31 +112,34 @@ void cleanup_map11_external(CLEANUP_STATE *state, VSTRING *addr, msg_warn("%s: multi-valued %s entry for %s", state->queue_id, maps->title, STR(addr)); saved_addr = mystrdup(STR(addr)); + did_rewrite |= strcmp(new_addr->argv[0], STR(addr)); vstring_strcpy(addr, new_addr->argv[0]); expand_to_self = !strcasecmp(saved_addr, STR(addr)); myfree(saved_addr); argv_free(new_addr); if (expand_to_self) - return; + return (did_rewrite); } else if (dict_errno != 0) { msg_warn("%s: %s map lookup problem for %s", state->queue_id, maps->title, STR(addr)); state->errs |= CLEANUP_STAT_WRITE; - return; + return (did_rewrite); } else { - return; + return (did_rewrite); } } msg_warn("%s: unreasonable %s map nesting for %s", state->queue_id, maps->title, STR(addr)); + return (did_rewrite); } /* cleanup_map11_tree - rewrite address node */ -void cleanup_map11_tree(CLEANUP_STATE *state, TOK822 *tree, +int cleanup_map11_tree(CLEANUP_STATE *state, TOK822 *tree, MAPS *maps, int propagate) { VSTRING *temp = vstring_alloc(100); + int did_rewrite; /* * Produce sensible output even in the face of a recoverable error. This @@ -143,18 +148,20 @@ void cleanup_map11_tree(CLEANUP_STATE *state, TOK822 *tree, * the place. */ tok822_externalize(temp, tree->head, TOK822_STR_DEFL); - cleanup_map11_external(state, temp, maps, propagate); + did_rewrite = cleanup_map11_external(state, temp, maps, propagate); tok822_free_tree(tree->head); tree->head = tok822_scan(STR(temp), &tree->tail); vstring_free(temp); + return (did_rewrite); } /* cleanup_map11_internal - rewrite address internal form */ -void cleanup_map11_internal(CLEANUP_STATE *state, VSTRING *addr, +int cleanup_map11_internal(CLEANUP_STATE *state, VSTRING *addr, MAPS *maps, int propagate) { VSTRING *temp = vstring_alloc(100); + int did_rewrite; /* * Produce sensible output even in the face of a recoverable error. This @@ -163,7 +170,8 @@ void cleanup_map11_internal(CLEANUP_STATE *state, VSTRING *addr, * the place. */ quote_822_local(temp, STR(addr)); - cleanup_map11_external(state, temp, maps, propagate); + did_rewrite = cleanup_map11_external(state, temp, maps, propagate); unquote_822_local(addr, STR(temp)); vstring_free(temp); + return (did_rewrite); } diff --git a/postfix/src/cleanup/cleanup_masquerade.c b/postfix/src/cleanup/cleanup_masquerade.c index dd0fa0768..f54fb7e5a 100644 --- a/postfix/src/cleanup/cleanup_masquerade.c +++ b/postfix/src/cleanup/cleanup_masquerade.c @@ -6,15 +6,15 @@ /* SYNOPSIS /* #include /* -/* void cleanup_masquerade_external(addr, masq_domains) +/* int cleanup_masquerade_external(addr, masq_domains) /* VSTRING *addr; /* ARGV *masq_domains; /* -/* void cleanup_masquerade_internal(addr, masq_domains) +/* int cleanup_masquerade_internal(addr, masq_domains) /* VSTRING *addr; /* ARGV *masq_domains; /* -/* void cleanup_masquerade_tree(tree, masq_domains) +/* int cleanup_masquerade_tree(tree, masq_domains) /* TOK822 *tree; /* ARGV *masq_domains; /* DESCRIPTION @@ -22,6 +22,7 @@ /* below domain names that are listed in the masquerade_domains /* configuration parameter, except for user names listed in the /* masquerade_exceptions configuration parameter. +/* These functions return non-zero when the address was changed. /* /* cleanup_masquerade_external() rewrites the external (quoted) string /* form of an address. @@ -77,7 +78,7 @@ /* cleanup_masquerade_external - masquerade address external form */ -void cleanup_masquerade_external(VSTRING *addr, ARGV *masq_domains) +int cleanup_masquerade_external(VSTRING *addr, ARGV *masq_domains) { char *domain; int domain_len; @@ -86,6 +87,7 @@ void cleanup_masquerade_external(VSTRING *addr, ARGV *masq_domains) int masq_len; char *parent; int truncate; + int did_rewrite = 0; /* Stuff for excluded names. */ char *name; @@ -95,7 +97,7 @@ void cleanup_masquerade_external(VSTRING *addr, ARGV *masq_domains) * Find the domain part. */ if ((domain = strrchr(STR(addr), '@')) == 0) - return; + return (0); domain += 1; domain_len = strlen(domain); @@ -107,7 +109,7 @@ void cleanup_masquerade_external(VSTRING *addr, ARGV *masq_domains) excluded = (string_list_match(cleanup_masq_exceptions, lowercase(name)) != 0); myfree(name); if (excluded) - return; + return (0); } /* @@ -132,38 +134,44 @@ void cleanup_masquerade_external(VSTRING *addr, ARGV *masq_domains) msg_info("masquerade: %s -> %s", domain, masq); vstring_truncate(addr, domain - STR(addr)); vstring_strcat(addr, masq); + did_rewrite = 1; } break; } } } + return (did_rewrite); } /* cleanup_masquerade_tree - masquerade address node */ -void cleanup_masquerade_tree(TOK822 *tree, ARGV *masq_domains) +int cleanup_masquerade_tree(TOK822 *tree, ARGV *masq_domains) { VSTRING *temp = vstring_alloc(100); + int did_rewrite; tok822_externalize(temp, tree->head, TOK822_STR_DEFL); - cleanup_masquerade_external(temp, masq_domains); + did_rewrite = cleanup_masquerade_external(temp, masq_domains); tok822_free_tree(tree->head); tree->head = tok822_scan(STR(temp), &tree->tail); vstring_free(temp); + return (did_rewrite); } /* cleanup_masquerade_internal - masquerade address internal form */ -void cleanup_masquerade_internal(VSTRING *addr, ARGV *masq_domains) +int cleanup_masquerade_internal(VSTRING *addr, ARGV *masq_domains) { VSTRING *temp = vstring_alloc(100); + int did_rewrite; quote_822_local(temp, STR(addr)); - cleanup_masquerade_external(temp, masq_domains); + did_rewrite = cleanup_masquerade_external(temp, masq_domains); unquote_822_local(addr, STR(temp)); vstring_free(temp); + return (did_rewrite); } /* @@ -175,10 +183,10 @@ void cleanup_masquerade_internal(VSTRING *addr, ARGV *masq_domains) #include -char *var_masq_exceptions; +char *var_masq_exceptions; STRING_LIST *cleanup_masq_exceptions; -int main(int argc, char **argv) +int main(int argc, char **argv) { VSTRING *addr; ARGV *masq_domains; @@ -188,7 +196,7 @@ int main(int argc, char **argv) var_masq_exceptions = argv[1]; cleanup_masq_exceptions = - string_list_init(MATCH_FLAG_NONE, var_masq_exceptions); + string_list_init(MATCH_FLAG_NONE, var_masq_exceptions); masq_domains = argv_split(argv[2], " ,\t\r\n"); addr = vstring_alloc(1); if (strchr(argv[3], '@') == 0) diff --git a/postfix/src/cleanup/cleanup_message.c b/postfix/src/cleanup/cleanup_message.c index cdf6840a8..ae04b0fb1 100644 --- a/postfix/src/cleanup/cleanup_message.c +++ b/postfix/src/cleanup/cleanup_message.c @@ -161,6 +161,7 @@ static void cleanup_rewrite_sender(CLEANUP_STATE *state, HEADER_OPTS *hdr_opts, TOK822 *tree; TOK822 **addr_list; TOK822 **tpp; + int did_rewrite = 0; if (msg_verbose) msg_info("rewrite_sender: %s", hdr_opts->name); @@ -175,27 +176,36 @@ static void cleanup_rewrite_sender(CLEANUP_STATE *state, HEADER_OPTS *hdr_opts, var_token_limit); addr_list = tok822_grep(tree, TOK822_ADDR); for (tpp = addr_list; *tpp; tpp++) { - cleanup_rewrite_tree(state->hdr_rewrite_context, *tpp); + did_rewrite |= cleanup_rewrite_tree(state->hdr_rewrite_context, *tpp); if (state->flags & CLEANUP_FLAG_MAP_OK) { if (cleanup_send_canon_maps && (cleanup_send_canon_flags & CLEANUP_CANON_FLAG_HDR_FROM)) - cleanup_map11_tree(state, *tpp, cleanup_send_canon_maps, + did_rewrite |= + cleanup_map11_tree(state, *tpp, cleanup_send_canon_maps, cleanup_ext_prop_mask & EXT_PROP_CANONICAL); if (cleanup_comm_canon_maps && (cleanup_comm_canon_flags & CLEANUP_CANON_FLAG_HDR_FROM)) - cleanup_map11_tree(state, *tpp, cleanup_comm_canon_maps, + did_rewrite |= + cleanup_map11_tree(state, *tpp, cleanup_comm_canon_maps, cleanup_ext_prop_mask & EXT_PROP_CANONICAL); if (cleanup_masq_domains && (cleanup_masq_flags & CLEANUP_MASQ_FLAG_HDR_FROM)) - cleanup_masquerade_tree(*tpp, cleanup_masq_domains); + did_rewrite |= + cleanup_masquerade_tree(*tpp, cleanup_masq_domains); } } - vstring_sprintf(header_buf, "%s: ", hdr_opts->name); - tok822_externalize(header_buf, tree, TOK822_STR_HEAD); + if (did_rewrite) { + vstring_sprintf(header_buf, "%s: ", hdr_opts->name); + tok822_externalize(header_buf, tree, TOK822_STR_HEAD); + } myfree((char *) addr_list); tok822_free_tree(tree); - if ((hdr_opts->flags & HDR_OPT_DROP) == 0) - cleanup_fold_header(state, header_buf); + if ((hdr_opts->flags & HDR_OPT_DROP) == 0) { + if (did_rewrite) + cleanup_fold_header(state, header_buf); + else + cleanup_out_header(state, header_buf); + } } /* cleanup_rewrite_recip - recipient address rewriting */ @@ -206,6 +216,7 @@ static void cleanup_rewrite_recip(CLEANUP_STATE *state, HEADER_OPTS *hdr_opts, TOK822 *tree; TOK822 **addr_list; TOK822 **tpp; + int did_rewrite = 0; if (msg_verbose) msg_info("rewrite_recip: %s", hdr_opts->name); @@ -220,27 +231,36 @@ static void cleanup_rewrite_recip(CLEANUP_STATE *state, HEADER_OPTS *hdr_opts, var_token_limit); addr_list = tok822_grep(tree, TOK822_ADDR); for (tpp = addr_list; *tpp; tpp++) { - cleanup_rewrite_tree(state->hdr_rewrite_context, *tpp); + did_rewrite |= cleanup_rewrite_tree(state->hdr_rewrite_context, *tpp); if (state->flags & CLEANUP_FLAG_MAP_OK) { if (cleanup_rcpt_canon_maps && (cleanup_rcpt_canon_flags & CLEANUP_CANON_FLAG_HDR_RCPT)) - cleanup_map11_tree(state, *tpp, cleanup_rcpt_canon_maps, + did_rewrite |= + cleanup_map11_tree(state, *tpp, cleanup_rcpt_canon_maps, cleanup_ext_prop_mask & EXT_PROP_CANONICAL); if (cleanup_comm_canon_maps && (cleanup_comm_canon_flags & CLEANUP_CANON_FLAG_HDR_RCPT)) - cleanup_map11_tree(state, *tpp, cleanup_comm_canon_maps, + did_rewrite |= + cleanup_map11_tree(state, *tpp, cleanup_comm_canon_maps, cleanup_ext_prop_mask & EXT_PROP_CANONICAL); if (cleanup_masq_domains && (cleanup_masq_flags & CLEANUP_MASQ_FLAG_HDR_RCPT)) - cleanup_masquerade_tree(*tpp, cleanup_masq_domains); + did_rewrite |= + cleanup_masquerade_tree(*tpp, cleanup_masq_domains); } } - vstring_sprintf(header_buf, "%s: ", hdr_opts->name); - tok822_externalize(header_buf, tree, TOK822_STR_HEAD); + if (did_rewrite) { + vstring_sprintf(header_buf, "%s: ", hdr_opts->name); + tok822_externalize(header_buf, tree, TOK822_STR_HEAD); + } myfree((char *) addr_list); tok822_free_tree(tree); - if ((hdr_opts->flags & HDR_OPT_DROP) == 0) - cleanup_fold_header(state, header_buf); + if ((hdr_opts->flags & HDR_OPT_DROP) == 0) { + if (did_rewrite) + cleanup_fold_header(state, header_buf); + else + cleanup_out_header(state, header_buf); + } } /* cleanup_act_log - log action with context */ diff --git a/postfix/src/cleanup/cleanup_rewrite.c b/postfix/src/cleanup/cleanup_rewrite.c index 9241ac8d8..3c81e7bed 100644 --- a/postfix/src/cleanup/cleanup_rewrite.c +++ b/postfix/src/cleanup/cleanup_rewrite.c @@ -6,23 +6,24 @@ /* SYNOPSIS /* #include /* -/* void cleanup_rewrite_external(context_name, result, addr) +/* int cleanup_rewrite_external(context_name, result, addr) /* const char *context; /* VSTRING *result; /* const char *addr; /* -/* void cleanup_rewrite_internal(context_name, result, addr) +/* int cleanup_rewrite_internal(context_name, result, addr) /* const char *context; /* VSTRING *result; /* const char *addr; /* -/* void cleanup_rewrite_tree(context_name, tree) +/* int cleanup_rewrite_tree(context_name, tree) /* const char *context; /* TOK822 *tree; /* DESCRIPTION /* This module rewrites addresses to canonical form, adding missing /* domains and stripping source routes etc., and performs /* \fIcanonical\fR map lookups to map addresses to official form. +/* These functions return non-zero when the address was changed. /* /* cleanup_rewrite_init() performs one-time initialization. /* @@ -80,38 +81,43 @@ /* cleanup_rewrite_external - rewrite address external form */ -void cleanup_rewrite_external(const char *context_name, VSTRING *result, +int cleanup_rewrite_external(const char *context_name, VSTRING *result, const char *addr) { rewrite_clnt(context_name, addr, result); + return (strcmp(STR(result), addr) != 0); } /* cleanup_rewrite_tree - rewrite address node */ -void cleanup_rewrite_tree(const char *context_name, TOK822 *tree) +int cleanup_rewrite_tree(const char *context_name, TOK822 *tree) { VSTRING *dst = vstring_alloc(100); VSTRING *src = vstring_alloc(100); + int did_rewrite; tok822_externalize(src, tree->head, TOK822_STR_DEFL); - cleanup_rewrite_external(context_name, dst, STR(src)); + did_rewrite = cleanup_rewrite_external(context_name, dst, STR(src)); tok822_free_tree(tree->head); tree->head = tok822_scan(STR(dst), &tree->tail); vstring_free(dst); vstring_free(src); + return (did_rewrite); } /* cleanup_rewrite_internal - rewrite address internal form */ -void cleanup_rewrite_internal(const char *context_name, +int cleanup_rewrite_internal(const char *context_name, VSTRING *result, const char *addr) { VSTRING *dst = vstring_alloc(100); VSTRING *src = vstring_alloc(100); + int did_rewrite; quote_822_local(src, addr); - cleanup_rewrite_external(context_name, dst, STR(src)); + did_rewrite = cleanup_rewrite_external(context_name, dst, STR(src)); unquote_822_local(result, STR(dst)); vstring_free(dst); vstring_free(src); + return (did_rewrite); } diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 05ed68614..623eaac40 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change the patchlevel and the release date. Snapshots change the * release date only. */ -#define MAIL_RELEASE_DATE "20050211" +#define MAIL_RELEASE_DATE "20050212" #define MAIL_VERSION_NUMBER "2.2" #define VAR_MAIL_VERSION "mail_version" diff --git a/postfix/src/oqmgr/qmgr_message.c b/postfix/src/oqmgr/qmgr_message.c index 17bee1f43..7b09bb233 100644 --- a/postfix/src/oqmgr/qmgr_message.c +++ b/postfix/src/oqmgr/qmgr_message.c @@ -220,8 +220,7 @@ static int qmgr_message_open(QMGR_MESSAGE *message) static void qmgr_message_oldstyle_scan(QMGR_MESSAGE *message) { VSTRING *buf; - long orig_offset, - extra_offset; + long orig_offset, extra_offset; int rec_type; char *start; @@ -535,28 +534,28 @@ static int qmgr_message_read(QMGR_MESSAGE *message) message->sasl_method = mystrdup(value); else msg_warn("%s: ignoring multiple %s attribute: %s", - message->queue_id, MAIL_ATTR_SASL_METHOD, value); + message->queue_id, MAIL_ATTR_SASL_METHOD, value); } if (strcmp(name, MAIL_ATTR_SASL_USERNAME) == 0) { if (message->sasl_username == 0) message->sasl_username = mystrdup(value); else msg_warn("%s: ignoring multiple %s attribute: %s", - message->queue_id, MAIL_ATTR_SASL_USERNAME, value); + message->queue_id, MAIL_ATTR_SASL_USERNAME, value); } if (strcmp(name, MAIL_ATTR_SASL_SENDER) == 0) { if (message->sasl_sender == 0) message->sasl_sender = mystrdup(value); else msg_warn("%s: ignoring multiple %s attribute: %s", - message->queue_id, MAIL_ATTR_SASL_SENDER, value); + message->queue_id, MAIL_ATTR_SASL_SENDER, value); } if (strcmp(name, MAIL_ATTR_RWR_CONTEXT) == 0) { if (message->rewrite_context == 0) message->rewrite_context = mystrdup(value); else msg_warn("%s: ignoring multiple %s attribute: %s", - message->queue_id, MAIL_ATTR_RWR_CONTEXT, value); + message->queue_id, MAIL_ATTR_RWR_CONTEXT, value); } /* Optional tracing flags. */ else if (strcmp(name, MAIL_ATTR_TRACE_FLAGS) == 0) { @@ -1170,10 +1169,17 @@ QMGR_MESSAGE *qmgr_message_alloc(const char *queue_name, const char *queue_id, * queue file and *before* resolving new recipients. Since all those * operations are encapsulated so nicely by this routine, the defer * log reset has to be done here as well. + * + * Likewise remove a trace file with results from address verification, + * "what if" testing, or verbose delivery. */ if (mail_queue_remove(MAIL_QUEUE_DEFER, queue_id) && errno != ENOENT) msg_fatal("%s: %s: remove %s %s: %m", myname, queue_id, MAIL_QUEUE_DEFER, queue_id); + if (message->tflags != 0 + && mail_queue_remove(MAIL_QUEUE_TRACE, queue_id) && errno != ENOENT) + msg_fatal("%s: %s: remove %s %s: %m", myname, + queue_id, MAIL_QUEUE_TRACE, queue_id); qmgr_message_sort(message); qmgr_message_resolve(message); qmgr_message_sort(message); diff --git a/postfix/src/qmgr/qmgr_message.c b/postfix/src/qmgr/qmgr_message.c index 0c6ba062c..9d341c85c 100644 --- a/postfix/src/qmgr/qmgr_message.c +++ b/postfix/src/qmgr/qmgr_message.c @@ -234,8 +234,7 @@ static int qmgr_message_open(QMGR_MESSAGE *message) static void qmgr_message_oldstyle_scan(QMGR_MESSAGE *message) { VSTRING *buf; - long orig_offset, - extra_offset; + long orig_offset, extra_offset; int rec_type; char *start; @@ -570,28 +569,28 @@ static int qmgr_message_read(QMGR_MESSAGE *message) message->sasl_method = mystrdup(value); else msg_warn("%s: ignoring multiple %s attribute: %s", - message->queue_id, MAIL_ATTR_SASL_METHOD, value); + message->queue_id, MAIL_ATTR_SASL_METHOD, value); } if (strcmp(name, MAIL_ATTR_SASL_USERNAME) == 0) { if (message->sasl_username == 0) message->sasl_username = mystrdup(value); else msg_warn("%s: ignoring multiple %s attribute: %s", - message->queue_id, MAIL_ATTR_SASL_USERNAME, value); + message->queue_id, MAIL_ATTR_SASL_USERNAME, value); } if (strcmp(name, MAIL_ATTR_SASL_SENDER) == 0) { if (message->sasl_sender == 0) message->sasl_sender = mystrdup(value); else msg_warn("%s: ignoring multiple %s attribute: %s", - message->queue_id, MAIL_ATTR_SASL_SENDER, value); + message->queue_id, MAIL_ATTR_SASL_SENDER, value); } if (strcmp(name, MAIL_ATTR_RWR_CONTEXT) == 0) { if (message->rewrite_context == 0) message->rewrite_context = mystrdup(value); else msg_warn("%s: ignoring multiple %s attribute: %s", - message->queue_id, MAIL_ATTR_RWR_CONTEXT, value); + message->queue_id, MAIL_ATTR_RWR_CONTEXT, value); } /* Optional tracing flags. */ else if (strcmp(name, MAIL_ATTR_TRACE_FLAGS) == 0) { @@ -1276,10 +1275,17 @@ QMGR_MESSAGE *qmgr_message_alloc(const char *queue_name, const char *queue_id, * queue file and *before* resolving new recipients. Since all those * operations are encapsulated so nicely by this routine, the defer * log reset has to be done here as well. + * + * Likewise remove a trace file with results from address verification, + * "what if" testing, or verbose delivery. */ if (mail_queue_remove(MAIL_QUEUE_DEFER, queue_id) && errno != ENOENT) msg_fatal("%s: %s: remove %s %s: %m", myname, queue_id, MAIL_QUEUE_DEFER, queue_id); + if (message->tflags != 0 + && mail_queue_remove(MAIL_QUEUE_TRACE, queue_id) && errno != ENOENT) + msg_fatal("%s: %s: remove %s %s: %m", myname, + queue_id, MAIL_QUEUE_TRACE, queue_id); qmgr_message_sort(message); qmgr_message_resolve(message); qmgr_message_sort(message); diff --git a/postfix/src/smtp/smtp_proto.c b/postfix/src/smtp/smtp_proto.c index 31d02a7d8..3f87513df 100644 --- a/postfix/src/smtp/smtp_proto.c +++ b/postfix/src/smtp/smtp_proto.c @@ -387,6 +387,7 @@ int smtp_helo(SMTP_STATE *state, NOCLOBBER int misc_flags) } #ifdef USE_TLS } else if (strcasecmp(word, "STARTTLS") == 0) { + /* Ignored later if we already sent STARTTLS. */ if ((discard_mask & EHLO_MASK_STARTTLS) == 0) session->features |= SMTP_FEATURE_STARTTLS; #endif