From 28b5cc972d587041a89bd6070efee874645c72cf Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Tue, 1 Nov 2016 00:00:00 -0500 Subject: [PATCH] postfix-3.2-20161101 --- postfix/HISTORY | 8 + postfix/README_FILES/MILTER_README | 302 +++++++++--------- postfix/RELEASE_NOTES | 7 + postfix/html/MILTER_README.html | 31 ++ postfix/html/postconf.5.html | 33 ++ postfix/html/smtpd.8.html | 442 ++++++++++++++------------- postfix/man/man5/postconf.5 | 35 +++ postfix/man/man8/smtpd.8 | 5 + postfix/mantools/postlink | 1 + postfix/proto/MILTER_README.html | 31 ++ postfix/proto/postconf.proto | 29 ++ postfix/src/global/mail_params.h | 5 + postfix/src/global/mail_version.h | 2 +- postfix/src/smtpd/smtpd.c | 185 ++++++----- postfix/src/smtpd/smtpd.h | 1 + postfix/src/smtpd/smtpd_sasl_proto.c | 2 +- postfix/src/smtpd/smtpd_state.c | 1 + 17 files changed, 680 insertions(+), 440 deletions(-) diff --git a/postfix/HISTORY b/postfix/HISTORY index cae5b09da..efb39cca3 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -22537,3 +22537,11 @@ Apologies for any names omitted. and "PASS" disables header, body, and Milter inspection for the remainder of the message content. Contributed by Hobbit. Files: cleanup/cleanup_message.c, global/header_body_checks.c. + +20161024 + + Feature: smtpd_milter_maps, per-client Milter configuration + that overrides smtpd_milters, and that has the same syntax. + Files: mantools/postlink, proto/MILTER_README.html, + proto/postconf.proto, global/mail_params.h, smtpd/smtpd.c, + smtpd/smtpd.h, smtpd/smtpd_sasl_proto.c, smtpd/smtpd_state.c. diff --git a/postfix/README_FILES/MILTER_README b/postfix/README_FILES/MILTER_README index e56a7d5ea..a1b68b68d 100644 --- a/postfix/README_FILES/MILTER_README +++ b/postfix/README_FILES/MILTER_README @@ -1,8 +1,8 @@ -PPoossttffiixx bbeeffoorree--qquueeuuee MMiilltteerr ssuuppppoorrtt +Postfix before-queue Milter support ------------------------------------------------------------------------------- -IInnttrroodduuccttiioonn +Introduction Postfix implements support for the Sendmail version 8 Milter (mail filter) protocol. This protocol is used by applications that run outside the MTA to @@ -30,7 +30,7 @@ This document provides information on the following topics: * Workarounds * Limitations -HHooww MMiilltteerr aapppplliiccaattiioonnss pplluugg iinnttoo PPoossttffiixx +How Milter applications plug into Postfix The Postfix Milter implementation uses two different lists of mail filters: one list of filters for SMTP mail only, and one list of filters for non-SMTP mail. @@ -80,7 +80,7 @@ Postfix architecture). Local -> sendmail(1) -BBuuiillddiinngg MMiilltteerr aapppplliiccaattiioonnss +Building Milter applications Milter applications have been written in C, JAVA and Perl, but this document deals with C applications only. For these, you need an object library that @@ -94,25 +94,25 @@ some Linux systems). Once libmilter is installed, applications such as OpenDKIM and OpenDMARC build out of the box without requiring any tinkering: - $ ggzzccaatt ooppeennddkkiimm--xx..yy..zz..ttaarr..ggzz || ttaarr xxff -- - $ ccdd ooppeennddkkiimm--xx..yy..zz - $ ..//ccoonnffiigguurree ......ooppttiioonnss...... - $ mmaakkee + $ gzcat opendkim-x.y.z.tar.gz | tar xf - + $ cd opendkim-x.y.z + $ ./configure ...options... + $ make [...lots of output omitted...] - $ mmaakkee iinnssttaallll + $ make install -RRuunnnniinngg MMiilltteerr aapppplliiccaattiioonnss +Running Milter applications To run a Milter application, see the documentation of the filter for options. A typical command looks like this: - # //ssoommee//wwhheerree//ooppeennddkkiimm --ll --uu uusseerriidd --pp iinneett::ppoorrttnnuummbbeerr@@llooccaallhhoosstt ......ootthheerr - ooppttiioonnss...... + # /some/where/opendkim -l -u userid -p inet:portnumber@localhost ...other + options... Please specify a userid value that isn't used for other applications (not "postfix", not "www", etc.). -CCoonnffiigguurriinngg PPoossttffiixx +Configuring Postfix Like Sendmail, Postfix has a lot of configuration options that control how it talks to Milter applications. Besides global options that apply to all Milter @@ -127,10 +127,11 @@ Information in this section: * Milter protocol version * Milter protocol timeouts * Different settings for different Milter applications + * Different settings for different SMTP clients * Sendmail macro emulation * What macros will Postfix send to Milters? -SSMMTTPP--OOnnllyy MMiilltteerr aapppplliiccaattiioonnss +SMTP-Only Milter applications The SMTP-only Milter applications handle mail that arrives via the Postfix smtpd(8) server. They are typically used to filter unwanted mail, and to sign @@ -158,20 +159,23 @@ from other Milter applications. The general syntax for listening sockets is as follows: - uunniixx::pathname + unix:pathname Connect to the local UNIX-domain server that is bound to the specified pathname. If the smtpd(8) or cleanup(8) process runs chrooted, an absolute pathname is interpreted relative to the Postfix queue directory. - iinneett::host::port + inet:host:port Connect to the specified TCP port on the specified local or remote host. The host and port can be specified in numeric or symbolic form. NOTE: Postfix syntax differs from Milter syntax which has the form - iinneett::port@@host. + inet:port@host. -NNoonn--SSMMTTPP MMiilltteerr aapppplliiccaattiioonnss +For advanced configuration see "Different settings for different SMTP clients" +and "Different settings for different Milter applications". + +Non-SMTP Milter applications The non-SMTP Milter applications handle mail that arrives via the Postfix sendmail(1) command-line or via the Postfix qmqpd(8) server. They are typically @@ -222,7 +226,7 @@ must not REJECT or TEMPFAIL simulated RCPT TO commands. When a non_smtpd_milters application REJECTs or TEMPFAILs a recipient, Postfix will report a configuration error, and mail will stay in the queue. -SSiiggnniinngg iinntteerrnnaallllyy--ggeenneerraatteedd bboouunnccee mmeessssaaggeess +Signing internally-generated bounce messages Postfix normally does not apply content filters to mail that is generated internally such as bounces or Postmaster notifications. Filtering internally- @@ -239,7 +243,7 @@ non_smtpd_milters, header_checks or body_checks (lines 3-5 below). 4 header_checks = don't reject internally-generated bounces 5 body_checks = don't reject internally-generated bounces -MMiilltteerr eerrrroorr hhaannddlliinngg +Milter error handling The milter_default_action parameter specifies how Postfix handles Milter application errors. The default action is to respond with a temporary error @@ -256,16 +260,16 @@ the message in the "hold" queue, and is available with Postfix 2.6 or later. See "Different settings for different Milter applications" for advanced configuration options. -MMiilltteerr pprroottooccooll vveerrssiioonn +Milter protocol version As Postfix is not built with the Sendmail libmilter library, you may need to configure the Milter protocol version that Postfix should use. The default version is 6 (before Postfix 2.6 the default version is 2). /etc/postfix/main.cf: - # Postfix >= 2.6 + # Postfix ≥ 2.6 milter_protocol = 6 - # 2.3 <= Postfix <= 2.5 + # 2.3 ≤ Postfix ≤ 2.5 milter_protocol = 2 If the Postfix milter_protocol setting specifies a too low version, the @@ -294,21 +298,21 @@ libmilter library does not expect. See "Different settings for different Milter applications" for advanced configuration options. -MMiilltteerr pprroottooccooll ttiimmeeoouuttss +Milter protocol timeouts Postfix uses different time limits at different Milter protocol stages. The table shows the timeout settings and the corresponding protocol stages (EOH = end of headers; EOM = end of message). - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - |PPoossttffiixx ppaarraammeetteerr |TTiimmee lliimmiitt|MMiilltteerr pprroottooccooll ssttaaggee | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + _________________________________________________________________ + |Postfix parameter |Time limit|Milter protocol stage | + |______________________|__________|_______________________________| |milter_connect_timeout|30s |CONNECT | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |______________________|__________|_______________________________| |milter_command_timeout|30s |HELO, MAIL, RCPT, DATA, UNKNOWN| - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |______________________|__________|_______________________________| |milter_content_timeout|300s |HEADER, EOH, BODY, EOM | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |______________________|__________|_______________________________| Beware: 30s may be too short for Milter applications that do lots of DNS lookups. However, if you increase the above timeouts too much, remote SMTP @@ -318,7 +322,7 @@ inherent problem with before-queue filtering. See "Different settings for different Milter applications" for advanced configuration options. -DDiiffffeerreenntt sseettttiinnggss ffoorr ddiiffffeerreenntt MMiilltteerr aapppplliiccaattiioonnss +Different settings for different Milter applications The previous sections list a number of Postfix main.cf parameters that control time limits and other settings for all Postfix Milter clients. This is @@ -345,11 +349,31 @@ Instead of a server endpoint, we now have a list enclosed in {}. content_timeout, default_action, and protocol. Inside the list, syntax is similar to what we already know from main.cf: items -separated by space or comma. There is one difference: yyoouu mmuusstt eenncclloossee aa -sseettttiinngg iinn ppaarreenntthheesseess,, aass iinn ""{{ nnaammee == vvaalluuee }}"",, iiff yyoouu wwaanntt ttoo hhaavvee ssppaaccee oorr -ccoommmmaa wwiitthhiinn aa vvaalluuee oorr aarroouunndd ""=="". +separated by space or comma. There is one difference: you must enclose a +setting in parentheses, as in "{ name = value }", if you want to have space or +comma within a value or around "=". -SSeennddmmaaiill mmaaccrroo eemmuullaattiioonn +Different settings for different SMTP clients + +The smtpd_milter_maps feature supports different Milter settings for different +client IP addresses. Lookup results override the the global smtpd_milters +setting, and have the same syntax. For example, to disable Milter settings for +local address ranges: + +/etc/postfix/main.cf: + smtpd_milter_maps = cidr:/etc/postfix/smtpd_milter_map + smtpd_milters = inet:host:port, { inet:host:port, ... }, ... + +/etc/postfix/smtpd_milter_map: + # Disable Milters for local clients. + 127.0.0.0/8 DISABLE + 192.168.0.0/16 DISABLE + ::/64 DISABLE + 2001:db8::/32 DISABLE + +This feature is available with Postfix 3.2 and later. + +Sendmail macro emulation Postfix emulates a limited number of Sendmail macros, as shown in the table. Some macro values depend on whether a recipient is rejected (rejected @@ -358,92 +382,70 @@ macros are available at different Milter protocol stages (EOH = end-of-header, EOM = end-of-message); their availability is not always the same as in Sendmail. See the workarounds section below for solutions. - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - |SSeennddmmaaiill mmaaccrroo |MMiilltteerr pprroottooccooll ssttaaggee |DDeessccrriippttiioonn | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |i |DATA, EOH, EOM |Queue ID, also Postfix | - | | |queue file name | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |j |Always |Value of myhostname | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |_ |Always |The validated client name | - | | |and address | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{auth_authen} |MAIL, DATA, EOH, EOM |SASL login name | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{auth_author} |MAIL, DATA, EOH, EOM |SASL sender | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{auth_type} |MAIL, DATA, EOH, EOM |SASL login method | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{client_addr} |Always |Remote client IP address | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - | | |Connection concurrency for| - | | |this client (zero if the | - |{client_connections}|CONNECT |client is excluded from | - | | |all smtpd_client_* | - | | |limits). | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - | | |Remote client hostname | - | | |When address -> name | - |{client_name} |Always |lookup or name -> address | - | | |verification fails: | - | | |"unknown" | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{client_port} |Always (Postfix >=2.5) |Remote client TCP port | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - | | |Client name from address -| - |{client_ptr} |CONNECT, HELO, MAIL, DATA|> name lookup | - | | |When address -> name | - | | |lookup fails: "unknown" | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{cert_issuer} |HELO, MAIL, DATA, EOH, |TLS client certificate | - | |EOM |issuer | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{cert_subject} |HELO, MAIL, DATA, EOH, |TLS client certificate | - | |EOM |subject | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{cipher_bits} |HELO, MAIL, DATA, EOH, |TLS session key size | - | |EOM | | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{cipher} |HELO, MAIL, DATA, EOH, |TLS cipher | - | |EOM | | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{daemon_addr} |Always (Postfix >=3.2) |Local server IP address | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{daemon_name} |Always |value of | - | | |milter_macro_daemon_name | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{daemon_port} |Always (Postfix >=3.2) |Local server TCP port | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{mail_addr} |MAIL |Sender address | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{mail_host} |MAIL (Postfix >= 2.6, |Sender next-hop | - | |only with smtpd_milters) |destination | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{mail_mailer} |MAIL (Postfix >= 2.6, |Sender mail delivery | - | |only with smtpd_milters) |transport | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - | | |Recipient address | - |{rcpt_addr} |RCPT |With rejected recipient: | - | | |descriptive text | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - | | |Recipient next-hop | - |{rcpt_host} |RCPT (Postfix >= 2.6, |destination | - | |only with smtpd_milters) |With rejected recipient: | - | | |enhanced status code | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - | | |Recipient mail delivery | - |{rcpt_mailer} |RCPT (Postfix >= 2.6, |transport | - | |only with smtpd_milters) |With rejected recipient: | - | | |"error" | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |{tls_version} |HELO, MAIL, DATA, EOH, |TLS protocol version | - | |EOM | | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | - |v |Always |value of milter_macro_v | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + _________________________________________________________________________________________________________________________________________ + |Sendmail macro |Milter protocol stage |Description | + |____________________|_______________________________________________|____________________________________________________________________| + |i |DATA, EOH, EOM |Queue ID, also Postfix queue file name | + |____________________|_______________________________________________|____________________________________________________________________| + |j |Always |Value of myhostname | + |____________________|_______________________________________________|____________________________________________________________________| + |_ |Always |The validated client name and address | + |____________________|_______________________________________________|____________________________________________________________________| + |{auth_authen} |MAIL, DATA, EOH, EOM |SASL login name | + |____________________|_______________________________________________|____________________________________________________________________| + |{auth_author} |MAIL, DATA, EOH, EOM |SASL sender | + |____________________|_______________________________________________|____________________________________________________________________| + |{auth_type} |MAIL, DATA, EOH, EOM |SASL login method | + |____________________|_______________________________________________|____________________________________________________________________| + |{client_addr} |Always |Remote client IP address | + |____________________|_______________________________________________|____________________________________________________________________| + |{client_connections}|CONNECT |Connection concurrency for this client (zero if the client is | + | | |excluded from all smtpd_client_* limits). | + |____________________|_______________________________________________|____________________________________________________________________| + | | |Remote client hostname | + |{client_name} |Always |When address → name lookup or name → address verification fails:| + | | |"unknown" | + |____________________|_______________________________________________|____________________________________________________________________| + |{client_port} |Always (Postfix ≥2.5) |Remote client TCP port | + |____________________|_______________________________________________|____________________________________________________________________| + |{client_ptr} |CONNECT, HELO, MAIL, DATA |Client name from address → name lookup | + | | |When address → name lookup fails: "unknown" | + |____________________|_______________________________________________|____________________________________________________________________| + |{cert_issuer} |HELO, MAIL, DATA, EOH, EOM |TLS client certificate issuer | + |____________________|_______________________________________________|____________________________________________________________________| + |{cert_subject} |HELO, MAIL, DATA, EOH, EOM |TLS client certificate subject | + |____________________|_______________________________________________|____________________________________________________________________| + |{cipher_bits} |HELO, MAIL, DATA, EOH, EOM |TLS session key size | + |____________________|_______________________________________________|____________________________________________________________________| + |{cipher} |HELO, MAIL, DATA, EOH, EOM |TLS cipher | + |____________________|_______________________________________________|____________________________________________________________________| + |{daemon_addr} |Always (Postfix ≥3.2) |Local server IP address | + |____________________|_______________________________________________|____________________________________________________________________| + |{daemon_name} |Always |value of milter_macro_daemon_name | + |____________________|_______________________________________________|____________________________________________________________________| + |{daemon_port} |Always (Postfix ≥3.2) |Local server TCP port | + |____________________|_______________________________________________|____________________________________________________________________| + |{mail_addr} |MAIL |Sender address | + |____________________|_______________________________________________|____________________________________________________________________| + |{mail_host} |MAIL (Postfix ≥ 2.6, only with smtpd_milters)|Sender next-hop destination | + |____________________|_______________________________________________|____________________________________________________________________| + |{mail_mailer} |MAIL (Postfix ≥ 2.6, only with smtpd_milters)|Sender mail delivery transport | + |____________________|_______________________________________________|____________________________________________________________________| + |{rcpt_addr} |RCPT |Recipient address | + | | |With rejected recipient: descriptive text | + |____________________|_______________________________________________|____________________________________________________________________| + |{rcpt_host} |RCPT (Postfix ≥ 2.6, only with smtpd_milters)|Recipient next-hop destination | + | | |With rejected recipient: enhanced status code | + |____________________|_______________________________________________|____________________________________________________________________| + |{rcpt_mailer} |RCPT (Postfix ≥ 2.6, only with smtpd_milters)|Recipient mail delivery transport | + | | |With rejected recipient: "error" | + |____________________|_______________________________________________|____________________________________________________________________| + |{tls_version} |HELO, MAIL, DATA, EOH, EOM |TLS protocol version | + |____________________|_______________________________________________|____________________________________________________________________| + |v |Always |value of milter_macro_v | + |____________________|_______________________________________________|____________________________________________________________________| -WWhhaatt mmaaccrrooss wwiillll PPoossttffiixx sseenndd ttoo MMiilltteerrss?? +What macros will Postfix send to Milters? Postfix sends specific sets of macros at different Milter protocol stages. The sets are configured with the parameters as shown in the table below (EOH = end @@ -454,26 +456,26 @@ As of Sendmail 8.14.0, Milter applications can specify what macros they want to receive at different Milter protocol stages. An application-specified list takes precedence over a Postfix-specified list. - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - |PPoossttffiixx ppaarraammeetteerr |MMiilltteerr pprroottooccooll|MMiilltteerr pprroottooccooll ssttaaggee| - | |vveerrssiioonn | | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + ___________________________________________________________________ + |Postfix parameter |Milter protocol|Milter protocol stage| + | |version | | + |_____________________________|_______________|_____________________| |milter_connect_macros |2 or higher |CONNECT | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_____________________________|_______________|_____________________| |milter_helo_macros |2 or higher |HELO/EHLO | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_____________________________|_______________|_____________________| |milter_mail_macros |2 or higher |MAIL FROM | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_____________________________|_______________|_____________________| |milter_rcpt_macros |2 or higher |RCPT TO | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_____________________________|_______________|_____________________| |milter_data_macros |4 or higher |DATA | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_____________________________|_______________|_____________________| |milter_end_of_header_macros |6 or higher |EOH | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_____________________________|_______________|_____________________| |milter_end_of_data_macros |2 or higher |EOM | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_____________________________|_______________|_____________________| |milter_unknown_command_macros|3 or higher |unknown command | - |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_____________________________|_______________|_____________________| By default, Postfix will send only macros whose values have been updated with information from main.cf or master.cf, from an SMTP session (for example; SASL @@ -485,7 +487,7 @@ specify macro default values with the milter_macro_defaults parameter. Specify zero or more name=value pairs separated by comma or whitespace; you may even specify macro names that Postfix does know about! -WWoorrkkaarroouunnddss +Workarounds * To avoid breaking DKIM etc. signatures with an SMTP-based content filter, update the before-filter SMTP client in master.cf, and add a line with "- @@ -504,7 +506,7 @@ WWoorrkkaarroouunnddss * Some Milter applications use the "{if_addr}" macro to recognize local mail; this macro does not exist in Postfix. Workaround: use the "{daemon_addr}" - (Postfix >= 3.2) or "{client_addr}" macro instead. + (Postfix ≥ 3.2) or "{client_addr}" macro instead. * Some Milter applications log a warning that looks like this: @@ -533,19 +535,19 @@ WWoorrkkaarroouunnddss o Edit the filter source file (typically named xxx-filter/xxx-filter.c or similar). - o Look up the mlfi_eom() function and add code near the top shown as bboolldd + o Look up the mlfi_eom() function and add code near the top shown as bold text below: dfc = cc->cctx_msg; assert(dfc != NULL); - //** DDeetteerrmmiinnee tthhee jjoobb IIDD ffoorr llooggggiinngg.. **// - iiff ((ddffcc-->>mmccttxx__jjoobbiidd ==== 00 |||| ssttrrccmmpp((ddffcc-->>mmccttxx__jjoobbiidd,, JJOOBBIIDDUUNNKKNNOOWWNN)) ==== 00)) - {{ - cchhaarr **jjoobbiidd == ssmmffii__ggeettssyymmvvaall((ccttxx,, ""ii""));; - iiff ((jjoobbiidd !!== 00)) - ddffcc-->>mmccttxx__jjoobbiidd == jjoobbiidd;; - }} + /* Determine the job ID for logging. */ + if (dfc->mctx_jobid == 0 || strcmp(dfc->mctx_jobid, JOBIDUNKNOWN) == 0) + { + char *jobid = smfi_getsymval(ctx, "i"); + if (jobid != 0) + dfc->mctx_jobid = jobid; + } NOTES: @@ -557,7 +559,7 @@ WWoorrkkaarroouunnddss o This change fixes only the ugly message header, but not the WARNING message. Fortunately, many Milters log that message only once. -LLiimmiittaattiioonnss +Limitations This section lists limitations of the Postfix Milter implementation. Some limitations will be removed as the implementation is extended over time. Of @@ -567,22 +569,22 @@ the CONTENT_INSPECTION_README document for a discussion. * The Milter protocol has evolved over time. Therefore, different Postfix versions implement different feature sets. - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - |PPoossttffiixx|SSuuppppoorrtteedd MMiilltteerr rreeqquueessttss | - |_ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + ________________________________________________________________________ + |Postfix|Supported Milter requests | + |_______|________________________________________________________________| | 2.6 |All Milter requests of Sendmail 8.14.0 (see notes below). | - |_ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_______|________________________________________________________________| | |All Milter requests of Sendmail 8.14.0, except: | | |SMFIP_RCPT_REJ (report rejected recipients to the mail filter), | | 2.5 |SMFIR_CHGFROM (replace sender, with optional ESMTP parameters), | | |SMFIR_ADDRCPT_PAR (add recipient, with optional ESMTP | | |parameters). | - |_ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_______|________________________________________________________________| | 2.4 |All Milter requests of Sendmail 8.13.0. | - |_ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_______|________________________________________________________________| | 2.3 |All Milter requests of Sendmail 8.13.0, except: | | |SMFIR_REPLBODY (replace message body). | - |_ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | + |_______|________________________________________________________________| * For Milter applications that are written in C, you need to use the Sendmail libmilter library. diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index 03bc062b7..c083b20b5 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -16,6 +16,13 @@ specifies the release date of a stable release or snapshot release. If you upgrade from Postfix 3.0 or earlier, read RELEASE_NOTES-3.1 before proceeding. +Major changes with snapshot 20161031 +==================================== + +The smtpd_milter_maps feature supports per-client Milter configuration. +This overrides the global smtpd_milters setting and has the same syntax. A +lookup result of "DISABLE" turns off Milter support. + Incompatible changes with snapshot 20160925 =========================================== diff --git a/postfix/html/MILTER_README.html b/postfix/html/MILTER_README.html index ee46ad452..99af63a12 100644 --- a/postfix/html/MILTER_README.html +++ b/postfix/html/MILTER_README.html @@ -259,6 +259,9 @@ support per-Milter timeouts, per-Milter error handling, etc.

  • Different settings for different Milter applications +
  • Different settings for different SMTP +clients +
  • Sendmail macro emulation
  • What macros will Postfix send to Milters? @@ -320,6 +323,11 @@ form inet:port@host.

    +

    For advanced configuration see "Different +settings for different SMTP clients" and "Different settings for different Milter +applications".

    +

    Non-SMTP Milter applications

    The non-SMTP Milter applications handle mail that arrives via @@ -564,6 +572,29 @@ and protocol.

    }", if you want to have space or comma within a value or around "=".

    +

    Different settings for different SMTP +clients

    + +

    The smtpd_milter_maps feature supports different Milter settings +for different client IP addresses. Lookup results override the the +global smtpd_milters setting, and have the same syntax. For example, +to disable Milter settings for local address ranges:

    + +
    +/etc/postfix/main.cf:
    +    smtpd_milter_maps = cidr:/etc/postfix/smtpd_milter_map
    +    smtpd_milters = inet:host:port, { inet:host:port, ... }, ...
    +
    +/etc/postfix/smtpd_milter_map:
    +    # Disable Milters for local clients.
    +    127.0.0.0/8    DISABLE
    +    192.168.0.0/16 DISABLE
    +    ::/64          DISABLE
    +    2001:db8::/32  DISABLE
    +
    + +

    This feature is available with Postfix 3.2 and later.

    +

    Sendmail macro emulation

    Postfix emulates a limited number of Sendmail macros, as shown diff --git a/postfix/html/postconf.5.html b/postfix/html/postconf.5.html index 166c8073f..9163af9f9 100644 --- a/postfix/html/postconf.5.html +++ b/postfix/html/postconf.5.html @@ -14637,6 +14637,39 @@ from the list.

    This feature is available in Postfix 2.10 and later.

    + + +
    smtpd_milter_maps +(default: empty)
    + +

    Lookup tables with Milter settings per remote SMTP client IP +address. The lookup result overrides the smtpd_milters setting, +and has the same syntax.

    + +

    Note: lookup tables cannot return empty responses. Specify a +lookup result of DISABLE (case does not matter) to indicate that +Milter support should be disabled.

    + +

    Example to disable Milters for local clients:

    + +
    +/etc/postfix/main.cf:
    +    smtpd_milter_maps = cidr:/etc/postfix/smtpd_milter_map
    +    smtpd_milters = inet:host:port, { inet:host:port, ... }, ...
    +
    + +
    +/etc/postfix/smtpd_milter_map:
    +    # Disable Milters for local clients.
    +    127.0.0.0/8    DISABLE
    +    192.168.0.0/16 DISABLE
    +    ::/64          DISABLE
    +    2001:db8::/32  DISABLE
    +
    + +

    This feature is available in Postfix 3.2 and later.

    + +
    smtpd_milters diff --git a/postfix/html/smtpd.8.html b/postfix/html/smtpd.8.html index f2ed4a70f..fd39227fb 100644 --- a/postfix/html/smtpd.8.html +++ b/postfix/html/smtpd.8.html @@ -297,8 +297,14 @@ SMTPD(8) SMTPD(8) for arbitrary macros that Postfix may send to Milter applica- tions. + Available in Postfix version 3.2 and later: + + smtpd_milter_maps (empty) + Lookup tables with Milter settings per remote SMTP client IP + address. + GENERAL CONTENT INSPECTION CONTROLS - The following parameters are applicable for both built-in and external + The following parameters are applicable for both built-in and external content filters. Available in Postfix version 2.1 and later: @@ -308,51 +314,51 @@ SMTPD(8) SMTPD(8) ing, or address mapping. EXTERNAL CONTENT INSPECTION CONTROLS - The following parameters are applicable for both before-queue and + The following parameters are applicable for both before-queue and after-queue content filtering. Available in Postfix version 2.1 and later: smtpd_authorized_xforward_hosts (empty) - What remote SMTP clients are allowed to use the XFORWARD fea- + What remote SMTP clients are allowed to use the XFORWARD fea- ture. SASL AUTHENTICATION CONTROLS Postfix SASL support (RFC 4954) can be used to authenticate remote SMTP - clients to the Postfix SMTP server, and to authenticate the Postfix - SMTP client to a remote SMTP server. See the SASL_README document for + clients to the Postfix SMTP server, and to authenticate the Postfix + SMTP client to a remote SMTP server. See the SASL_README document for details. broken_sasl_auth_clients (no) - Enable interoperability with remote SMTP clients that implement + Enable interoperability with remote SMTP clients that implement an obsolete version of the AUTH command (RFC 4954). smtpd_sasl_auth_enable (no) Enable SASL authentication in the Postfix SMTP server. smtpd_sasl_local_domain (empty) - The name of the Postfix SMTP server's local SASL authentication + The name of the Postfix SMTP server's local SASL authentication realm. smtpd_sasl_security_options (noanonymous) Postfix SMTP server SASL security options; as of Postfix 2.3 the - list of available features depends on the SASL server implemen- + list of available features depends on the SASL server implemen- tation that is selected with smtpd_sasl_type. smtpd_sender_login_maps (empty) - Optional lookup table with the SASL login names that own the + Optional lookup table with the SASL login names that own the sender (MAIL FROM) addresses. Available in Postfix version 2.1 and later: smtpd_sasl_exceptions_networks (empty) - What remote SMTP clients the Postfix SMTP server will not offer + What remote SMTP clients the Postfix SMTP server will not offer AUTH support to. Available in Postfix version 2.1 and 2.2: smtpd_sasl_application_name (smtpd) - The application name that the Postfix SMTP server uses for SASL + The application name that the Postfix SMTP server uses for SASL server initialization. Available in Postfix version 2.3 and later: @@ -363,11 +369,11 @@ SMTPD(8) SMTPD(8) smtpd_sasl_path (smtpd) Implementation-specific information that the Postfix SMTP server - passes through to the SASL plug-in implementation that is + passes through to the SASL plug-in implementation that is selected with smtpd_sasl_type. smtpd_sasl_type (cyrus) - The SASL plug-in type that the Postfix SMTP server should use + The SASL plug-in type that the Postfix SMTP server should use for authentication. Available in Postfix version 2.5 and later: @@ -379,20 +385,20 @@ SMTPD(8) SMTPD(8) Available in Postfix version 2.11 and later: smtpd_sasl_service (smtp) - The service name that is passed to the SASL plug-in that is + The service name that is passed to the SASL plug-in that is selected with smtpd_sasl_type and smtpd_sasl_path. STARTTLS SUPPORT CONTROLS - Detailed information about STARTTLS configuration may be found in the + Detailed information about STARTTLS configuration may be found in the TLS_README document. smtpd_tls_security_level (empty) - The SMTP TLS security level for the Postfix SMTP server; when a + The SMTP TLS security level for the Postfix SMTP server; when a non-empty value is specified, this overrides the obsolete param- eters smtpd_use_tls and smtpd_enforce_tls. smtpd_sasl_tls_security_options ($smtpd_sasl_security_options) - The SASL authentication security options that the Postfix SMTP + The SASL authentication security options that the Postfix SMTP server uses for TLS encrypted SMTP sessions. smtpd_starttls_timeout (see 'postconf -d' output) @@ -400,25 +406,25 @@ SMTPD(8) SMTPD(8) during TLS startup and shutdown handshake procedures. smtpd_tls_CAfile (empty) - A file containing (PEM format) CA certificates of root CAs + A file containing (PEM format) CA certificates of root CAs trusted to sign either remote SMTP client certificates or inter- mediate CA certificates. smtpd_tls_CApath (empty) - A directory containing (PEM format) CA certificates of root CAs + A directory containing (PEM format) CA certificates of root CAs trusted to sign either remote SMTP client certificates or inter- mediate CA certificates. smtpd_tls_always_issue_session_ids (yes) - Force the Postfix SMTP server to issue a TLS session id, even - when TLS session caching is turned off (smtpd_tls_ses- + Force the Postfix SMTP server to issue a TLS session id, even + when TLS session caching is turned off (smtpd_tls_ses- sion_cache_database is empty). smtpd_tls_ask_ccert (no) Ask a remote SMTP client for a client certificate. smtpd_tls_auth_only (no) - When TLS encryption is optional in the Postfix SMTP server, do + When TLS encryption is optional in the Postfix SMTP server, do not announce or accept SASL authentication over unencrypted con- nections. @@ -429,18 +435,18 @@ SMTPD(8) SMTPD(8) File with the Postfix SMTP server RSA certificate in PEM format. smtpd_tls_exclude_ciphers (empty) - List of ciphers or cipher types to exclude from the SMTP server + List of ciphers or cipher types to exclude from the SMTP server cipher list at all TLS security levels. smtpd_tls_dcert_file (empty) File with the Postfix SMTP server DSA certificate in PEM format. smtpd_tls_dh1024_param_file (empty) - File with DH parameters that the Postfix SMTP server should use + File with DH parameters that the Postfix SMTP server should use with non-export EDH ciphers. smtpd_tls_dh512_param_file (empty) - File with DH parameters that the Postfix SMTP server should use + File with DH parameters that the Postfix SMTP server should use with export-grade EDH ciphers. smtpd_tls_dkey_file ($smtpd_tls_dcert_file) @@ -453,35 +459,35 @@ SMTPD(8) SMTPD(8) Enable additional Postfix SMTP server logging of TLS activity. smtpd_tls_mandatory_ciphers (medium) - The minimum TLS cipher grade that the Postfix SMTP server will + The minimum TLS cipher grade that the Postfix SMTP server will use with mandatory TLS encryption. smtpd_tls_mandatory_exclude_ciphers (empty) - Additional list of ciphers or cipher types to exclude from the - Postfix SMTP server cipher list at mandatory TLS security lev- + Additional list of ciphers or cipher types to exclude from the + Postfix SMTP server cipher list at mandatory TLS security lev- els. smtpd_tls_mandatory_protocols (!SSLv2, !SSLv3) - The SSL/TLS protocols accepted by the Postfix SMTP server with + The SSL/TLS protocols accepted by the Postfix SMTP server with mandatory TLS encryption. smtpd_tls_received_header (no) Request that the Postfix SMTP server produces Received: message - headers that include information about the protocol and cipher - used, as well as the remote SMTP client CommonName and client + headers that include information about the protocol and cipher + used, as well as the remote SMTP client CommonName and client certificate issuer CommonName. smtpd_tls_req_ccert (no) - With mandatory TLS encryption, require a trusted remote SMTP + With mandatory TLS encryption, require a trusted remote SMTP client certificate in order to allow TLS connections to proceed. smtpd_tls_wrappermode (no) - Run the Postfix SMTP server in the non-standard "wrapper" mode, + Run the Postfix SMTP server in the non-standard "wrapper" mode, instead of using the STARTTLS command. tls_daemon_random_bytes (32) - The number of pseudo-random bytes that an smtp(8) or smtpd(8) - process requests from the tlsmgr(8) server in order to seed its + The number of pseudo-random bytes that an smtp(8) or smtpd(8) + process requests from the tlsmgr(8) server in order to seed its internal pseudo random number generator (PRNG). tls_high_cipherlist (see 'postconf -d' output) @@ -497,41 +503,41 @@ SMTPD(8) SMTPD(8) The OpenSSL cipherlist for "export" or higher grade ciphers. tls_null_cipherlist (eNULL:!aNULL) - The OpenSSL cipherlist for "NULL" grade ciphers that provide + The OpenSSL cipherlist for "NULL" grade ciphers that provide authentication without encryption. Available in Postfix version 2.5 and later: smtpd_tls_fingerprint_digest (md5) - The message digest algorithm to construct remote SMTP - client-certificate fingerprints or public key fingerprints - (Postfix 2.9 and later) for check_ccert_access and per- + The message digest algorithm to construct remote SMTP + client-certificate fingerprints or public key fingerprints + (Postfix 2.9 and later) for check_ccert_access and per- mit_tls_clientcerts. Available in Postfix version 2.6 and later: smtpd_tls_protocols (!SSLv2, !SSLv3) - List of TLS protocols that the Postfix SMTP server will exclude + List of TLS protocols that the Postfix SMTP server will exclude or include with opportunistic TLS encryption. smtpd_tls_ciphers (medium) - The minimum TLS cipher grade that the Postfix SMTP server will + The minimum TLS cipher grade that the Postfix SMTP server will use with opportunistic TLS encryption. smtpd_tls_eccert_file (empty) - File with the Postfix SMTP server ECDSA certificate in PEM for- + File with the Postfix SMTP server ECDSA certificate in PEM for- mat. smtpd_tls_eckey_file ($smtpd_tls_eccert_file) - File with the Postfix SMTP server ECDSA private key in PEM for- + File with the Postfix SMTP server ECDSA private key in PEM for- mat. smtpd_tls_eecdh_grade (see 'postconf -d' output) - The Postfix SMTP server security grade for ephemeral ellip- + The Postfix SMTP server security grade for ephemeral ellip- tic-curve Diffie-Hellman (EECDH) key exchange. tls_eecdh_strong_curve (prime256v1) - The elliptic curve used by the Postfix SMTP server for sensibly + The elliptic curve used by the Postfix SMTP server for sensibly strong ephemeral ECDH key exchange. tls_eecdh_ultra_curve (secp384r1) @@ -542,7 +548,7 @@ SMTPD(8) SMTPD(8) tls_preempt_cipherlist (no) With SSLv3 and later, use the Postfix SMTP server's cipher pref- - erence order instead of the remote client's cipher preference + erence order instead of the remote client's cipher preference order. tls_disable_workarounds (see 'postconf -d' output) @@ -555,17 +561,17 @@ SMTPD(8) SMTPD(8) Available in Postfix version 3.0 and later: - tls_session_ticket_cipher (Postfix >= 3.0: aes-256-cbc, Postfix < 3.0: + tls_session_ticket_cipher (Postfix >= 3.0: aes-256-cbc, Postfix < 3.0: aes-128-cbc) Algorithm used to encrypt RFC5077 TLS session tickets. OBSOLETE STARTTLS CONTROLS - The following configuration parameters exist for compatibility with - Postfix versions before 2.3. Support for these will be removed in a + The following configuration parameters exist for compatibility with + Postfix versions before 2.3. Support for these will be removed in a future release. smtpd_use_tls (no) - Opportunistic TLS: announce STARTTLS support to remote SMTP + Opportunistic TLS: announce STARTTLS support to remote SMTP clients, but do not require that clients use TLS encryption. smtpd_enforce_tls (no) @@ -573,85 +579,85 @@ SMTPD(8) SMTPD(8) and require that clients use TLS encryption. smtpd_tls_cipherlist (empty) - Obsolete Postfix < 2.3 control for the Postfix SMTP server TLS + Obsolete Postfix < 2.3 control for the Postfix SMTP server TLS cipher list. SMTPUTF8 CONTROLS Preliminary SMTPUTF8 support is introduced with Postfix 3.0. smtputf8_enable (yes) - Enable preliminary SMTPUTF8 support for the protocols described + Enable preliminary SMTPUTF8 support for the protocols described in RFC 6531..6533. strict_smtputf8 (no) Enable stricter enforcement of the SMTPUTF8 protocol. smtputf8_autodetect_classes (sendmail, verify) - Detect that a message requires SMTPUTF8 support for the speci- + Detect that a message requires SMTPUTF8 support for the speci- fied mail origin classes. VERP SUPPORT CONTROLS - With VERP style delivery, each recipient of a message receives a cus- - tomized copy of the message with his/her own recipient address encoded + With VERP style delivery, each recipient of a message receives a cus- + tomized copy of the message with his/her own recipient address encoded in the envelope sender address. The VERP_README file describes config- - uration and operation details of Postfix support for variable envelope - return path addresses. VERP style delivery is requested with the SMTP - XVERP command or with the "sendmail -V" command-line option and is + uration and operation details of Postfix support for variable envelope + return path addresses. VERP style delivery is requested with the SMTP + XVERP command or with the "sendmail -V" command-line option and is available in Postfix version 1.1 and later. default_verp_delimiters (+=) The two default VERP delimiter characters. verp_delimiter_filter (-=+) - The characters Postfix accepts as VERP delimiter characters on + The characters Postfix accepts as VERP delimiter characters on the Postfix sendmail(1) command line and in SMTP commands. Available in Postfix version 1.1 and 2.0: authorized_verp_clients ($mynetworks) - What remote SMTP clients are allowed to specify the XVERP com- + What remote SMTP clients are allowed to specify the XVERP com- mand. Available in Postfix version 2.1 and later: smtpd_authorized_verp_clients ($authorized_verp_clients) - What remote SMTP clients are allowed to specify the XVERP com- + What remote SMTP clients are allowed to specify the XVERP com- mand. TROUBLE SHOOTING CONTROLS - The DEBUG_README document describes how to debug parts of the Postfix - mail system. The methods vary from making the software log a lot of + The DEBUG_README document describes how to debug parts of the Postfix + mail system. The methods vary from making the software log a lot of detail, to running some daemon processes under control of a call tracer or debugger. debug_peer_level (2) - The increment in verbose logging level when a remote client or + The increment in verbose logging level when a remote client or server matches a pattern in the debug_peer_list parameter. debug_peer_list (empty) - Optional list of remote client or server hostname or network + Optional list of remote client or server hostname or network address patterns that cause the verbose logging level to increase by the amount specified in $debug_peer_level. error_notice_recipient (postmaster) - The recipient of postmaster notifications about mail delivery + The recipient of postmaster notifications about mail delivery problems that are caused by policy, resource, software or proto- col errors. internal_mail_filter_classes (empty) - What categories of Postfix-generated mail are subject to - before-queue content inspection by non_smtpd_milters, + What categories of Postfix-generated mail are subject to + before-queue content inspection by non_smtpd_milters, header_checks and body_checks. notify_classes (resource, software) The list of error classes that are reported to the postmaster. smtpd_reject_footer (empty) - Optional information that is appended after each Postfix SMTP + Optional information that is appended after each Postfix SMTP server 4XX or 5XX response. soft_bounce (no) - Safety net to keep mail queued that would otherwise be returned + Safety net to keep mail queued that would otherwise be returned to the sender. Available in Postfix version 2.1 and later: @@ -662,105 +668,105 @@ SMTPD(8) SMTPD(8) Available in Postfix version 2.10 and later: smtpd_log_access_permit_actions (empty) - Enable logging of the named "permit" actions in SMTP server - access lists (by default, the SMTP server logs "reject" actions + Enable logging of the named "permit" actions in SMTP server + access lists (by default, the SMTP server logs "reject" actions but not "permit" actions). KNOWN VERSUS UNKNOWN RECIPIENT CONTROLS - As of Postfix version 2.0, the SMTP server rejects mail for unknown + As of Postfix version 2.0, the SMTP server rejects mail for unknown recipients. This prevents the mail queue from clogging up with undeliv- - erable MAILER-DAEMON messages. Additional information on this topic is + erable MAILER-DAEMON messages. Additional information on this topic is in the LOCAL_RECIPIENT_README and ADDRESS_CLASS_README documents. show_user_unknown_table_name (yes) - Display the name of the recipient table in the "User unknown" + Display the name of the recipient table in the "User unknown" responses. canonical_maps (empty) - Optional address mapping lookup tables for message headers and + Optional address mapping lookup tables for message headers and envelopes. recipient_canonical_maps (empty) - Optional address mapping lookup tables for envelope and header + Optional address mapping lookup tables for envelope and header recipient addresses. Parameters concerning known/unknown local recipients: mydestination ($myhostname, localhost.$mydomain, localhost) - The list of domains that are delivered via the $local_transport + The list of domains that are delivered via the $local_transport mail delivery transport. inet_interfaces (all) - The network interface addresses that this mail system receives + The network interface addresses that this mail system receives mail on. proxy_interfaces (empty) - The network interface addresses that this mail system receives + The network interface addresses that this mail system receives mail on by way of a proxy or network address translation unit. inet_protocols (all) - The Internet protocols Postfix will attempt to use when making + The Internet protocols Postfix will attempt to use when making or accepting connections. local_recipient_maps (proxy:unix:passwd.byname $alias_maps) Lookup tables with all names or addresses of local recipients: a - recipient address is local when its domain matches $mydestina- + recipient address is local when its domain matches $mydestina- tion, $inet_interfaces or $proxy_interfaces. unknown_local_recipient_reject_code (550) The numerical Postfix SMTP server response code when a recipient - address is local, and $local_recipient_maps specifies a list of + address is local, and $local_recipient_maps specifies a list of lookup tables that does not match the recipient. Parameters concerning known/unknown recipients of relay destinations: relay_domains (Postfix >= 3.0: empty, Postfix < 3.0: $mydestination) - What destination domains (and subdomains thereof) this system + What destination domains (and subdomains thereof) this system will relay mail to. relay_recipient_maps (empty) - Optional lookup tables with all valid addresses in the domains + Optional lookup tables with all valid addresses in the domains that match $relay_domains. unknown_relay_recipient_reject_code (550) - The numerical Postfix SMTP server reply code when a recipient - address matches $relay_domains, and relay_recipient_maps speci- - fies a list of lookup tables that does not match the recipient + The numerical Postfix SMTP server reply code when a recipient + address matches $relay_domains, and relay_recipient_maps speci- + fies a list of lookup tables that does not match the recipient address. - Parameters concerning known/unknown recipients in virtual alias + Parameters concerning known/unknown recipients in virtual alias domains: virtual_alias_domains ($virtual_alias_maps) - Postfix is final destination for the specified list of virtual - alias domains, that is, domains for which all addresses are + Postfix is final destination for the specified list of virtual + alias domains, that is, domains for which all addresses are aliased to addresses in other local or remote domains. virtual_alias_maps ($virtual_maps) - Optional lookup tables that alias specific mail addresses or + Optional lookup tables that alias specific mail addresses or domains to other local or remote address. unknown_virtual_alias_reject_code (550) - The Postfix SMTP server reply code when a recipient address - matches $virtual_alias_domains, and $virtual_alias_maps speci- - fies a list of lookup tables that does not match the recipient + The Postfix SMTP server reply code when a recipient address + matches $virtual_alias_domains, and $virtual_alias_maps speci- + fies a list of lookup tables that does not match the recipient address. Parameters concerning known/unknown recipients in virtual mailbox domains: virtual_mailbox_domains ($virtual_mailbox_maps) - Postfix is final destination for the specified list of domains; - mail is delivered via the $virtual_transport mail delivery + Postfix is final destination for the specified list of domains; + mail is delivered via the $virtual_transport mail delivery transport. virtual_mailbox_maps (empty) - Optional lookup tables with all valid addresses in the domains + Optional lookup tables with all valid addresses in the domains that match $virtual_mailbox_domains. unknown_virtual_mailbox_reject_code (550) - The Postfix SMTP server reply code when a recipient address - matches $virtual_mailbox_domains, and $virtual_mailbox_maps + The Postfix SMTP server reply code when a recipient address + matches $virtual_mailbox_domains, and $virtual_mailbox_maps specifies a list of lookup tables that does not match the recip- ient address. @@ -769,7 +775,7 @@ SMTPD(8) SMTPD(8) control client request rates. line_length_limit (2048) - Upon input, long lines are chopped up into pieces of at most + Upon input, long lines are chopped up into pieces of at most this length; upon delivery, long lines are reconstructed. queue_minfree (0) @@ -777,58 +783,58 @@ SMTPD(8) SMTPD(8) tem that is needed to receive mail. message_size_limit (10240000) - The maximal size in bytes of a message, including envelope + The maximal size in bytes of a message, including envelope information. smtpd_recipient_limit (1000) - The maximal number of recipients that the Postfix SMTP server + The maximal number of recipients that the Postfix SMTP server accepts per message delivery request. smtpd_timeout (normal: 300s, overload: 10s) - The time limit for sending a Postfix SMTP server response and + The time limit for sending a Postfix SMTP server response and for receiving a remote SMTP client request. smtpd_history_flush_threshold (100) - The maximal number of lines in the Postfix SMTP server command - history before it is flushed upon receipt of EHLO, RSET, or end + The maximal number of lines in the Postfix SMTP server command + history before it is flushed upon receipt of EHLO, RSET, or end of DATA. Available in Postfix version 2.3 and later: smtpd_peername_lookup (yes) - Attempt to look up the remote SMTP client hostname, and verify + Attempt to look up the remote SMTP client hostname, and verify that the name matches the client IP address. The per SMTP client connection count and request rate limits are imple- - mented in co-operation with the anvil(8) service, and are available in + mented in co-operation with the anvil(8) service, and are available in Postfix version 2.2 and later. smtpd_client_connection_count_limit (50) - How many simultaneous connections any client is allowed to make + How many simultaneous connections any client is allowed to make to this service. smtpd_client_connection_rate_limit (0) - The maximal number of connection attempts any client is allowed + The maximal number of connection attempts any client is allowed to make to this service per time unit. smtpd_client_message_rate_limit (0) - The maximal number of message delivery requests that any client - is allowed to make to this service per time unit, regardless of + The maximal number of message delivery requests that any client + is allowed to make to this service per time unit, regardless of whether or not Postfix actually accepts those messages. smtpd_client_recipient_rate_limit (0) - The maximal number of recipient addresses that any client is - allowed to send to this service per time unit, regardless of + The maximal number of recipient addresses that any client is + allowed to send to this service per time unit, regardless of whether or not Postfix actually accepts those recipients. smtpd_client_event_limit_exceptions ($mynetworks) - Clients that are excluded from smtpd_client_*_count/rate_limit + Clients that are excluded from smtpd_client_*_count/rate_limit restrictions. Available in Postfix version 2.3 and later: smtpd_client_new_tls_session_rate_limit (0) - The maximal number of new (i.e., uncached) TLS sessions that a + The maximal number of new (i.e., uncached) TLS sessions that a remote SMTP client is allowed to negotiate with this service per time unit. @@ -836,68 +842,68 @@ SMTPD(8) SMTPD(8) smtpd_per_record_deadline (normal: no, overload: yes) Change the behavior of the smtpd_timeout and smtpd_start- - tls_timeout time limits, from a time limit per read or write - system call, to a time limit to send or receive a complete - record (an SMTP command line, SMTP response line, SMTP message + tls_timeout time limits, from a time limit per read or write + system call, to a time limit to send or receive a complete + record (an SMTP command line, SMTP response line, SMTP message content line, or TLS protocol message). Available in Postfix version 3.1 and later: smtpd_client_auth_rate_limit (0) - The maximal number of AUTH commands that any client is allowed - to send to this service per time unit, regardless of whether or + The maximal number of AUTH commands that any client is allowed + to send to this service per time unit, regardless of whether or not Postfix actually accepts those commands. TARPIT CONTROLS - When a remote SMTP client makes errors, the Postfix SMTP server can - insert delays before responding. This can help to slow down run-away - software. The behavior is controlled by an error counter that counts + When a remote SMTP client makes errors, the Postfix SMTP server can + insert delays before responding. This can help to slow down 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. smtpd_error_sleep_time (1s) - 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 + 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. smtpd_soft_error_limit (10) - The number of errors a remote SMTP client is allowed to make - without delivering mail before the Postfix SMTP server slows + The number of errors a remote SMTP client is allowed to make + without delivering mail before the Postfix SMTP server slows down all its responses. smtpd_hard_error_limit (normal: 20, overload: 1) - The maximal number of errors a remote SMTP client is allowed to + The maximal number of errors a remote SMTP client is allowed to make without delivering mail. smtpd_junk_command_limit (normal: 100, overload: 1) - The number of junk commands (NOOP, VRFY, ETRN or RSET) that a - remote SMTP client can send before the Postfix SMTP server + The number of junk commands (NOOP, VRFY, ETRN or RSET) that a + remote SMTP client can send before the Postfix SMTP server starts to increment the error counter with each junk command. Available in Postfix version 2.1 and later: smtpd_recipient_overshoot_limit (1000) - The number of recipients that a remote SMTP client can send in + The number of recipients that a remote SMTP client can send in excess of the limit specified with $smtpd_recipient_limit, - before the Postfix SMTP server increments the per-session error + before the Postfix SMTP server increments the per-session error count for each excess recipient. ACCESS POLICY DELEGATION CONTROLS - As of version 2.1, Postfix can be configured to delegate access policy - decisions to an external server that runs outside Postfix. See the + As of version 2.1, Postfix can be configured to delegate access policy + decisions to an external server that runs outside Postfix. See the file SMTPD_POLICY_README for more information. smtpd_policy_service_max_idle (300s) - The time after which an idle SMTPD policy service connection is + The time after which an idle SMTPD policy service connection is closed. smtpd_policy_service_max_ttl (1000s) - The time after which an active SMTPD policy service connection + The time after which an active SMTPD policy service connection is closed. smtpd_policy_service_timeout (100s) - The time limit for connecting to, writing to, or receiving from + The time limit for connecting to, writing to, or receiving from a delegated SMTPD policy server. Available in Postfix version 3.0 and later: @@ -907,81 +913,81 @@ SMTPD(8) SMTPD(8) The default action when an SMTPD policy service request fails. smtpd_policy_service_request_limit (0) - The maximal number of requests per SMTPD policy service connec- + The maximal number of requests per SMTPD policy service connec- tion, or zero (no limit). smtpd_policy_service_try_limit (2) - The maximal number of attempts to send an SMTPD policy service + The maximal number of attempts to send an SMTPD policy service request before giving up. smtpd_policy_service_retry_delay (1s) - The delay between attempts to resend a failed SMTPD policy ser- + The delay between attempts to resend a failed SMTPD policy ser- vice request. Available in Postfix version 3.1 and later: smtpd_policy_service_policy_context (empty) - Optional information that the Postfix SMTP server specifies in - the "policy_context" attribute of a policy service request - (originally, to share the same service endpoint among multiple + Optional information that the Postfix SMTP server specifies in + the "policy_context" attribute of a policy service request + (originally, to share the same service endpoint among multiple check_policy_service clients). ACCESS CONTROLS - The SMTPD_ACCESS_README document gives an introduction to all the SMTP + The SMTPD_ACCESS_README document gives an introduction to all the SMTP server access control features. smtpd_delay_reject (yes) - Wait until the RCPT TO command before evaluating + Wait until the RCPT TO command before evaluating $smtpd_client_restrictions, $smtpd_helo_restrictions and $smtpd_sender_restrictions, or wait until the ETRN command - before evaluating $smtpd_client_restrictions and + before evaluating $smtpd_client_restrictions and $smtpd_helo_restrictions. parent_domain_matches_subdomains (see 'postconf -d' output) - A list of Postfix features where the pattern "example.com" also - matches subdomains of example.com, instead of requiring an + A list of Postfix features where the pattern "example.com" also + matches subdomains of example.com, instead of requiring an explicit ".example.com" pattern. smtpd_client_restrictions (empty) - Optional restrictions that the Postfix SMTP server applies in + Optional restrictions that the Postfix SMTP server applies in the context of a client connection request. smtpd_helo_required (no) - Require that a remote SMTP client introduces itself with the - HELO or EHLO command before sending the MAIL command or other + Require that a remote SMTP client introduces itself with the + HELO or EHLO command before sending the MAIL command or other commands that require EHLO negotiation. smtpd_helo_restrictions (empty) - Optional restrictions that the Postfix SMTP server applies in + Optional restrictions that the Postfix SMTP server applies in the context of a client HELO command. smtpd_sender_restrictions (empty) - Optional restrictions that the Postfix SMTP server applies in + Optional restrictions that the Postfix SMTP server applies in the context of a client MAIL FROM command. smtpd_recipient_restrictions (see 'postconf -d' output) - Optional restrictions that the Postfix SMTP server applies in - the context of a client RCPT TO command, after + Optional restrictions that the Postfix SMTP server applies in + the context of a client RCPT TO command, after smtpd_relay_restrictions. smtpd_etrn_restrictions (empty) - Optional restrictions that the Postfix SMTP server applies in + Optional restrictions that the Postfix SMTP server applies in the context of a client ETRN command. allow_untrusted_routing (no) - Forward mail with sender-specified routing - (user[@%!]remote[@%!]site) from untrusted clients to destina- + Forward mail with sender-specified routing + (user[@%!]remote[@%!]site) from untrusted clients to destina- tions matching $relay_domains. smtpd_restriction_classes (empty) User-defined aliases for groups of access restrictions. smtpd_null_access_lookup_key (<>) - The lookup key to be used in SMTP access(5) tables instead of + The lookup key to be used in SMTP access(5) tables instead of the null sender address. permit_mx_backup_networks (empty) - Restrict the use of the permit_mx_backup SMTP access feature to + Restrict the use of the permit_mx_backup SMTP access feature to only domains whose primary MX hosts match the listed networks. Available in Postfix version 2.0 and later: @@ -991,19 +997,19 @@ SMTPD(8) SMTPD(8) applies in the context of the SMTP DATA command. smtpd_expansion_filter (see 'postconf -d' output) - What characters are allowed in $name expansions of RBL reply + What characters are allowed in $name expansions of RBL reply templates. Available in Postfix version 2.1 and later: smtpd_reject_unlisted_sender (no) - Request that the Postfix SMTP server rejects mail from unknown - sender addresses, even when no explicit reject_unlisted_sender + Request that the Postfix SMTP server rejects mail from unknown + sender addresses, even when no explicit reject_unlisted_sender access restriction is specified. smtpd_reject_unlisted_recipient (yes) - Request that the Postfix SMTP server rejects mail for unknown - recipient addresses, even when no explicit + Request that the Postfix SMTP server rejects mail for unknown + recipient addresses, even when no explicit reject_unlisted_recipient access restriction is specified. Available in Postfix version 2.2 and later: @@ -1017,17 +1023,17 @@ SMTPD(8) SMTPD(8) smtpd_relay_restrictions (permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination) Access restrictions for mail relay control that the Postfix SMTP - server applies in the context of the RCPT TO command, before + server applies in the context of the RCPT TO command, before smtpd_recipient_restrictions. SENDER AND RECIPIENT ADDRESS VERIFICATION CONTROLS - Postfix version 2.1 introduces sender and recipient address verifica- + Postfix version 2.1 introduces sender and recipient address verifica- tion. This feature is implemented by sending probe email messages that are not actually delivered. This feature is requested via the - reject_unverified_sender and reject_unverified_recipient access - restrictions. The status of verification probes is maintained by the - verify(8) server. See the file ADDRESS_VERIFICATION_README for infor- - mation about how to configure and operate the Postfix sender/recipient + reject_unverified_sender and reject_unverified_recipient access + restrictions. The status of verification probes is maintained by the + verify(8) server. See the file ADDRESS_VERIFICATION_README for infor- + mation about how to configure and operate the Postfix sender/recipient address verification service. address_verify_poll_count (normal: 3, overload: 1) @@ -1039,7 +1045,7 @@ SMTPD(8) SMTPD(8) fication request in progress. address_verify_sender ($double_bounce_sender) - The sender address to use in address verification probes; prior + The sender address to use in address verification probes; prior to Postfix 2.5 the default was "postmaster". unverified_sender_reject_code (450) @@ -1047,18 +1053,18 @@ SMTPD(8) SMTPD(8) address is rejected by the reject_unverified_sender restriction. unverified_recipient_reject_code (450) - The numerical Postfix SMTP server response when a recipient - address is rejected by the reject_unverified_recipient restric- + The numerical Postfix SMTP server response when a recipient + address is rejected by the reject_unverified_recipient restric- tion. Available in Postfix version 2.6 and later: unverified_sender_defer_code (450) - The numerical Postfix SMTP server response code when a sender + The numerical Postfix SMTP server response code when a sender address probe fails due to a temporary error condition. unverified_recipient_defer_code (450) - The numerical Postfix SMTP server response when a recipient + The numerical Postfix SMTP server response when a recipient address probe fails due to a temporary error condition. unverified_sender_reject_reason (empty) @@ -1070,17 +1076,17 @@ SMTPD(8) SMTPD(8) reject_unverified_recipient. unverified_sender_tempfail_action ($reject_tempfail_action) - The Postfix SMTP server's action when reject_unverified_sender + The Postfix SMTP server's action when reject_unverified_sender fails due to a temporary error condition. unverified_recipient_tempfail_action ($reject_tempfail_action) - The Postfix SMTP server's action when reject_unverified_recipi- + The Postfix SMTP server's action when reject_unverified_recipi- ent fails due to a temporary error condition. Available with Postfix 2.9 and later: address_verify_sender_ttl (0s) - The time between changes in the time-dependent portion of + The time between changes in the time-dependent portion of address verification probe sender addresses. ACCESS CONTROL RESPONSES @@ -1092,36 +1098,36 @@ SMTPD(8) SMTPD(8) map "reject" action. defer_code (450) - The numerical Postfix SMTP server response code when a remote + The numerical Postfix SMTP server response code when a remote SMTP client request is rejected by the "defer" restriction. invalid_hostname_reject_code (501) - The numerical Postfix SMTP server response code when the client - HELO or EHLO command parameter is rejected by the + The numerical Postfix SMTP server response code when the client + HELO or EHLO command parameter is rejected by the reject_invalid_helo_hostname restriction. maps_rbl_reject_code (554) - The numerical Postfix SMTP server response code when a remote - SMTP client request is blocked by the reject_rbl_client, + The numerical Postfix SMTP server response code when a remote + SMTP client request is blocked by the reject_rbl_client, reject_rhsbl_client, reject_rhsbl_reverse_client, reject_rhsbl_sender or reject_rhsbl_recipient restriction. non_fqdn_reject_code (504) - The numerical Postfix SMTP server reply code when a client - request is rejected by the reject_non_fqdn_helo_hostname, + The numerical Postfix SMTP server reply code when a client + request is rejected by the reject_non_fqdn_helo_hostname, reject_non_fqdn_sender or reject_non_fqdn_recipient restriction. plaintext_reject_code (450) - The numerical Postfix SMTP server response code when a request + The numerical Postfix SMTP server response code when a request is rejected by the reject_plaintext_session restriction. reject_code (554) - The numerical Postfix SMTP server response code when a remote + The numerical Postfix SMTP server response code when a remote SMTP client request is rejected by the "reject" restriction. relay_domains_reject_code (554) - The numerical Postfix SMTP server response code when a client - request is rejected by the reject_unauth_destination recipient + The numerical Postfix SMTP server response code when a client + request is rejected by the reject_unauth_destination recipient restriction. unknown_address_reject_code (450) @@ -1129,24 +1135,24 @@ SMTPD(8) SMTPD(8) a sender or recipient address because its domain is unknown. unknown_client_reject_code (450) - The numerical Postfix SMTP server response code when a client - without valid address <=> name mapping is rejected by the + The numerical Postfix SMTP server response code when a client + without valid address <=> name mapping is rejected by the reject_unknown_client_hostname restriction. unknown_hostname_reject_code (450) - The numerical Postfix SMTP server response code when the host- - name specified with the HELO or EHLO command is rejected by the + The numerical Postfix SMTP server response code when the host- + name specified with the HELO or EHLO command is rejected by the reject_unknown_helo_hostname restriction. Available in Postfix version 2.0 and later: default_rbl_reply (see 'postconf -d' output) - The default Postfix SMTP server response template for a request + The default Postfix SMTP server response template for a request that is rejected by an RBL-based restriction. multi_recipient_bounce_reject_code (550) - The numerical Postfix SMTP server response code when a remote - SMTP client request is blocked by the reject_multi_recipi- + The numerical Postfix SMTP server response code when a remote + SMTP client request is blocked by the reject_multi_recipi- ent_bounce restriction. rbl_reply_maps (empty) @@ -1156,52 +1162,52 @@ SMTPD(8) SMTPD(8) access_map_defer_code (450) The numerical Postfix SMTP server response code for an access(5) - map "defer" action, including "defer_if_permit" or + map "defer" action, including "defer_if_permit" or "defer_if_reject". reject_tempfail_action (defer_if_permit) - The Postfix SMTP server's action when a reject-type restriction + The Postfix SMTP server's action when a reject-type restriction fails due to a temporary error condition. unknown_helo_hostname_tempfail_action ($reject_tempfail_action) - The Postfix SMTP server's action when reject_unknown_helo_host- + The Postfix SMTP server's action when reject_unknown_helo_host- name fails due to an temporary error condition. unknown_address_tempfail_action ($reject_tempfail_action) - The Postfix SMTP server's action when - reject_unknown_sender_domain or reject_unknown_recipient_domain + The Postfix SMTP server's action when + reject_unknown_sender_domain or reject_unknown_recipient_domain fail due to a temporary error condition. MISCELLANEOUS CONTROLS config_directory (see 'postconf -d' output) - The default location of the Postfix main.cf and master.cf con- + The default location of the Postfix main.cf and master.cf con- figuration files. daemon_timeout (18000s) - How much time a Postfix daemon process may take to handle a + How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. command_directory (see 'postconf -d' output) The location of all postfix administrative commands. double_bounce_sender (double-bounce) - The sender address of postmaster notifications that are gener- + The sender address of postmaster notifications that are gener- ated by the mail system. ipc_timeout (3600s) - The time limit for sending or receiving information over an + The time limit for sending or receiving information over an internal communication channel. mail_name (Postfix) - The mail system name that is displayed in Received: headers, in + The mail system name that is displayed in Received: headers, in the SMTP greeting banner, and in bounced mail. mail_owner (postfix) - The UNIX system account that owns the Postfix queue and most + The UNIX system account that owns the Postfix queue and most Postfix daemon processes. max_idle (100s) - The maximum amount of time that an idle Postfix daemon process + The maximum amount of time that an idle Postfix daemon process waits for an incoming connection before terminating voluntarily. max_use (100) @@ -1212,11 +1218,11 @@ SMTPD(8) SMTPD(8) The internet hostname of this mail system. mynetworks (see 'postconf -d' output) - The list of "trusted" remote SMTP clients that have more privi- + The list of "trusted" remote SMTP clients that have more privi- leges than "strangers". myorigin ($myhostname) - The domain name that locally-posted mail appears to come from, + The domain name that locally-posted mail appears to come from, and that locally posted mail is delivered to. process_id (read-only) @@ -1229,25 +1235,25 @@ SMTPD(8) SMTPD(8) The location of the Postfix top-level queue directory. recipient_delimiter (empty) - The set of characters that can separate a user name from its - extension (example: user+foo), or a .forward file name from its + The set of characters that can separate a user name from its + extension (example: user+foo), or a .forward file name from its extension (example: .forward+foo). smtpd_banner ($myhostname ESMTP $mail_name) - The text that follows the 220 status code in the SMTP greeting + The text that follows the 220 status code in the SMTP greeting banner. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (see 'postconf -d' output) - A prefix that is prepended to the process name in syslog + A prefix that is prepended to the process name in syslog records, so that, for example, "smtpd" becomes "prefix/smtpd". Available in Postfix version 2.2 and later: smtpd_forbidden_commands (CONNECT, GET, POST) - List of commands that cause the Postfix SMTP server to immedi- + List of commands that cause the Postfix SMTP server to immedi- ately terminate the session with a 221 code. Available in Postfix version 2.5 and later: diff --git a/postfix/man/man5/postconf.5 b/postfix/man/man5/postconf.5 index 1cebf490d..fb7dfa9ed 100644 --- a/postfix/man/man5/postconf.5 +++ b/postfix/man/man5/postconf.5 @@ -9827,6 +9827,41 @@ Examples: .ft R .PP This feature is available in Postfix 2.10 and later. +.SH smtpd_milter_maps (default: empty) +Lookup tables with Milter settings per remote SMTP client IP +address. The lookup result overrides the smtpd_milters setting, +and has the same syntax. +.PP +Note: lookup tables cannot return empty responses. Specify a +lookup result of DISABLE (case does not matter) to indicate that +Milter support should be disabled. +.PP +Example to disable Milters for local clients: +.PP +.nf +.na +.ft C +/etc/postfix/main.cf: + smtpd_milter_maps = cidr:/etc/postfix/smtpd_milter_map + smtpd_milters = inet:host:port, { inet:host:port, ... }, ... +.fi +.ad +.ft R +.PP +.nf +.na +.ft C +/etc/postfix/smtpd_milter_map: + # Disable Milters for local clients. + 127.0.0.0/8 DISABLE + 192.168.0.0/16 DISABLE + ::/64 DISABLE + 2001:db8::/32 DISABLE +.fi +.ad +.ft R +.PP +This feature is available in Postfix 3.2 and later. .SH smtpd_milters (default: empty) A list of Milter (mail filter) applications for new mail that arrives via the Postfix \fBsmtpd\fR(8) server. Specify space or comma as diff --git a/postfix/man/man8/smtpd.8 b/postfix/man/man8/smtpd.8 index acc8d06c7..b6381d4bb 100644 --- a/postfix/man/man8/smtpd.8 +++ b/postfix/man/man8/smtpd.8 @@ -284,6 +284,11 @@ Available in Postfix version 3.1 and later: Optional list of \fIname=value\fR pairs that specify default values for arbitrary macros that Postfix may send to Milter applications. +.PP +Available in Postfix version 3.2 and later: +.IP "\fBsmtpd_milter_maps (empty)\fR" +Lookup tables with Milter settings per remote SMTP client IP +address. .SH "GENERAL CONTENT INSPECTION CONTROLS" .na .nf diff --git a/postfix/mantools/postlink b/postfix/mantools/postlink index 2bb97ccf9..cb3515e96 100755 --- a/postfix/mantools/postlink +++ b/postfix/mantools/postlink @@ -550,6 +550,7 @@ while (<>) { s;\bsmtpd_history_flush_threshold\b;$&;g; s;\bsmtpd_junk_command_limit\b;$&;g; s;\bsmtpd_milters\b;$&;g; + s;\bsmtpd_milter_maps\b;$&;g; s;\bsmtpd_noop_commands\b;$&;g; s;\bsmtpd_null_access_lookup_key\b;$&;g; s;\bsmtpd_recipient_overshoot_limit\b;$&;g; diff --git a/postfix/proto/MILTER_README.html b/postfix/proto/MILTER_README.html index eb6873569..6ccc8a6df 100644 --- a/postfix/proto/MILTER_README.html +++ b/postfix/proto/MILTER_README.html @@ -259,6 +259,9 @@ support per-Milter timeouts, per-Milter error handling, etc.

  • Different settings for different Milter applications +
  • Different settings for different SMTP +clients +
  • Sendmail macro emulation
  • What macros will Postfix send to Milters? @@ -320,6 +323,11 @@ form inet:port@host.

    +

    For advanced configuration see "Different +settings for different SMTP clients" and "Different settings for different Milter +applications".

    +

    Non-SMTP Milter applications

    The non-SMTP Milter applications handle mail that arrives via @@ -564,6 +572,29 @@ main.cf: items separated by space or comma. There is one difference: }", if you want to have space or comma within a value or around "=".

    +

    Different settings for different SMTP +clients

    + +

    The smtpd_milter_maps feature supports different Milter settings +for different client IP addresses. Lookup results override the the +global smtpd_milters setting, and have the same syntax. For example, +to disable Milter settings for local address ranges:

    + +
    +/etc/postfix/main.cf:
    +    smtpd_milter_maps = cidr:/etc/postfix/smtpd_milter_map
    +    smtpd_milters = inet:host:port, { inet:host:port, ... }, ...
    +
    +/etc/postfix/smtpd_milter_map:
    +    # Disable Milters for local clients.
    +    127.0.0.0/8    DISABLE
    +    192.168.0.0/16 DISABLE
    +    ::/64          DISABLE
    +    2001:db8::/32  DISABLE
    +
    + +

    This feature is available with Postfix 3.2 and later.

    +

    Sendmail macro emulation

    Postfix emulates a limited number of Sendmail macros, as shown diff --git a/postfix/proto/postconf.proto b/postfix/proto/postconf.proto index 8bc5e6d36..89ffe6cc1 100644 --- a/postfix/proto/postconf.proto +++ b/postfix/proto/postconf.proto @@ -16675,3 +16675,32 @@ the verify(8) daemon automatically refreshes an active address before it expires.

    This feature is available in Postfix 3.1 and later.

    + +%PARAM smtpd_milter_maps + +

    Lookup tables with Milter settings per remote SMTP client IP +address. The lookup result overrides the smtpd_milters setting, +and has the same syntax.

    + +

    Note: lookup tables cannot return empty responses. Specify a +lookup result of DISABLE (case does not matter) to indicate that +Milter support should be disabled.

    + +

    Example to disable Milters for local clients:

    + +
    +/etc/postfix/main.cf:
    +    smtpd_milter_maps = cidr:/etc/postfix/smtpd_milter_map
    +    smtpd_milters = inet:host:port, { inet:host:port, ... }, ...
    +
    + +
    +/etc/postfix/smtpd_milter_map:
    +    # Disable Milters for local clients.
    +    127.0.0.0/8    DISABLE
    +    192.168.0.0/16 DISABLE
    +    ::/64          DISABLE
    +    2001:db8::/32  DISABLE
    +
    + +

    This feature is available in Postfix 3.2 and later.

    diff --git a/postfix/src/global/mail_params.h b/postfix/src/global/mail_params.h index b4b51eb6d..c7ccc7f04 100644 --- a/postfix/src/global/mail_params.h +++ b/postfix/src/global/mail_params.h @@ -3250,6 +3250,11 @@ extern bool var_tls_dane_taa_dgst; #define DEF_SMTPD_MILTERS "" extern char *var_smtpd_milters; +#define VAR_SMTPD_MILTER_MAPS "smtpd_milter_maps" +#define DEF_SMTPD_MILTER_MAPS "" +extern char *var_smtpd_milter_maps; +#define SMTPD_MILTERS_DISABLE "DISABLE" + #define VAR_CLEANUP_MILTERS "non_smtpd_milters" #define DEF_CLEANUP_MILTERS "" extern char *var_cleanup_milters; diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 03afe4a55..d24f7c293 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 "20161008" +#define MAIL_RELEASE_DATE "20161101" #define MAIL_VERSION_NUMBER "3.2" #ifdef SNAPSHOT diff --git a/postfix/src/smtpd/smtpd.c b/postfix/src/smtpd/smtpd.c index 6e2a194f8..d94d585f3 100644 --- a/postfix/src/smtpd/smtpd.c +++ b/postfix/src/smtpd/smtpd.c @@ -258,6 +258,11 @@ /* Optional list of \fIname=value\fR pairs that specify default /* values for arbitrary macros that Postfix may send to Milter /* applications. +/* .PP +/* Available in Postfix version 3.2 and later: +/* .IP "\fBsmtpd_milter_maps (empty)\fR" +/* Lookup tables with Milter settings per remote SMTP client IP +/* address. /* GENERAL CONTENT INSPECTION CONTROLS /* .ad /* .fi @@ -1355,6 +1360,7 @@ bool var_smtpd_peername_lookup; int var_plaintext_code; bool var_smtpd_delay_open; char *var_smtpd_milters; +char *var_smtpd_milter_maps; int var_milt_conn_time; int var_milt_cmd_time; int var_milt_msg_time; @@ -1402,6 +1408,13 @@ int var_smtpd_uproxy_tmout; */ static MAPS *ehlo_discard_maps; + /* + * Per-client Milter support. + */ +static MAPS *smtpd_milter_maps; +static void setup_milters(SMTPD_STATE *); +static void teardown_milters(SMTPD_STATE *); + /* * VERP command name. */ @@ -1459,11 +1472,6 @@ static void tls_reset(SMTPD_STATE *); #define REASON_LOST_CONNECTION "lost connection" #define REASON_ERROR_LIMIT "too many errors" - /* - * Mail filter initialization status. - */ -MILTERS *smtpd_milters; - #ifdef USE_TLS /* @@ -1640,10 +1648,9 @@ static int helo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) #define PUSH_STRING(old, curr, new) { char *old = (curr); (curr) = (new); #define POP_STRING(old, curr) (curr) = old; } - if (smtpd_milters != 0 - && SMTPD_STAND_ALONE(state) == 0 + if (state->milters != 0 && (state->saved_flags & MILTER_SKIP_FLAGS) == 0 - && (err = milter_helo_event(smtpd_milters, argv[1].strval, 0)) != 0) { + && (err = milter_helo_event(state->milters, argv[1].strval, 0)) != 0) { /* Log reject etc. with correct HELO information. */ PUSH_STRING(saved_helo, state->helo_name, argv[1].strval); err = check_milter_reply(state, err); @@ -1726,10 +1733,9 @@ static int ehlo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) * other commands such as AUTH, STARTTLS, and VRFY. */ err = 0; - if (smtpd_milters != 0 - && SMTPD_STAND_ALONE(state) == 0 + if (state->milters != 0 && (state->saved_flags & MILTER_SKIP_FLAGS) == 0 - && (err = milter_helo_event(smtpd_milters, argv[1].strval, 1)) != 0) { + && (err = milter_helo_event(state->milters, argv[1].strval, 1)) != 0) { /* Log reject etc. with correct HELO information. */ PUSH_STRING(saved_helo, state->helo_name, argv[1].strval); err = check_milter_reply(state, err); @@ -1904,8 +1910,8 @@ static void helo_reset(SMTPD_STATE *state) if (state->helo_name) { myfree(state->helo_name); state->helo_name = 0; - if (SMTPD_STAND_ALONE(state) == 0 && smtpd_milters != 0) - milter_abort(smtpd_milters); + if (state->milters != 0) + milter_abort(state->milters); } if (state->ehlo_argv) { argv_free(state->ehlo_argv); @@ -2036,10 +2042,10 @@ static int mail_open_stream(SMTPD_STATE *state) state->cleanup = state->dest->stream; state->queue_id = mystrdup(state->dest->id); if (SMTPD_STAND_ALONE(state) == 0) { - if (smtpd_milters != 0 + if (state->milters != 0 && (state->saved_flags & MILTER_SKIP_FLAGS) == 0) /* Send place-holder smtpd_milters list. */ - (void) milter_dummy(smtpd_milters, state->cleanup); + (void) milter_dummy(state->milters, state->cleanup); rec_fprintf(state->cleanup, REC_TYPE_TIME, REC_TYPE_TIME_FORMAT, REC_TYPE_TIME_ARG(state->arrival_time)); if (*var_filter_xport) @@ -2533,11 +2539,10 @@ static int mail_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) smtpd_chat_reply(state, "%s", err); return (-1); } - if (smtpd_milters != 0 - && SMTPD_STAND_ALONE(state) == 0 + if (state->milters != 0 && (state->saved_flags & MILTER_SKIP_FLAGS) == 0) { PUSH_STRING(saved_sender, state->sender, STR(state->addr_buf)); - err = milter_mail_event(smtpd_milters, + err = milter_mail_event(state->milters, milter_argv(state, argc - 2, argv + 2)); if (err != 0) { /* Log reject etc. with correct sender information. */ @@ -2653,8 +2658,8 @@ static void mail_reset(SMTPD_STATE *state) state->queue_id = 0; } if (state->sender) { - if (SMTPD_STAND_ALONE(state) == 0 && smtpd_milters != 0) - milter_abort(smtpd_milters); + if (state->milters != 0) + milter_abort(state->milters); myfree(state->sender); state->sender = 0; } @@ -2868,11 +2873,11 @@ static int rcpt_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) } else { err = smtpd_check_rcpt(state, STR(state->addr_buf)); } - if (smtpd_milters != 0 + if (state->milters != 0 && (state->saved_flags & MILTER_SKIP_FLAGS) == 0) { PUSH_STRING(saved_rcpt, state->recipient, STR(state->addr_buf)); state->milter_reject_text = err; - milter_err = milter_rcpt_event(smtpd_milters, + milter_err = milter_rcpt_event(state->milters, err == 0 ? MILTER_FLAG_NONE : MILTER_FLAG_WANT_RCPT_REJ, milter_argv(state, argc - 2, argv + 2)); @@ -3143,10 +3148,9 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv) smtpd_chat_reply(state, "%s", err); return (-1); } - if (smtpd_milters != 0 - && SMTPD_STAND_ALONE(state) == 0 + if (state->milters != 0 && (state->saved_flags & MILTER_SKIP_FLAGS) == 0 - && (err = milter_data_event(smtpd_milters)) != 0 + && (err = milter_data_event(state->milters)) != 0 && (err = check_milter_reply(state, err)) != 0) { smtpd_chat_reply(state, "%s", err); return (-1); @@ -3186,10 +3190,10 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv) */ if (state->cleanup) { if (SMTPD_STAND_ALONE(state) == 0) { - if (smtpd_milters != 0 + if (state->milters != 0 && (state->saved_flags & MILTER_SKIP_FLAGS) == 0) /* Send actual smtpd_milters list. */ - (void) milter_send(smtpd_milters, state->cleanup); + (void) milter_send(state->milters, state->cleanup); if (state->saved_flags) rec_fprintf(state->cleanup, REC_TYPE_FLGS, "%d", state->saved_flags); @@ -3437,7 +3441,7 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv) * XXX See exception below in code that overrides state->access_denied for * compliance with RFC 2821 Sec 3.1. */ - if (smtpd_milters != 0 && (state->err & CLEANUP_STAT_WRITE) != 0) + if (state->milters != 0 && (state->err & CLEANUP_STAT_WRITE) != 0) state->access_denied = mystrdup("421 4.3.0 Mail system error"); /* @@ -3658,7 +3662,7 @@ static int vrfy_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) state->addr); return (-1); } - if (smtpd_milters != 0 && (err = milter_other_event(smtpd_milters)) != 0 + if (state->milters != 0 && (err = milter_other_event(state->milters)) != 0 && (err[0] == '5' || err[0] == '4')) { state->error_mask |= MAIL_ERROR_POLICY; smtpd_chat_reply(state, "%s", err); @@ -3713,7 +3717,7 @@ static int etrn_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) smtpd_chat_reply(state, "503 Error: send HELO/EHLO first"); return (-1); } - if (smtpd_milters != 0 && (err = milter_other_event(smtpd_milters)) != 0 + if (state->milters != 0 && (err = milter_other_event(state->milters)) != 0 && (err[0] == '5' || err[0] == '4')) { state->error_mask |= MAIL_ERROR_POLICY; smtpd_chat_reply(state, "%s", err); @@ -4154,8 +4158,11 @@ static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) chat_reset(state, 0); mail_reset(state); rcpt_reset(state); - if (smtpd_milters) - milter_disc_event(smtpd_milters); + if (state->milters) + milter_disc_event(state->milters); + /* Following duplicates the top-level connect/disconnect handler. */ + teardown_milters(state); + setup_milters(state); vstream_longjmp(state->client, SMTP_ERR_NONE); return (0); } @@ -4634,7 +4641,7 @@ static int starttls_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv) smtpd_chat_reply(state, "501 5.5.4 Syntax: STARTTLS"); return (-1); } - if (smtpd_milters != 0 && (err = milter_other_event(smtpd_milters)) != 0) { + if (state->milters != 0 && (err = milter_other_event(state->milters)) != 0) { if (err[0] == '5') { state->error_mask |= MAIL_ERROR_POLICY; smtpd_chat_reply(state, "%s", err); @@ -5035,10 +5042,10 @@ static void smtpd_proto(SMTPD_STATE *state) */ else { err = 0; - if (smtpd_milters != 0 && SMTPD_STAND_ALONE(state) == 0) { - milter_macro_callback(smtpd_milters, smtpd_milter_eval, + if (state->milters != 0) { + milter_macro_callback(state->milters, smtpd_milter_eval, (void *) state); - if ((err = milter_conn_event(smtpd_milters, state->name, + if ((err = milter_conn_event(state->milters, state->name, state->addr, strcmp(state->port, CLIENT_PORT_UNKNOWN) ? state->port : "0", @@ -5163,9 +5170,8 @@ static void smtpd_proto(SMTPD_STATE *state) } /* state->access_denied == 0 || cmdp->action == quit_cmd */ if (cmdp->name == 0) { - if (smtpd_milters != 0 - && SMTPD_STAND_ALONE(state) == 0 - && (err = milter_unknown_event(smtpd_milters, + if (state->milters != 0 + && (err = milter_unknown_event(state->milters, argv[0].strval)) != 0 && (err = check_milter_reply(state, err)) != 0) { smtpd_chat_reply(state, "%s", err); @@ -5270,8 +5276,8 @@ static void smtpd_proto(SMTPD_STATE *state) chat_reset(state, 0); mail_reset(state); rcpt_reset(state); - if (smtpd_milters) - milter_disc_event(smtpd_milters); + if (state->milters) + milter_disc_event(state->milters); } /* smtpd_format_cmd_stats - format per-command statistics */ @@ -5313,6 +5319,59 @@ static char *smtpd_format_cmd_stats(VSTRING *buf) return (lowercase(STR(buf))); } +/* setup_milters - set up Milters after a connection is established */ + +static void setup_milters(SMTPD_STATE *state) +{ + const char *milter_string; + + /* + * Postcondition: either state->milters is set, or the + * INPUT_TRANSP_MILTER flag is passed down-stream. + */ + if (SMTPD_STAND_ALONE(state) == 0 + && (smtpd_input_transp_mask & INPUT_TRANSP_MILTER) == 0 + && ((smtpd_milter_maps + && (milter_string = + maps_find(smtpd_milter_maps, state->addr, 0)) != 0) + || *(milter_string = var_smtpd_milters) != 0) + && strcasecmp(milter_string, SMTPD_MILTERS_DISABLE) != 0) { + state->milters = milter_create(milter_string, + var_milt_conn_time, + var_milt_cmd_time, + var_milt_msg_time, + var_milt_protocol, + var_milt_def_action, + var_milt_conn_macros, + var_milt_helo_macros, + var_milt_mail_macros, + var_milt_rcpt_macros, + var_milt_data_macros, + var_milt_eoh_macros, + var_milt_eod_macros, + var_milt_unk_macros, + var_milt_macro_deflts); + } + + /* + * Safety: disable non_smtpd_milters when not sending our own mail filter + * list. Otherwise the next stage could handle this message as a local + * submission. + */ + if (state->milters == 0) + smtpd_input_transp_mask |= INPUT_TRANSP_MILTER; +} + +/* teardown_milters - release resources */ + +static void teardown_milters(SMTPD_STATE *state) +{ + if (state->milters) { + milter_free(state->milters); + state->milters = 0; + } +} + /* smtpd_service - service one client */ @@ -5374,6 +5433,11 @@ static void smtpd_service(VSTREAM *stream, char *service, char **argv) */ debug_peer_check(state.name, state.addr); + /* + * Set up Milters, or disable Milters down-stream. + */ + setup_milters(&state); /* duplicates xclient_cmd */ + /* * Provide the SMTP service. */ @@ -5386,6 +5450,7 @@ static void smtpd_service(VSTREAM *stream, char *service, char **argv) */ msg_info("disconnect from %s%s", state.namaddr, smtpd_format_cmd_stats(state.buffer)); + teardown_milters(&state); /* duplicates xclient_cmd */ smtpd_state_reset(&state); debug_peer_restore(); } @@ -5598,6 +5663,14 @@ static void pre_jail_init(char *unused_name, char **unused_argv) var_smtpd_ehlo_dis_maps, DICT_FLAG_LOCK); + /* + * Per-client Milter support. + */ + if (*var_smtpd_milter_maps) + smtpd_milter_maps = maps_create(VAR_SMTPD_MILTER_MAPS, + var_smtpd_milter_maps, + DICT_FLAG_LOCK); + /* * DNS reply filter. */ @@ -5627,35 +5700,6 @@ static void post_jail_init(char *unused_name, char **unused_argv) smtpd_proxy_opts = smtpd_proxy_parse_opts(VAR_SMTPD_PROXY_OPTS, var_smtpd_proxy_opts); - /* - * Sendmail mail filters. - * - * XXX Should not do this when running in stand-alone mode. But that test - * looks at VSTREAM_IN which is not available at this point. - * - * XXX Disable non_smtpd_milters when not sending our own mail filter list. - */ - if ((smtpd_input_transp_mask & INPUT_TRANSP_MILTER) == 0) { - if (*var_smtpd_milters) - smtpd_milters = milter_create(var_smtpd_milters, - var_milt_conn_time, - var_milt_cmd_time, - var_milt_msg_time, - var_milt_protocol, - var_milt_def_action, - var_milt_conn_macros, - var_milt_helo_macros, - var_milt_mail_macros, - var_milt_rcpt_macros, - var_milt_data_macros, - var_milt_eoh_macros, - var_milt_eod_macros, - var_milt_unk_macros, - var_milt_macro_deflts); - else - smtpd_input_transp_mask |= INPUT_TRANSP_MILTER; - } - /* * Sanity checks. The queue_minfree value should be at least as large as * (process_limit * message_size_limit) but that is unpractical, so we @@ -5865,6 +5909,7 @@ int main(int argc, char **argv) VAR_MILT_DAEMON_NAME, DEF_MILT_DAEMON_NAME, &var_milt_daemon_name, 1, 0, VAR_MILT_V, DEF_MILT_V, &var_milt_v, 1, 0, VAR_MILT_MACRO_DEFLTS, DEF_MILT_MACRO_DEFLTS, &var_milt_macro_deflts, 0, 0, + VAR_SMTPD_MILTER_MAPS, DEF_SMTPD_MILTER_MAPS, &var_smtpd_milter_maps, 0, 0, VAR_STRESS, DEF_STRESS, &var_stress, 0, 0, VAR_UNV_FROM_WHY, DEF_UNV_FROM_WHY, &var_unv_from_why, 0, 0, VAR_UNV_RCPT_WHY, DEF_UNV_RCPT_WHY, &var_unv_rcpt_why, 0, 0, diff --git a/postfix/src/smtpd/smtpd.h b/postfix/src/smtpd/smtpd.h index fdce24929..4facfb080 100644 --- a/postfix/src/smtpd/smtpd.h +++ b/postfix/src/smtpd/smtpd.h @@ -182,6 +182,7 @@ typedef struct { const char **milter_argv; /* SMTP command vector */ ssize_t milter_argc; /* SMTP command vector */ const char *milter_reject_text; /* input to call-back from Milter */ + MILTERS *milters; /* Milter initialization status.*/ /* * EHLO temporary space. diff --git a/postfix/src/smtpd/smtpd_sasl_proto.c b/postfix/src/smtpd/smtpd_sasl_proto.c index a04d9daf6..5a11a87bd 100644 --- a/postfix/src/smtpd/smtpd_sasl_proto.c +++ b/postfix/src/smtpd/smtpd_sasl_proto.c @@ -163,7 +163,7 @@ int smtpd_sasl_auth_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) smtpd_chat_reply(state, "503 5.5.1 Error: MAIL transaction in progress"); return (-1); } - if (smtpd_milters != 0 && (err = milter_other_event(smtpd_milters)) != 0) { + if (state->milters != 0 && (err = milter_other_event(state->milters)) != 0) { if (err[0] == '5') { state->error_mask |= MAIL_ERROR_POLICY; smtpd_chat_reply(state, "%s", err); diff --git a/postfix/src/smtpd/smtpd_state.c b/postfix/src/smtpd/smtpd_state.c index c03dfbef8..7a117a8b2 100644 --- a/postfix/src/smtpd/smtpd_state.c +++ b/postfix/src/smtpd/smtpd_state.c @@ -159,6 +159,7 @@ void smtpd_state_init(SMTPD_STATE *state, VSTREAM *stream, state->milter_argv = 0; state->milter_argc = 0; + state->milters = 0; /* * Initialize peer information.