diff --git a/postfix/HISTORY b/postfix/HISTORY
index c2947e853..5551d5577 100644
--- a/postfix/HISTORY
+++ b/postfix/HISTORY
@@ -16457,3 +16457,17 @@ Apologies for any names omitted.
now configurable, in case someone needs this. Files:
global/mail_params.h, postscreen/postscreen.c, mantools/postlink,
proto/postconf.proto.
+
+20110116
+
+ Cleanup: soft_bounce support for postscreen(8). Files:
+ postscreen/postscreen_smtpd.c, postscreen/postscreen_send.c.
+
+ Cleanup: for smtpd(8) compatibility, postscreen(8) now
+ strips deprecated route address prefixes from email addresses
+ (@here,@there:user@example becomes user@example). This is
+ primarily to make postscreen(8) logging more similar to
+ that of smtpd(8). File: postscreen/postscreen_smtpd.c.
+
+ Cleanup: documentation, in preparation for the Postfix 2.8
+ stable release.
diff --git a/postfix/README_FILES/POSTSCREEN_README b/postfix/README_FILES/POSTSCREEN_README
index 0f83617ae..5e55a0289 100644
--- a/postfix/README_FILES/POSTSCREEN_README
+++ b/postfix/README_FILES/POSTSCREEN_README
@@ -13,15 +13,14 @@ postscreen(8) should not be used on SMTP ports that receive mail from end-user
clients (MUAs). In a typical deployment, postscreen(8) is used on the "port 25"
service, while MUA clients submit mail via the submission service.
-postscreen(8) is the first layer in a multi-layer defense.
+postscreen(8) is part of a multi-layer defense.
- * The postscreen(8) layer blocks connections from zombies and other spambots
- that are responsible for about 90% of all spam. It is implemented as a
- single process to make this defense as cheap as possible.
+ * As the first layer, postscreen(8) blocks connections from zombies and other
+ spambots that are responsible for about 90% of all spam. It is implemented
+ as a single process to make this defense as cheap as possible.
- * The second layer implements more complex SMTP-level access checks that are
- available with Postfix SMTP servers, policy daemons, and Milter
- applications.
+ * The second layer implements more complex SMTP-level access checks with
+ Postfix SMTP servers, policy daemons, and Milter applications.
* The third layer performs light-weight content inspection with the Postfix
built-in header_checks and body_checks. This can block unacceptable
@@ -482,14 +481,29 @@ TTuurrnniinngg oonn ppoossttssccrreeeenn((88)) wwiitth
To enable the postscreen(8) service and log client information without blocking
mail:
- 1. Comment out the "smtp inet ... smtpd" service in master.cf, including any
+ 1. Make sure that local clients and systems with non-standard SMTP
+ implementations are excluded from any postscreen(8) tests. The default is
+ to exclude all clients in mynetworks. To exclude additional clients, for
+ example, third-party performance monitoring tools (these tend to have
+ broken SMTP implementations):
+
+ /etc/postfix/main.cf:
+ # Exclude broken clients by whitelisting. Clients in mynetworks
+ # should always be whitelisted.
+ postscreen_access_list = permit_mynetworks,
+ cidr:/etc/postfix/postscreen_access.cidr
+
+ /etc/postfix/postscreen_access.cidr:
+ 192.168.254.0/24 permit
+
+ 2. Comment out the "smtp inet ... smtpd" service in master.cf, including any
"-o parameter=value" entries that follow.
/etc/postfix/master.cf:
#smtp inet n - n - - smtpd
# -o parameter=value ...
- 2. Uncomment the new "smtpd pass ... smtpd" service in master.cf, and
+ 3. Uncomment the new "smtpd pass ... smtpd" service in master.cf, and
duplicate any "-o parameter=value" entries from the smtpd service that was
commented out in step 1.
@@ -497,24 +511,24 @@ mail:
smtpd pass - - n - - smtpd
-o parameter=value ...
- 3. Uncomment the new "smtp inet ... postscreen" service in master.cf.
+ 4. Uncomment the new "smtp inet ... postscreen" service in master.cf.
/etc/postfix/master.cf:
smtp inet n - n - 1 postscreen
- 4. Uncomment the new "tlsproxy unix ... tlsproxy" service in master.cf. This
+ 5. Uncomment the new "tlsproxy unix ... tlsproxy" service in master.cf. This
service implements STARTTLS support for postscreen(8).
/etc/postfix/master.cf:
tlsproxy unix - - n - 0 tlsproxy
- 5. Uncomment the new "dnsblog unix ... dnsblog" service in master.cf. This
+ 6. Uncomment the new "dnsblog unix ... dnsblog" service in master.cf. This
service does DNSBL lookups for postscreen(8) and logs results.
/etc/postfix/master.cf:
dnsblog unix - - n - 0 dnsblog
- 6. To enable DNSBL lookups, list some DNS blocklist sites in main.cf,
+ 7. To enable DNSBL lookups, list some DNS blocklist sites in main.cf,
separated by whitespace. Different sites can have different weights. For
example:
@@ -537,7 +551,7 @@ mail:
run postmap(1) before the file can be used, and that it does not detect
changes after the file is read. It is new with Postfix version 2.8.
- 7. Read the new configuration with "postfix reload".
+ 8. Read the new configuration with "postfix reload".
Notes:
@@ -549,9 +563,6 @@ Notes:
* See "Tests before the 220 SMTP server greeting" for details about the
logging from these postscreen(8) tests.
- * By default, postscreen(8) whitelists all clients in mynetworks. This is a
- safety feature to avoid you from getting into trouble with local users.
-
* If you run Postfix 2.6 or earlier you must stop and start the master daemon
("postfix stop; postfix start"). This is needed because the Postfix "pass"
master service type did not work reliably on all systems.
@@ -575,6 +586,20 @@ those same parameter overrides for the postscreen(8) and tlsproxy(8) services.
BBlloocckkiinngg mmaaiill wwiitthh ppoossttssccrreeeenn((88))
+For compatibility with smtpd(8), postscreen(8) implements the soft_bounce
+safety feature. This causes Postfix to reject mail with a "try again" reply
+code.
+
+ * To turn this on for all of Postfix, specify "soft_bounce = yes" in main.cf.
+
+ * To turn this on for postscreen(8) only, append "-o soft_bounce=yes" (note:
+ NO SPACES around '=') to the postscreen entry in master.cf.
+
+Execute "postfix reload" to make the change effective.
+
+After testing, do not forget to remove the soft_bounce feature, otherwise
+senders won't receive their non-delivery notification until many days later.
+
To use the postscreen(8) service to block mail, edit main.cf and specify one or
more of:
diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES
index 5ea4c491f..a9634df67 100644
--- a/postfix/RELEASE_NOTES
+++ b/postfix/RELEASE_NOTES
@@ -1,433 +1,15 @@
-The stable Postfix release is called postfix-2.7.x where 2=major
-release number, 7=minor release number, x=patchlevel. The stable
+The stable Postfix release is called postfix-2.8.x where 2=major
+release number, 8=minor release number, x=patchlevel. The stable
release never changes except for patches that address bugs or
emergencies. Patches change the patchlevel and the release date.
New features are developed in snapshot releases. These are called
-postfix-2.8-yyyymmdd where yyyymmdd is the release date (yyyy=year,
+postfix-2.9-yyyymmdd where yyyymmdd is the release date (yyyy=year,
mm=month, dd=day). Patches are never issued for snapshot releases;
instead, a new snapshot is released.
The mail_release_date configuration parameter (format: yyyymmdd)
specifies the release date of a stable release or snapshot release.
-If you upgrade from Postfix 2.6 or earlier, read RELEASE_NOTES-2.7
+If you upgrade from Postfix 2.7 or earlier, read RELEASE_NOTES-2.8
before proceeding.
-
-Postscreen notes:
-=================
-
-To turn on postscreen, see "Configuring the postscreen(8) service"
-in the POSTSCREEN_README file. This allows you to run postscreen
-without blocking mail first.
-
-The code is rock solid, but the user interface has dozens of
-parameters, so it literally is like using a machine that has wires
-hanging out on all sides. This makes it possible to do research.
-The idea is to reduce the number of parameters once things settle
-down.
-
-NOTE: Some postscreen parameters implement stress-dependent behavior.
-This is supported only when the default value is stress-dependent
-(that is, the default looks like ${stress?XX}${stress:YY}, or it
-is the $name of an smtpd_xxx parameter with a stress-dependent
-default). Other postscreen parameters always evaluate as if the
-stress value is equal to the empty string.
-
-Incompatibility with snapshot 20110111
-======================================
-
-For performance reasons the postscreen_access_list feature replaces
-the postscreen_whitelist_networks and postscreen_blacklist_networks
-features. CIDR-style access maps are some 100x faster than the code
-that implemented the postscreen_white/blacklist_networks support.
-It can match about 100 million CIDR patterns/second on a modern CPU,
-which is not blindingly fast but adequate for the near future.
-
-Major changes with snapshot 20110105
-====================================
-
-The SMTP server now supports contact information that is appended
-to "reject" responses. This includes SMTP server responses that
-aren't logged to the maillog file, such as responses to syntax
-errors, or unsupported commands.
-
-Example:
- smtpd_reject_footer = For assistance, call 800-555-0101.
-
-Server response:
- 550-5.5.1
postscreen(8) is the first layer in a multi-layer defense.
+
postscreen(8) is part of a multi-layer defense.
The postscreen(8) layer blocks connections from zombies -and other spambots that are responsible for about 90% of all spam. -It is implemented as a single process to make this defense as cheap -as possible.
+As the first layer, postscreen(8) blocks connections from +zombies and other spambots that are responsible for about 90% of +all spam. It is implemented as a single process to make this defense +as cheap as possible.
The second layer implements more complex SMTP-level access -checks that are available with Postfix SMTP servers, policy daemons, -and Milter applications.
+checks with Postfix SMTP servers, policy daemons, and Milter +applications.The third layer performs light-weight content inspection with the Postfix built-in header_checks and body_checks. This can @@ -672,6 +672,23 @@ without blocking mail:
Make sure that local clients and systems with non-standard +SMTP implementations are excluded from any postscreen(8) tests. The +default is to exclude all clients in mynetworks. To exclude additional +clients, for example, third-party performance monitoring tools (these +tend to have broken SMTP implementations):
+ ++/etc/postfix/main.cf: + # Exclude broken clients by whitelisting. Clients in mynetworks + # should always be whitelisted. + postscreen_access_list = permit_mynetworks, + cidr:/etc/postfix/postscreen_access.cidr + +/etc/postfix/postscreen_access.cidr: + 192.168.254.0/24 permit ++
Comment out the "smtp inet ... smtpd" service in master.cf, including any "-o parameter=value" entries that follow.
@@ -768,10 +785,6 @@ string. greeting" for details about the logging from these postscreen(8) tests. -By default, postscreen(8) whitelists all clients in -mynetworks. This is a safety feature to avoid you from getting -into trouble with local users.
-If you run Postfix 2.6 or earlier you must stop and start the master daemon ("postfix stop; postfix start"). This is needed because the Postfix "pass" master service type did not @@ -802,6 +815,27 @@ services.
For compatibility with smtpd(8), postscreen(8) implements the +soft_bounce safety feature. This causes Postfix to reject mail with +a "try again" reply code.
+ +To turn this on for all of Postfix, specify "soft_bounce += yes" in main.cf.
+ +To turn this on for postscreen(8) only, append "-o +soft_bounce=yes" (note: NO SPACES around '=') to the postscreen +entry in master.cf.
+ +
Execute "postfix reload" to make the change effective.
+ +After testing, do not forget to remove the soft_bounce feature, +otherwise senders won't receive their non-delivery notification +until many days later.
+To use the postscreen(8) service to block mail, edit main.cf and specify one or more of:
diff --git a/postfix/html/dnsblog.8.html b/postfix/html/dnsblog.8.html index ab257ea38..85de63982 100644 --- a/postfix/html/dnsblog.8.html +++ b/postfix/html/dnsblog.8.html @@ -14,10 +14,11 @@ DNSBLOG(8) DNSBLOG(8) DESCRIPTION The dnsblog(8) server implements an ad-hoc DNS - white/blacklist lookup service that will eventually be + white/blacklist lookup service. This may eventually be replaced by an UDP client that is built directly into the postscreen(8) server. +PROTOCOL With each connection, the dnsblog(8) server receives a DNS white/blacklist domain name and an IP address. If the address is listed under the DNS white/blacklist, the dns- @@ -84,7 +85,7 @@ DNSBLOG(8) DNSBLOG(8) software. HISTORY - This service is temporary with Postfix version 2.7. + This service was introduced with Postfix version 2.8. AUTHOR(S) Wietse Venema diff --git a/postfix/html/postconf.5.html b/postfix/html/postconf.5.html index cc3f97dc6..b879d0a45 100644 --- a/postfix/html/postconf.5.html +++ b/postfix/html/postconf.5.html @@ -6634,7 +6634,7 @@ and enabled instances are processed in reverse order.Permanent white/blacklist for remote SMTP client IP addresses; +
Permanent white/blacklist for remote SMTP client IP addresses. postscreen(8) searches this list immediately after a remote SMTP client connects. Specify a comma- or whitespace-separated list of commands (in upper or lower case) or lookup tables. The search stops @@ -6664,10 +6664,12 @@ server process.
The action that postscreen(8) takes when an SMTP client is -permanently blacklisted with the postscreen_blacklist_networks -parameter. Specify one of the following:
+permanently blacklisted with the postscreen_access_list parameter. +Specify one of the following:The command "read" time limit for postscreen(8)'s built-in SMTP -protocol engine. This bounds the time to receive an entire command. -
+The time limit to read an entire command line with postscreen(8)'s +built-in SMTP protocol engine.
This feature is available in Postfix 2.8.
diff --git a/postfix/html/postscreen.8.html b/postfix/html/postscreen.8.html index a26bf621a..7b459f768 100644 --- a/postfix/html/postscreen.8.html +++ b/postfix/html/postscreen.8.html @@ -71,84 +71,100 @@ POSTSCREEN(8) POSTSCREEN(8) Problems and transactions are logged to syslogd(8). BUGS - The postscreen(8) server does not yet implement the - soft_bounce feature. - - The postscreen(8) built-in SMTP protocol engine currently - does not announce support for AUTH, XCLIENT or XFORWARD. - Support for AUTH may be added in the future. In the mean + The postscreen(8) built-in SMTP protocol engine currently + does not announce support for AUTH, XCLIENT or XFORWARD. + Support for AUTH may be added in the future. In the mean time, if you need to make these services available on port - 25, then do not enable the optional "after 220 server + 25, then do not enable the optional "after 220 server greeting" tests. - The optional "after 220 server greeting" tests involve - postscreen(8)'s built-in SMTP protocol engine. When these + The optional "after 220 server greeting" tests involve + postscreen(8)'s built-in SMTP protocol engine. When these tests succeed, postscreen(8) adds the client to the tempo- - rary whitelist but it cannot not hand off the "live" con- - nection to a Postfix SMTP server process in the middle of - a session. Instead, postscreen(8) defers attempts to - deliver mail with a 4XX status, and waits for the client - to disconnect. The next time a good client connects, it - will be allowed to talk to a Postfix SMTP server process - to deliver mail. postscreen(8) mitigates the impact of - this limitation by giving such tests a long expiration + rary whitelist but it cannot not hand off the "live" con- + nection to a Postfix SMTP server process in the middle of + a session. Instead, postscreen(8) defers attempts to + deliver mail with a 4XX status, and waits for the client + to disconnect. The next time a good client connects, it + will be allowed to talk to a Postfix SMTP server process + to deliver mail. postscreen(8) mitigates the impact of + this limitation by giving such tests a long expiration time. CONFIGURATION PARAMETERS - Changes to main.cf are not picked up automatically, as - postscreen(8) processes may run for several hours. Use + Changes to main.cf are not picked up automatically, as + postscreen(8) processes may run for several hours. Use the command "postfix reload" after a configuration change. - The text below provides only a parameter summary. See + The text below provides only a parameter summary. See postconf(5) for more details including examples. NOTE: Some postscreen(8) parameters implement stress- - dependent behavior. This is supported only when the - default parameter value is stress-dependent (that is, it - looks like ${stress?X}${stress:Y}, or it is the $name of + dependent behavior. This is supported only when the + default parameter value is stress-dependent (that is, it + looks like ${stress?X}${stress:Y}, or it is the $name of an smtpd parameter with a stress-dependent default). - Other parameters always evaluate as if the stress parame- + Other parameters always evaluate as if the stress parame- ter value is the empty string. COMPATIBILITY CONTROLS postscreen_command_filter ($smtpd_command_filter) - A mechanism to transform commands from remote SMTP + A mechanism to transform commands from remote SMTP clients. postscreen_discard_ehlo_keyword_address_maps ($smtpd_dis- card_ehlo_keyword_address_maps) - Lookup tables, indexed by the remote SMTP client - address, with case insensitive lists of EHLO key- - words (pipelining, starttls, auth, etc.) that the - postscreen(8) server will not send in the EHLO + Lookup tables, indexed by the remote SMTP client + address, with case insensitive lists of EHLO key- + words (pipelining, starttls, auth, etc.) that the + postscreen(8) server will not send in the EHLO response to a remote SMTP client. postscreen_discard_ehlo_keywords ($smtpd_discard_ehlo_key- words) - A case insensitive list of EHLO keywords (pipelin- - ing, starttls, auth, etc.) that the postscreen(8) - server will not send in the EHLO response to a + A case insensitive list of EHLO keywords (pipelin- + ing, starttls, auth, etc.) that the postscreen(8) + server will not send in the EHLO response to a remote SMTP client. -BEFORE-GREETING TRIAGE - dnsblog_service_name (dnsblog) - The name of the dnsblog(8) service entry in mas- - ter.cf. +TROUBLE SHOOTING CONTROLS + postscreen_expansion_filter (see 'postconf -d' output) + List of characters that are permitted in + postscreen_reject_footer attribute expansions. + + postscreen_reject_footer ($smtpd_reject_footer) + Optional information that is appended after a 4XX + or 5XX server response. + + soft_bounce (no) + Safety net to keep mail queued that would otherwise + be returned to the sender. + +PERMANENT WHITE/BLACKLIST TEST + This test is executed immediately after a remote SMTP + client connects. If a client is permanently whitelisted, + the client will be handed off immediately to a Postfix + SMTP server process. postscreen_access_list (permit_mynetworks) Permanent white/blacklist for remote SMTP client IP - addresses; postscreen(8) searches this list immedi- - ately after a remote SMTP client connects. + addresses. postscreen_blacklist_action (ignore) - The action that postscreen(8) takes when an SMTP - client is permanently blacklisted with the - postscreen_blacklist_networks parameter. + The action that postscreen(8) takes when an SMTP + client is permanently blacklisted with the + postscreen_access_list parameter. - postscreen_blacklist_networks (empty) - Network addresses that are permanently blacklisted; - see the postscreen_blacklist_action parameter for - possible actions. +BEFORE-GREETING TESTS + These tests are executed before the remote SMTP client + receives the "220 servername" greeting. If no tests remain + after the successful completion of this phase, the client + will be handed off immediately to a Postfix SMTP server + process. + + dnsblog_service_name (dnsblog) + The name of the dnsblog(8) service entry in mas- + ter.cf. postscreen_dnsbl_action (ignore) The action that postscreen(8) takes when an SMTP @@ -191,7 +207,18 @@ POSTSCREEN(8) POSTSCREEN(8) (default: up to 2 seconds under stress, up to 6 seconds otherwise). -AFTER-GREETING TRIAGE + smtpd_service_name (smtpd) + The internal service that postscreen(8) forwards + allowed connections to. + +AFTER-GREETING TESTS + These tests are executed after the remote SMTP client + receives the "220 servername" greeting. If a client passes + all tests during this phase, it will receive a 4XX + response to RCPT TO commands until the client hangs up. + After this, the client will be allowed to talk directly to + a Postfix SMTP server process. + postscreen_bare_newline_action (ignore) The action that postscreen(8) takes when an SMTP client sends a bare newline character, that is, a @@ -231,150 +258,136 @@ POSTSCREEN(8) POSTSCREEN(8) Enable "pipelining" SMTP protocol tests in the postscreen(8) server. -AFTER-TRIAGE CONTROLS - smtpd_service_name (smtpd) - The internal service that postscreen(8) forwards - allowed connections to. - CACHE CONTROLS postscreen_cache_cleanup_interval (12h) - The amount of time between postscreen(8) cache + The amount of time between postscreen(8) cache cleanup runs. postscreen_cache_map (btree:$data_direc- tory/postscreen_cache) - Persistent storage for the postscreen(8) server + Persistent storage for the postscreen(8) server decisions. postscreen_cache_retention_time (7d) The amount of time that postscreen(8) will cache an - expired temporary whitelist entry before it is + expired temporary whitelist entry before it is removed. postscreen_bare_newline_ttl (30d) - The amount of time that postscreen(8) will use the + The amount of time that postscreen(8) will use the result from a successful "bare newline" SMTP proto- col test. postscreen_dnsbl_ttl (1h) - The amount of time that postscreen(8) will use the + The amount of time that postscreen(8) will use the result from a successful DNS blocklist test. postscreen_greet_ttl (1d) - The amount of time that postscreen(8) will use the + The amount of time that postscreen(8) will use the result from a successful PREGREET test. postscreen_non_smtp_command_ttl (30d) - The amount of time that postscreen(8) will use the - result from a successful "non_smtp_command" SMTP + The amount of time that postscreen(8) will use the + result from a successful "non_smtp_command" SMTP protocol test. postscreen_pipelining_ttl (30d) - The amount of time that postscreen(8) will use the + The amount of time that postscreen(8) will use the result from a successful "pipelining" SMTP protocol test. RESOURCE CONTROLS line_length_limit (2048) - Upon input, long lines are chopped up into pieces - of at most this length; upon delivery, long lines + Upon input, long lines are chopped up into pieces + of at most this length; upon delivery, long lines are reconstructed. postscreen_client_connection_count_limit ($smtpd_client_connection_count_limit) - How many simultaneous connections any client is + How many simultaneous connections any client is allowed to have with the postscreen(8) daemon. postscreen_command_count_limit (20) - The limit on the total number of commands per SMTP - session for postscreen(8)'s built-in SMTP protocol + The limit on the total number of commands per SMTP + session for postscreen(8)'s built-in SMTP protocol engine. postscreen_command_time_limit (${stress?10}${stress:300}s) - The command "read" time limit for postscreen(8)'s - built-in SMTP protocol engine. + The time limit to read an entire command line with + postscreen(8)'s built-in SMTP protocol engine. postscreen_post_queue_limit ($default_process_limit) - The number of clients that can be waiting for ser- + The number of clients that can be waiting for ser- vice from a real SMTP server process. postscreen_pre_queue_limit ($default_process_limit) - The number of non-whitelisted clients that can be - waiting for a decision whether they will receive + The number of non-whitelisted clients that can be + waiting for a decision whether they will receive service from a real SMTP server process. postscreen_watchdog_timeout (10s) - How much time a postscreen(8) process may take to - respond to an SMTP client command or to perform a + How much time a postscreen(8) process may take to + respond to an SMTP client command or to perform a cache operation before it is terminated by a built- in watchdog timer. STARTTLS CONTROLS postscreen_tls_security_level ($smtpd_tls_security_level) - The SMTP TLS security level for the postscreen(8) - server; when a non-empty value is specified, this + The SMTP TLS security level for the postscreen(8) + server; when a non-empty value is specified, this overrides the obsolete parameters postscreen_use_tls and postscreen_enforce_tls. tlsproxy_service_name (tlsproxy) - The name of the tlsproxy(8) service entry in mas- + The name of the tlsproxy(8) service entry in mas- ter.cf. OBSOLETE STARTTLS SUPPORT CONTROLS - These parameters are supported for compatibility with + These parameters are supported for compatibility with smtpd(8) legacy parameters. postscreen_use_tls ($smtpd_use_tls) - Opportunistic TLS: announce STARTTLS support to - SMTP clients, but do not require that clients use + Opportunistic TLS: announce STARTTLS support to + SMTP clients, but do not require that clients use TLS encryption. postscreen_enforce_tls ($smtpd_enforce_tls) - Mandatory TLS: announce STARTTLS support to SMTP - clients, and require that clients use TLS encryp- + Mandatory TLS: announce STARTTLS support to SMTP + clients, and require that clients use TLS encryp- tion. -TROUBLE SHOOTING CONTROLS - postscreen_expansion_filter (see 'postconf -d' output) - List of characters that are permitted in - postscreen_reject_footer attribute expansions. - - postscreen_reject_footer ($smtpd_reject_footer) - Optional information that is appended after a 4XX - or 5XX server response. - MISCELLANEOUS CONTROLS config_directory (see 'postconf -d' output) - The default location of the Postfix main.cf and + The default location of the Postfix main.cf and master.cf configuration files. delay_logging_resolution_limit (2) - The maximal number of digits after the decimal + The maximal number of digits after the decimal point when logging sub-second delay values. command_directory (see 'postconf -d' output) - The location of all postfix administrative com- + The location of all postfix administrative com- mands. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for an incoming connection + The maximum amount of time that an idle Postfix + daemon process waits for an incoming connection before terminating voluntarily. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (see 'postconf -d' output) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO @@ -387,12 +400,14 @@ POSTSCREEN(8) POSTSCREEN(8) POSTSCREEN_README, Postfix Postscreen Howto LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. HISTORY - Many ideas in postscreen(8) were explored in earlier work - by Michael Tokarev, in OpenBSD spamd, and in MailChannels + This service was introduced with Postfix version 2.8. + + Many ideas in postscreen(8) were explored in earlier work + by Michael Tokarev, in OpenBSD spamd, and in MailChannels Traffic Control. AUTHOR(S) diff --git a/postfix/man/man5/postconf.5 b/postfix/man/man5/postconf.5 index 9f4b1f693..994b6b3ef 100644 --- a/postfix/man/man5/postconf.5 +++ b/postfix/man/man5/postconf.5 @@ -3729,7 +3729,7 @@ and enabled instances are processed in reverse order. .PP This feature is available in Postfix 2.6 and later. .SH postscreen_access_list (default: permit_mynetworks) -Permanent white/blacklist for remote SMTP client IP addresses; +Permanent white/blacklist for remote SMTP client IP addresses. \fBpostscreen\fR(8) searches this list immediately after a remote SMTP client connects. Specify a comma- or whitespace-separated list of commands (in upper or lower case) or lookup tables. The search stops @@ -3757,11 +3757,16 @@ Blacklist the client and terminate the search. Subject the client to the action configured with the postscreen_blacklist_action configuration parameter. .IP "\fB dunno \fR" -When used inside a lookup table, -return from the lookup table and evaluate the next command. +All \fBpostscreen\fR(8) access lists +implicitly have this command at the end. .br -When used outside a lookup table, terminate the search, and subject -the client to the configured before/after 220 greeting tests. +When \fB dunno \fR +is executed inside a lookup table, return from the lookup table and +evaluate the next command. +.br +When \fB dunno \fR is executed +outside a lookup table, terminate the search, and subject the client +to the configured before/after 220 greeting tests. .PP Example: .PP @@ -3827,8 +3832,8 @@ one-letter suffix that specifies the time unit). Time units: s This feature is available in Postfix 2.8. .SH postscreen_blacklist_action (default: ignore) The action that \fBpostscreen\fR(8) takes when an SMTP client is -permanently blacklisted with the postscreen_blacklist_networks -parameter. Specify one of the following: +permanently blacklisted with the postscreen_access_list parameter. +Specify one of the following: .IP "\fBignore\fR (default)" Ignore this result. Allow other tests to complete. Repeat this test the next time the client connects. @@ -3898,8 +3903,8 @@ See smtpd_command_filter for further details. .PP This feature is available in Postfix 2.8 and later. .SH postscreen_command_time_limit (default: ${stress?10}${stress:300}s) -The command "read" time limit for \fBpostscreen\fR(8)'s built-in SMTP -protocol engine. This bounds the time to receive an entire command. +The time limit to read an entire command line with \fBpostscreen\fR(8)'s +built-in SMTP protocol engine. .PP This feature is available in Postfix 2.8. .SH postscreen_disable_vrfy_command (default: $disable_vrfy_command) diff --git a/postfix/man/man8/dnsblog.8 b/postfix/man/man8/dnsblog.8 index 358efa471..ca6660d8e 100644 --- a/postfix/man/man8/dnsblog.8 +++ b/postfix/man/man8/dnsblog.8 @@ -13,10 +13,14 @@ Postfix DNS white/blacklist logger .ad .fi The \fBdnsblog\fR(8) server implements an ad-hoc DNS -white/blacklist lookup service that will eventually be +white/blacklist lookup service. This may eventually be replaced by an UDP client that is built directly into the \fBpostscreen\fR(8) server. - +.SH "PROTOCOL" +.na +.nf +.ad +.fi With each connection, the \fBdnsblog\fR(8) server receives a DNS white/blacklist domain name and an IP address. If the address is listed under the DNS white/blacklist, the @@ -80,7 +84,7 @@ The Secure Mailer license must be distributed with this software. .nf .ad .fi -This service is temporary with Postfix version 2.7. +This service was introduced with Postfix version 2.8. .SH "AUTHOR(S)" .na .nf diff --git a/postfix/man/man8/postscreen.8 b/postfix/man/man8/postscreen.8 index 735e9a17b..84b85c23a 100644 --- a/postfix/man/man8/postscreen.8 +++ b/postfix/man/man8/postscreen.8 @@ -76,9 +76,6 @@ Problems and transactions are logged to \fBsyslogd\fR(8). .SH BUGS .ad .fi -The \fBpostscreen\fR(8) server does not yet implement -the \fBsoft_bounce\fR feature. - The \fBpostscreen\fR(8) built-in SMTP protocol engine currently does not announce support for AUTH, XCLIENT or XFORWARD. @@ -135,24 +132,46 @@ to a remote SMTP client. A case insensitive list of EHLO keywords (pipelining, starttls, auth, etc.) that the \fBpostscreen\fR(8) server will not send in the EHLO response to a remote SMTP client. -.SH "BEFORE-GREETING TRIAGE" +.SH "TROUBLE SHOOTING CONTROLS" .na .nf .ad .fi -.IP "\fBdnsblog_service_name (dnsblog)\fR" -The name of the \fBdnsblog\fR(8) service entry in master.cf. +.IP "\fBpostscreen_expansion_filter (see 'postconf -d' output)\fR" +List of characters that are permitted in postscreen_reject_footer +attribute expansions. +.IP "\fBpostscreen_reject_footer ($smtpd_reject_footer)\fR" +Optional information that is appended after a 4XX or 5XX server +response. +.IP "\fBsoft_bounce (no)\fR" +Safety net to keep mail queued that would otherwise be returned to +the sender. +.SH "PERMANENT WHITE/BLACKLIST TEST" +.na +.nf +.ad +.fi +This test is executed immediately after a remote SMTP client +connects. If a client is permanently whitelisted, the client +will be handed off immediately to a Postfix SMTP server +process. .IP "\fBpostscreen_access_list (permit_mynetworks)\fR" -Permanent white/blacklist for remote SMTP client IP addresses; -\fBpostscreen\fR(8) searches this list immediately after a remote SMTP -client connects. +Permanent white/blacklist for remote SMTP client IP addresses. .IP "\fBpostscreen_blacklist_action (ignore)\fR" The action that \fBpostscreen\fR(8) takes when an SMTP client is -permanently blacklisted with the postscreen_blacklist_networks -parameter. -.IP "\fBpostscreen_blacklist_networks (empty)\fR" -Network addresses that are permanently blacklisted; see the -postscreen_blacklist_action parameter for possible actions. +permanently blacklisted with the postscreen_access_list parameter. +.SH "BEFORE-GREETING TESTS" +.na +.nf +.ad +.fi +These tests are executed before the remote SMTP client +receives the "220 servername" greeting. If no tests remain +after the successful completion of this phase, the client +will be handed off immediately to a Postfix SMTP server +process. +.IP "\fBdnsblog_service_name (dnsblog)\fR" +The name of the \fBdnsblog\fR(8) service entry in master.cf. .IP "\fBpostscreen_dnsbl_action (ignore)\fR" The action that \fBpostscreen\fR(8) takes when an SMTP client's combined DNSBL score is equal to or greater than a threshold (as defined @@ -184,11 +203,20 @@ The amount of time that \fBpostscreen\fR(8) will wait for an SMTP client to send a command before its turn, and for DNS blocklist lookup results to arrive (default: up to 2 seconds under stress, up to 6 seconds otherwise). -.SH "AFTER-GREETING TRIAGE" +.IP "\fBsmtpd_service_name (smtpd)\fR" +The internal service that \fBpostscreen\fR(8) forwards allowed +connections to. +.SH "AFTER-GREETING TESTS" .na .nf .ad .fi +These tests are executed after the remote SMTP client +receives the "220 servername" greeting. If a client passes +all tests during this phase, it will receive a 4XX response +to RCPT TO commands until the client hangs up. After this, +the client will be allowed to talk directly to a Postfix +SMTP server process. .IP "\fBpostscreen_bare_newline_action (ignore)\fR" The action that \fBpostscreen\fR(8) takes when an SMTP client sends a bare newline character, that is, a newline not preceded by carriage @@ -217,14 +245,6 @@ the server to respond. .IP "\fBpostscreen_pipelining_enable (no)\fR" Enable "pipelining" SMTP protocol tests in the \fBpostscreen\fR(8) server. -.SH "AFTER-TRIAGE CONTROLS" -.na -.nf -.ad -.fi -.IP "\fBsmtpd_service_name (smtpd)\fR" -The internal service that \fBpostscreen\fR(8) forwards allowed -connections to. .SH "CACHE CONTROLS" .na .nf @@ -267,8 +287,8 @@ with the \fBpostscreen\fR(8) daemon. The limit on the total number of commands per SMTP session for \fBpostscreen\fR(8)'s built-in SMTP protocol engine. .IP "\fBpostscreen_command_time_limit (${stress?10}${stress:300}s)\fR" -The command "read" time limit for \fBpostscreen\fR(8)'s built-in SMTP -protocol engine. +The time limit to read an entire command line with \fBpostscreen\fR(8)'s +built-in SMTP protocol engine. .IP "\fBpostscreen_post_queue_limit ($default_process_limit)\fR" The number of clients that can be waiting for service from a real SMTP server process. @@ -304,17 +324,6 @@ but do not require that clients use TLS encryption. .IP "\fBpostscreen_enforce_tls ($smtpd_enforce_tls)\fR" Mandatory TLS: announce STARTTLS support to SMTP clients, and require that clients use TLS encryption. -.SH "TROUBLE SHOOTING CONTROLS" -.na -.nf -.ad -.fi -.IP "\fBpostscreen_expansion_filter (see 'postconf -d' output)\fR" -List of characters that are permitted in postscreen_reject_footer -attribute expansions. -.IP "\fBpostscreen_reject_footer ($smtpd_reject_footer)\fR" -Optional information that is appended after a 4XX or 5XX server -response. .SH "MISCELLANEOUS CONTROLS" .na .nf @@ -368,6 +377,8 @@ The Secure Mailer license must be distributed with this software. .nf .ad .fi +This service was introduced with Postfix version 2.8. + Many ideas in \fBpostscreen\fR(8) were explored in earlier work by Michael Tokarev, in OpenBSD spamd, and in MailChannels Traffic Control. diff --git a/postfix/proto/POSTSCREEN_README.html b/postfix/proto/POSTSCREEN_README.html index 1386efd02..cb7da2cc5 100644 --- a/postfix/proto/POSTSCREEN_README.html +++ b/postfix/proto/POSTSCREEN_README.html @@ -28,18 +28,18 @@ mail from end-user clients (MUAs). In a typical deployment, postscreen(8) is used on the "port 25" service, while MUA clients submit mail via the submission service. -postscreen(8) is the first layer in a multi-layer defense.
+
postscreen(8) is part of a multi-layer defense.
The postscreen(8) layer blocks connections from zombies -and other spambots that are responsible for about 90% of all spam. -It is implemented as a single process to make this defense as cheap -as possible.
+As the first layer, postscreen(8) blocks connections from +zombies and other spambots that are responsible for about 90% of +all spam. It is implemented as a single process to make this defense +as cheap as possible.
The second layer implements more complex SMTP-level access -checks that are available with Postfix SMTP servers, policy daemons, -and Milter applications.
+checks with Postfix SMTP servers, policy daemons, and Milter +applications.The third layer performs light-weight content inspection with the Postfix built-in header_checks and body_checks. This can @@ -672,6 +672,23 @@ without blocking mail:
Make sure that local clients and systems with non-standard +SMTP implementations are excluded from any postscreen(8) tests. The +default is to exclude all clients in mynetworks. To exclude additional +clients, for example, third-party performance monitoring tools (these +tend to have broken SMTP implementations):
+ ++/etc/postfix/main.cf: + # Exclude broken clients by whitelisting. Clients in mynetworks + # should always be whitelisted. + postscreen_access_list = permit_mynetworks, + cidr:/etc/postfix/postscreen_access.cidr + +/etc/postfix/postscreen_access.cidr: + 192.168.254.0/24 permit ++
Comment out the "smtp inet ... smtpd" service in master.cf, including any "-o parameter=value" entries that follow.
@@ -768,10 +785,6 @@ string. greeting" for details about the logging from these postscreen(8) tests. -By default, postscreen(8) whitelists all clients in -mynetworks. This is a safety feature to avoid you from getting -into trouble with local users.
-If you run Postfix 2.6 or earlier you must stop and start the master daemon ("postfix stop; postfix start"). This is needed because the Postfix "pass" master service type did not @@ -802,6 +815,27 @@ services.
For compatibility with smtpd(8), postscreen(8) implements the +soft_bounce safety feature. This causes Postfix to reject mail with +a "try again" reply code.
+ +To turn this on for all of Postfix, specify "soft_bounce += yes" in main.cf.
+ +To turn this on for postscreen(8) only, append "-o +soft_bounce=yes" (note: NO SPACES around '=') to the postscreen +entry in master.cf.
+ +
Execute "postfix reload" to make the change effective.
+ +After testing, do not forget to remove the soft_bounce feature, +otherwise senders won't receive their non-delivery notification +until many days later.
+To use the postscreen(8) service to block mail, edit main.cf and specify one or more of:
diff --git a/postfix/proto/postconf.proto b/postfix/proto/postconf.proto index eea3a2892..4e6df6662 100644 --- a/postfix/proto/postconf.proto +++ b/postfix/proto/postconf.proto @@ -12831,7 +12831,7 @@ IP address. %PARAM postscreen_access_list permit_mynetworks -Permanent white/blacklist for remote SMTP client IP addresses; +
Permanent white/blacklist for remote SMTP client IP addresses. postscreen(8) searches this list immediately after a remote SMTP client connects. Specify a comma- or whitespace-separated list of commands (in upper or lower case) or lookup tables. The search stops @@ -12861,10 +12861,12 @@ server process.
The action that postscreen(8) takes when an SMTP client is -permanently blacklisted with the postscreen_blacklist_networks -parameter. Specify one of the following:
+permanently blacklisted with the postscreen_access_list parameter. +Specify one of the following:The command "read" time limit for postscreen(8)'s built-in SMTP -protocol engine. This bounds the time to receive an entire command. -
+The time limit to read an entire command line with postscreen(8)'s +built-in SMTP protocol engine.
This feature is available in Postfix 2.8.
diff --git a/postfix/src/dnsblog/dnsblog.c b/postfix/src/dnsblog/dnsblog.c index 09cb18d37..89d1f0df7 100644 --- a/postfix/src/dnsblog/dnsblog.c +++ b/postfix/src/dnsblog/dnsblog.c @@ -7,10 +7,12 @@ /* \fBdnsblog\fR [generic Postfix daemon options] /* DESCRIPTION /* The \fBdnsblog\fR(8) server implements an ad-hoc DNS -/* white/blacklist lookup service that will eventually be +/* white/blacklist lookup service. This may eventually be /* replaced by an UDP client that is built directly into the /* \fBpostscreen\fR(8) server. -/* +/* PROTOCOL +/* .ad +/* .fi /* With each connection, the \fBdnsblog\fR(8) server receives /* a DNS white/blacklist domain name and an IP address. If the /* address is listed under the DNS white/blacklist, the @@ -64,7 +66,7 @@ /* HISTORY /* .ad /* .fi -/* This service is temporary with Postfix version 2.7. +/* This service was introduced with Postfix version 2.8. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 3fb73c2f9..a766bc151 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,8 +20,8 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20110115" -#define MAIL_VERSION_NUMBER "2.8" +#define MAIL_RELEASE_DATE "20110116" +#define MAIL_VERSION_NUMBER "2.9" #ifdef SNAPSHOT # define MAIL_VERSION_DATE "-" MAIL_RELEASE_DATE diff --git a/postfix/src/postscreen/postscreen.c b/postfix/src/postscreen/postscreen.c index 0e9d61807..dd3927130 100644 --- a/postfix/src/postscreen/postscreen.c +++ b/postfix/src/postscreen/postscreen.c @@ -62,9 +62,6 @@ /* DIAGNOSTICS /* Problems and transactions are logged to \fBsyslogd\fR(8). /* BUGS -/* The \fBpostscreen\fR(8) server does not yet implement -/* the \fBsoft_bounce\fR feature. -/* /* The \fBpostscreen\fR(8) built-in SMTP protocol engine /* currently does not announce support for AUTH, XCLIENT or /* XFORWARD. @@ -117,22 +114,40 @@ /* A case insensitive list of EHLO keywords (pipelining, starttls, /* auth, etc.) that the \fBpostscreen\fR(8) server will not send in the EHLO /* response to a remote SMTP client. -/* BEFORE-GREETING TRIAGE +/* TROUBLE SHOOTING CONTROLS /* .ad /* .fi -/* .IP "\fBdnsblog_service_name (dnsblog)\fR" -/* The name of the \fBdnsblog\fR(8) service entry in master.cf. +/* .IP "\fBpostscreen_expansion_filter (see 'postconf -d' output)\fR" +/* List of characters that are permitted in postscreen_reject_footer +/* attribute expansions. +/* .IP "\fBpostscreen_reject_footer ($smtpd_reject_footer)\fR" +/* Optional information that is appended after a 4XX or 5XX server +/* response. +/* .IP "\fBsoft_bounce (no)\fR" +/* Safety net to keep mail queued that would otherwise be returned to +/* the sender. +/* PERMANENT WHITE/BLACKLIST TEST +/* .ad +/* .fi +/* This test is executed immediately after a remote SMTP client +/* connects. If a client is permanently whitelisted, the client +/* will be handed off immediately to a Postfix SMTP server +/* process. /* .IP "\fBpostscreen_access_list (permit_mynetworks)\fR" -/* Permanent white/blacklist for remote SMTP client IP addresses; -/* \fBpostscreen\fR(8) searches this list immediately after a remote SMTP -/* client connects. +/* Permanent white/blacklist for remote SMTP client IP addresses. /* .IP "\fBpostscreen_blacklist_action (ignore)\fR" /* The action that \fBpostscreen\fR(8) takes when an SMTP client is -/* permanently blacklisted with the postscreen_blacklist_networks -/* parameter. -/* .IP "\fBpostscreen_blacklist_networks (empty)\fR" -/* Network addresses that are permanently blacklisted; see the -/* postscreen_blacklist_action parameter for possible actions. +/* permanently blacklisted with the postscreen_access_list parameter. +/* BEFORE-GREETING TESTS +/* .ad +/* .fi +/* These tests are executed before the remote SMTP client +/* receives the "220 servername" greeting. If no tests remain +/* after the successful completion of this phase, the client +/* will be handed off immediately to a Postfix SMTP server +/* process. +/* .IP "\fBdnsblog_service_name (dnsblog)\fR" +/* The name of the \fBdnsblog\fR(8) service entry in master.cf. /* .IP "\fBpostscreen_dnsbl_action (ignore)\fR" /* The action that \fBpostscreen\fR(8) takes when an SMTP client's combined /* DNSBL score is equal to or greater than a threshold (as defined @@ -164,9 +179,18 @@ /* client to send a command before its turn, and for DNS blocklist /* lookup results to arrive (default: up to 2 seconds under stress, /* up to 6 seconds otherwise). -/* AFTER-GREETING TRIAGE +/* .IP "\fBsmtpd_service_name (smtpd)\fR" +/* The internal service that \fBpostscreen\fR(8) forwards allowed +/* connections to. +/* AFTER-GREETING TESTS /* .ad /* .fi +/* These tests are executed after the remote SMTP client +/* receives the "220 servername" greeting. If a client passes +/* all tests during this phase, it will receive a 4XX response +/* to RCPT TO commands until the client hangs up. After this, +/* the client will be allowed to talk directly to a Postfix +/* SMTP server process. /* .IP "\fBpostscreen_bare_newline_action (ignore)\fR" /* The action that \fBpostscreen\fR(8) takes when an SMTP client sends /* a bare newline character, that is, a newline not preceded by carriage @@ -195,12 +219,6 @@ /* .IP "\fBpostscreen_pipelining_enable (no)\fR" /* Enable "pipelining" SMTP protocol tests in the \fBpostscreen\fR(8) /* server. -/* AFTER-TRIAGE CONTROLS -/* .ad -/* .fi -/* .IP "\fBsmtpd_service_name (smtpd)\fR" -/* The internal service that \fBpostscreen\fR(8) forwards allowed -/* connections to. /* CACHE CONTROLS /* .ad /* .fi @@ -239,8 +257,8 @@ /* The limit on the total number of commands per SMTP session for /* \fBpostscreen\fR(8)'s built-in SMTP protocol engine. /* .IP "\fBpostscreen_command_time_limit (${stress?10}${stress:300}s)\fR" -/* The command "read" time limit for \fBpostscreen\fR(8)'s built-in SMTP -/* protocol engine. +/* The time limit to read an entire command line with \fBpostscreen\fR(8)'s +/* built-in SMTP protocol engine. /* .IP "\fBpostscreen_post_queue_limit ($default_process_limit)\fR" /* The number of clients that can be waiting for service from a /* real SMTP server process. @@ -272,15 +290,6 @@ /* .IP "\fBpostscreen_enforce_tls ($smtpd_enforce_tls)\fR" /* Mandatory TLS: announce STARTTLS support to SMTP clients, and /* require that clients use TLS encryption. -/* TROUBLE SHOOTING CONTROLS -/* .ad -/* .fi -/* .IP "\fBpostscreen_expansion_filter (see 'postconf -d' output)\fR" -/* List of characters that are permitted in postscreen_reject_footer -/* attribute expansions. -/* .IP "\fBpostscreen_reject_footer ($smtpd_reject_footer)\fR" -/* Optional information that is appended after a 4XX or 5XX server -/* response. /* MISCELLANEOUS CONTROLS /* .ad /* .fi @@ -324,6 +333,8 @@ /* HISTORY /* .ad /* .fi +/* This service was introduced with Postfix version 2.8. +/* /* Many ideas in \fBpostscreen\fR(8) were explored in earlier /* work by Michael Tokarev, in OpenBSD spamd, and in MailChannels /* Traffic Control. diff --git a/postfix/src/postscreen/postscreen_send.c b/postfix/src/postscreen/postscreen_send.c index 9a99997fe..dfb61cf99 100644 --- a/postfix/src/postscreen/postscreen_send.c +++ b/postfix/src/postscreen/postscreen_send.c @@ -22,6 +22,10 @@ /* a warning (except EPIPE) with the client address and port, /* and returns a non-zero result (all errors including EPIPE). /* +/* psc_send_reply() does a best effort to send the reply, but +/* it won't block when the output is throttled by a hostile +/* peer. +/* /* PSC_SEND_REPLY() is a legacy wrapper for psc_send_reply(). /* It will eventually be replaced by its expansion. /* @@ -88,26 +92,26 @@ int psc_send_reply(PSC_STATE *state, const char *text) */ start = VSTRING_LEN(state->send_buf); vstring_strcat(state->send_buf, text); - if (*var_psc_rej_footer && (*text == '4' || *text == '5')) - smtp_reply_footer(state->send_buf, start, var_psc_rej_footer, - STR(psc_expand_filter), psc_expand_lookup, - (char *) state); /* - * XXX For soft_bounce support, it is not sufficient to fix replies here. - * We also need to fix the REJECT messages that are logged by the dummy - * SMTP engine. Those messages are set with the PSC_DROP_SESSION_STATE - * and PSC_ENFORCE_SESSION_STATE macros, and we should not mess up all - * the code that invokes those macros. + * For soft_bounce support, we also fix the REJECT logging before the + * dummy SMTP engine calls the psc_send_reply() output routine. We do + * some double work, but it is for debugging only. */ -#if 0 if (var_soft_bounce) { if (text[0] == '5') STR(state->send_buf)[start + 0] = '4'; if (text[4] == '5') STR(state->send_buf)[start + 4] = '4'; } -#endif + + /* + * Append the optional reply footer. + */ + if (*var_psc_rej_footer && (*text == '4' || *text == '5')) + smtp_reply_footer(state->send_buf, start, var_psc_rej_footer, + STR(psc_expand_filter), psc_expand_lookup, + (char *) state); /* * Do a best effort sending text, but don't block when the output is diff --git a/postfix/src/postscreen/postscreen_smtpd.c b/postfix/src/postscreen/postscreen_smtpd.c index bed1d6661..8e9ec6885 100644 --- a/postfix/src/postscreen/postscreen_smtpd.c +++ b/postfix/src/postscreen/postscreen_smtpd.c @@ -24,8 +24,12 @@ /* /* Unlike the Postfix SMTP server, this engine does not announce /* PIPELINING support. This exposes spambots that pipeline -/* their commands anyway. To pass this test, the client has -/* to speak SMTP all the way to the RCPT TO command. +/* their commands anyway. Like the Postfix SMTP server, this +/* engine will accept input with bare newline characters. To +/* pass the "pipelining" and "bare newline" test, the client +/* has to properly speak SMTP all the way to the RCPT TO +/* command. These tests fail if the client violates the protocol +/* at any stage. /* /* No support is announced for AUTH, XCLIENT or XFORWARD. /* Clients that need this should be whitelisted or should talk @@ -42,10 +46,13 @@ /* a per-session command counter, and terminates the session /* with a 421 reply when the command count exceeds the limit. /* -/* We limit the command count so that we don't have to worry -/* about becoming blocked while sending responses (20 replies -/* of about 40 bytes plus greeting banners). Otherwise we would -/* have to make the output event-driven, just like the input. +/* We limit the command count, as well as the total time to +/* receive a command. This limits the time per client more +/* effectively than would be possible with read() timeouts. +/* +/* There is no concern about getting blocked on output. The +/* psc_send() routine uses non-blocking output, and discards +/* output that the client is not willing to receive. /* PROTOCOL INSPECTION VERSUS CONTENT INSPECTION /* The goal of postscreen is to keep spambots away from Postfix. /* To recognize spambots, postscreen measures properties of @@ -70,11 +77,11 @@ /* making long-term decisions after single measurements, and /* that is why postscreen does not inspect message content. /* REJECTING RCPT TO VERSUS SENDING LIVE SOCKETS TO SMTPD(8) -/* When deep protocol tests are enabled, postscreen rejects -/* the RCPT TO command from a good client, and forces it to -/* deliver mail in a later session. This is why deep protocol -/* tests have a longer expiration time than pre-handshake -/* tests. +/* When post-handshake protocol tests are enabled, postscreen +/* rejects the RCPT TO command from a good client, and forces +/* it to deliver mail in a later session. This is why +/* post-handshake protocol tests have a longer expiration time +/* than pre-handshake tests. /* /* Instead, postscreen could send the network socket to smtpd(8) /* and ship the session history (including TLS and other SMTP @@ -188,7 +195,9 @@ static void psc_smtpd_read_event(int, char *); * Encapsulation. The STARTTLS, EHLO and AUTH command handlers temporarily * suspend SMTP command events, send an asynchronous proxy request, and * resume SMTP command events after receiving the asynchrounous proxy - * response. + * response (the EHLO handler must asynchronously talk to the auth server + * before it can announce the SASL mechanism list; the list can depend on + * the client IP address and on the presence on TLS encryption). */ #define PSC_RESUME_SMTP_CMD_EVENTS(state) do { \ PSC_READ_EVENT_REQUEST2(vstream_fileno((state)->smtp_client_stream), \ @@ -411,15 +420,17 @@ static int psc_starttls_cmd(PSC_STATE *state, char *args) static char *psc_extract_addr(VSTRING *result, const char *string) { const unsigned char *cp = (const unsigned char *) string; + char *addr; + char *colon; int stop_at; int inquote = 0; /* * smtpd(8) incompatibility: we allow more invalid address forms, and we - * don't strip @site1,site2:user@site3 route addresses. We are not going - * to deliver them so we won't have to worry about addresses that end up - * being nonsense after stripping. This may have to change when we pass - * the socket to a real SMTP server and replay message envelope commands. + * don't validate recipients. We are not going to deliver them so we + * won't have to worry about deliverability. This may have to change when + * we pass the socket to a real SMTP server and replay message envelope + * commands. */ /* Skip SP characters. */ @@ -448,7 +459,15 @@ static char *psc_extract_addr(VSTRING *result, const char *string) } } VSTRING_TERMINATE(result); - return (STR(result)); + + /* + * smtpd(8) compatibility: truncate deprecated route address form. This + * is primarily to simplify logfile analysis. + */ + addr = STR(result); + if (*addr == '@' && (colon = strchr(addr, ':')) != 0) + addr = colon + 1; + return (addr); } /* psc_mail_cmd - record MAIL and respond */ @@ -478,6 +497,22 @@ static int psc_mail_cmd(PSC_STATE *state, char *args) return (PSC_SEND_REPLY(state, "250 2.1.0 Ok\r\n")); } +/* psc_soften_reply - copy and soft-bounce a reply */ + +static char *psc_soften_reply(const char *reply) +{ + static VSTRING *buf = 0; + + if (buf == 0) + buf = vstring_alloc(100); + vstring_strcpy(buf, reply); + if (reply[0] == '5') + STR(buf)[0] = '4'; + if (reply[4] == '5') + STR(buf)[4] = '4'; + return (STR(buf)); +} + /* psc_rcpt_cmd record RCPT and respond */ static int psc_rcpt_cmd(PSC_STATE *state, char *args) @@ -501,7 +536,9 @@ static int psc_rcpt_cmd(PSC_STATE *state, char *args) msg_info("NOQUEUE: reject: RCPT from [%s]:%s: %.*s; " "from=<%s>, to=<%s>, proto=%s, helo=<%s>", PSC_CLIENT_ADDR_PORT(state), - (int) strlen(state->rcpt_reply) - 2, state->rcpt_reply, + (int) strlen(state->rcpt_reply) - 2, + var_soft_bounce == 0 ? state->rcpt_reply : + psc_soften_reply(state->rcpt_reply), state->sender, addr, state->protocol, state->helo_name ? state->helo_name : ""); return (PSC_SEND_REPLY(state, state->rcpt_reply)); @@ -700,7 +737,7 @@ static void psc_smtpd_read_event(int event, char *context) */ /* - * Note: on entry into this function the VSTREAM buffer is still empty, + * Note: on entry into this function the VSTREAM buffer may be non-empty, * so we test the "no more input" condition at the bottom of the loops. */ for (;;) { @@ -825,7 +862,8 @@ static void psc_smtpd_read_event(int event, char *context) /* * Reset the command buffer write pointer and state machine in * preparation for the next command. For this to work as expected, - * VSTRING_RESET() must be non-destructive. + * VSTRING_RESET() must be non-destructive. We just can't ask for the + * VSTRING_LEN() and vstring_end() results. */ state->read_state = PSC_SMTPD_CMD_ST_ANY; VSTRING_RESET(state->cmd_buffer); @@ -837,7 +875,7 @@ static void psc_smtpd_read_event(int event, char *context) * session state structure. When this happens we must leave the SMTP * engine to avoid a dangling pointer problem. */ - cmd_buffer_ptr = vstring_str(state->cmd_buffer); + cmd_buffer_ptr = STR(state->cmd_buffer); if (msg_verbose) msg_info("< [%s]:%s: %s", state->smtp_client_addr, state->smtp_client_port, cmd_buffer_ptr);