From 9a4873a236ca1d6240cda41d0f209d8f3fb4bf8c Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Fri, 29 Sep 2000 00:00:00 -0500 Subject: [PATCH] snapshot-20000929 --- postfix/ETRN_README | 60 ++++++++---- postfix/RELEASE_NOTES | 50 ++++++++-- postfix/conf/etrn | 110 --------------------- postfix/conf/main.cf | 14 +++ postfix/conf/sample-misc.cf | 10 -- postfix/conf/sample-smtpd.cf | 44 ++++----- postfix/html/Makefile.in | 6 +- postfix/html/etrn.5.html | 134 -------------------------- postfix/html/flushd.8.html | 56 +++++------ postfix/html/sendmail.1.html | 82 ++++++++-------- postfix/html/smtpd.8.html | 138 +++++++++++++-------------- postfix/html/uce.html | 11 +-- postfix/man/Makefile.in | 6 +- postfix/man/man1/sendmail.1 | 16 +--- postfix/man/man5/etrn.5 | 101 -------------------- postfix/man/man8/flushd.8 | 23 ++--- postfix/man/man8/smtpd.8 | 25 +++-- postfix/proto/Makefile.in | 5 +- postfix/proto/etrn | 88 ----------------- postfix/src/flushd/flushd.c | 120 +++++++---------------- postfix/src/global/deliver_request.c | 10 ++ postfix/src/global/mail_flush.c | 24 +++-- postfix/src/global/mail_flush.h | 2 +- postfix/src/global/mail_params.c | 3 + postfix/src/global/mail_params.h | 19 ++-- postfix/src/global/mail_queue.c | 5 + postfix/src/global/mail_version.h | 2 +- postfix/src/nqmgr/qmgr.c | 6 -- postfix/src/nqmgr/qmgr.h | 1 - postfix/src/nqmgr/qmgr_defer.c | 4 + postfix/src/nqmgr/qmgr_deliver.c | 6 -- postfix/src/postsuper/postsuper.c | 4 + postfix/src/qmgr/Makefile.in | 1 - postfix/src/qmgr/qmgr.c | 6 -- postfix/src/qmgr/qmgr.h | 1 - postfix/src/qmgr/qmgr_defer.c | 4 + postfix/src/qmgr/qmgr_deliver.c | 7 -- postfix/src/qmgr/qmgr_message.c | 5 + postfix/src/sendmail/sendmail.c | 19 +--- postfix/src/smtpd/smtpd.c | 89 +++++++++++------ postfix/src/smtpd/smtpd_check.c | 86 ++++++++++------- postfix/src/smtpd/smtpd_check.h | 1 + 42 files changed, 497 insertions(+), 907 deletions(-) delete mode 100644 postfix/conf/etrn delete mode 100644 postfix/html/etrn.5.html delete mode 100644 postfix/man/man5/etrn.5 delete mode 100644 postfix/proto/etrn diff --git a/postfix/ETRN_README b/postfix/ETRN_README index c94a14847..dba879d8d 100644 --- a/postfix/ETRN_README +++ b/postfix/ETRN_README @@ -1,33 +1,59 @@ Enabling the Postfix fast ETRN service ====================================== -Add an entry to the master.cf file for the new flush daemon: +Postfix "fast ETRN" speeds up deliveries by looking only at mail +that is queued for a given destination site. Postfix ordinary ETRN +attempts to deliver all queued mail. Postfix fast ETRN service is +available only for destinations that the local MTA is willing to +relay mail to. + +But first you need to configure Postfix to provide fast ETRN service. + +- Execute "postfix stop" + +- Execute "make install" if you are running an older Postfix version + that does not have "fast flush" logfile support, + +- Add a "flush" service entry to /etc/postfix/master.cf if you were + running an older Postfix version: - /etc/postfix/master.cf: flush unix n - n - 0 flushd -Configure a list of domains that have fast ETRN service and -what clients can use the service: +- Execute "postconf hash_queue_names" and verify that the output + includes at the very least the "active", "bounce", "defer", and + "flush" queue names. If any queue name is missing, edit the + main.cf file and either delete the explicit hash_queue_names + entry, or add the missing queue names. + +- Execute "postconf hash_queue_names" again, just to be sure. + +- Edit the main.cf file and specify - /etc/postfix/etrn: - domain.name permit_mynetworks + enable_fast_flush = yes -Run the postmap command: +- Execute "postconf enable_fast_flush", to verify that the fast + flush feature is indeed enabled. - # postmap /etc/postfix/etrn +- Execute "postfix start" -Create any missing directories that are needed for fast ETRN service: +- From a client that is allowed to execute ETRN commands, connect + to the Postfix SMTP server and type: - # postfix check + helo my.client.name + etrn some.customer.domain -Configure Postfix to use the fast ETRN service: + where "some.customer.domain" is the name of a domain that your + mail server is willing to relay mail to. - /etc/postfix/main.cf: - etrn_maps = hash:/etc/postfix/etrn + In the maillog file, you should see something logged like: -(specify dbm instead of hash if your machine uses DBM databases -rather than DB). + created fast ETRN cache for some.customer.domain -Refresh Postfix: + If Postfix logs that it cannot create a fast ETRN cache then + execute the command "postfix check". You probably skipped some + of the above instructions so that the necessary directories were + not created. - # postfix reload + If Postfix logs that it refuses fast ETRN service, then either + "some.customer.domain" does not exist, or it is not listed as a + valid relay destination. Check your relay_domains setting. diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index ed53a8659..4a6edc599 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -1,16 +1,50 @@ -Incompatible changes with snapshot-20000924 +Incompatible changes with snapshot-20000928 =========================================== -After building and installing, you need to "postfix check" -and "postfix reload". +You must execute "postfix stop" before installing this release, +and "postfix start" after updating the software. Some default +parameter settings have changed, as detailed below. + +If this release does not work for you, you can go back to a previous +Postfix version without losing your mail, subject to the "incompatible +changes" listed for previous Postfix releases below. + +In order to improve performance of one-to-one deliveries, Postfix +by default now looks at up to 10000 messages at a time (was: 1000). +This change affects the following main.cf configuration parameters: -The ETRN service is no longer enabled by default. You need to -configure what domains and what clients can use ETRN. See the -ETRN_README file for more information. + qmgr_message_active_limit: default setting increased to 10000 + hash_queue_names: default setting now includes the active queue -The smtpd_etrn_restrictions are gone. +With this change, the active queue must no longer be a flat directory. + +If your main.cf file has an explicit hash_queue_names setting, and +the active queue is not listed there, Postfix will perform very +poorly when delivering lots of mail. + +Major changes with snapshot-20000929 +==================================== -The "flush" queue should be listed in "hash_queue_names". +Until now, Postfix does a rather lame effort at implementing the +SMTP ETRN command - it attempts to deliver all mail in the queue, +regardless of its destination. This is slow if your mail server +queues mail for lots of different sites. + +This release introduces "fast ETRN", which delivers only mail that +is known to be queued for a site. The per-destination queue info +is kept in so-called "fast flush" logfiles. A "fast flush" logfile +is "flushed" after Postfix receives an appropriate ETRN command, +or after someone executes the command "sendmail -qRsite" for an +appropriate site. + +A missing "fast flush" logfile is created automatically when an +SMTP client issues the ETRN command - but only for destinations +that the local MTA is willing to relay mail to. This policy is +currently hard coded. Other destinations remain stuck with the +old "slow" ETRN service that attempts to deliver all mail in the +queue. + +See the file ETRN_README for how to turn on the "fast ETRN" service. Incompatible changes with snapshot-20000924 =========================================== diff --git a/postfix/conf/etrn b/postfix/conf/etrn deleted file mode 100644 index 5ed1aea59..000000000 --- a/postfix/conf/etrn +++ /dev/null @@ -1,110 +0,0 @@ -# -# ETRN(5) ETRN(5) -# -# NAME -# etrn - format of Postfix etrn table -# -# SYNOPSIS -# etrn_maps = hash:/etc/postfix/etrn -# etrn_maps = dbm:/etc/postfix/etrn -# -# postmap /etc/postfix/etrn -# -# DESCRIPTION -# The optional etrn file specifies what destination domain -# names can be specified in SMTP ETRN commands. This infor- -# mation is used by the smtpd(8) and flushd(8) daemon. -# -# Normally, the file serves as input to the postmap(1) com- -# mand. The result, an indexed file in dbm or db format, is -# used for fast searching by the mail system. Execute the -# command postmap /etc/postfix/etrn in order to rebuild the -# indexed file after changing the etrn table. -# -# When the table is provided via other means such as NIS, -# LDAP, SQL, or as regular expressions, the same lookups are -# done as for ordinary indexed files. -# -# TABLE FORMAT -# The format of the etrn table is as follows: -# -# blanks and comments -# Blank lines are ignored, as are lines beginning -# with `#'. -# -# domain restrictions -# The left-hand side, domain, specifies a destination -# domain name that can be specified in ETRN commands. -# -# The right-hand side specifies one or more access -# restrictions. Restrictions are processed in the -# given order and the search stops at the first -# match. -# -# reject_unknown_client -# Reject the request if the client hostname is -# unknown. -# -# permit_mynetworks -# Permit the request if the client address -# matches $mynetworks. -# -# reject_maps_rbl -# Reject the request if the reverse client -# network address is listed under -# $maps_rbl_domains. -# -# reject Reject the request. Place this at the end of -# -# 1 -# -# ETRN(5) ETRN(5) -# -# a restriction list. -# -# permit Permit the request. Place this at the end of -# a restriction list. -# -# CONFIGURATION PARAMETERS -# The following main.cf parameters are especially relevant -# to this topic. See the Postfix main.cf file for syntax -# details and for default values. Use the postfix reload -# command after a configuration change. -# -# etrn_maps -# Tables that specify what domains have ETRN service. -# For each table entry, the left-hand side specifies -# a destination domain name that can be specified in -# an ETRN request, and the right-hand side specifies -# a list of access restrictions for SMTP clients that -# issue ETRN for the domain. -# -# fast_flush_maps -# The table with names of destinations that this MTA -# provides the fast flush service for. By default, -# this is set to $etrn_maps. -# -# relay_domains -# The list of domains that this MTA is willing to -# forward mail from or to. This defaults to $mydesti- -# nation, $fast_flush_maps. -# -# SEE ALSO -# smtpd(8) Postfix SMTP server -# flushd(1) Postfix fast flush service -# sendmail(5) sendmail-compatible interface -# pcre_table(5) format of PCRE tables -# regexp_table(5) format of POSIX regular expression tables -# -# LICENSE -# The Secure Mailer license must be distributed with this -# software. -# -# AUTHOR(S) -# Wietse Venema -# IBM T.J. Watson Research -# P.O. Box 704 -# Yorktown Heights, NY 10598, USA -# -# 2 -# diff --git a/postfix/conf/main.cf b/postfix/conf/main.cf index ee4eed63e..1cac2bc00 100644 --- a/postfix/conf/main.cf +++ b/postfix/conf/main.cf @@ -341,6 +341,20 @@ mail_owner = postfix #mynetworks = 168.100.189.0/28, 127.0.0.0/8 #mynetworks = $config_directory/mynetworks +# FAST ETRN SERVICE +# +# By default, Postfix does a rather lame effort at implementing the +# SMTP ETRN command - it attempts to deliver all queued mail regardless +# of its destination. This does not work well if your mail server +# queues mail for lots of sites. In order to enable a faster ETRN +# that only delivers mail that is known to be queued for a site, +# enable the fast flush cache. Currently, "fast ETRN" is available +# only for destinations that the local system is willing to relay +# mail to (as specified in the relay_domains parameter). +# +#enable_fast_flush = yes +#enable_fast_flush = no + # SHOW SOFTWARE VERSION OR NOT # # The smtpd_banner parameter specifies the text that follows the 220 diff --git a/postfix/conf/sample-misc.cf b/postfix/conf/sample-misc.cf index f1f876d2f..e5b134b36 100644 --- a/postfix/conf/sample-misc.cf +++ b/postfix/conf/sample-misc.cf @@ -38,16 +38,6 @@ default_transport = smtp # double_bounce_sender = double-bounce -# The fast_flush_maps parameter specifies what destination domain -# names can be used in SMTP ETRN requests and in "sendmail -qRdomain.name" -# commands. By default, the value is $etrn_maps, the set of domain names -# that can be used in SMTP ETRN requests (see sample-smtpd.cf). -# -# The fast_flush_maps parameter is also used in the default settings -# of the relay_domains configuration parameter. -# -fast_flush_maps = - # The hash_queue_depth parameter specifies the number of subdirectory # levels below the queue directories listed in the hash_queue_names # parameter. diff --git a/postfix/conf/sample-smtpd.cf b/postfix/conf/sample-smtpd.cf index 8729602b9..0539cc551 100644 --- a/postfix/conf/sample-smtpd.cf +++ b/postfix/conf/sample-smtpd.cf @@ -14,27 +14,6 @@ # #disable_vrfy_command = no -# The etrn_maps parameter specifies what domains have ETRN service. -# For each table entry, the left-hand side specifies a destination -# domain name, and the right-hand side specifies a list of access -# restrictions for clients that issue ETRN for the domain. -# -# The default is to disallow ETRN commands. The following restrictions -# are available: -# -# reject_unknown_client: reject the request if the client hostname is unknown. -# permit_mynetworks: permit if the client address matches $mynetworks. -# reject_maps_rbl: reject if the reverse client network address -# is listed under $maps_rbl_domains. -# reject: reject the request. Place this at the end of a restriction. -# permit: permit the request. Place this at the end of a restriction. -# -# etrn_maps is also the default value for the fast_flush_maps parameter -# which controls the fast flush service which is used for ETRN and for -# "sendmail -qRdomain.name" -# -etrn_maps = - # The smtpd_banner parameter specifies the text that follows the 220 # status code in the SMTP greeting banner. Some people like to see # the mail version advertised. By default, Postfix shows no version. @@ -47,6 +26,27 @@ etrn_maps = # smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) smtpd_banner = $myhostname ESMTP $mail_name +# The smtpd_etrn_restrictions parameter restricts what clients are +# allowed to issue the ETRN command. The present Postfix ETRN differs +# from other ETRN implementations in that it flushes mail for all +# destinations. This will change in the future. +# +# The default is to allow ETRN from any host. The following restrictions +# are available: +# +# reject_unknown_client: reject the request if the client hostname is unknown. +# permit_mynetworks: permit if the client address matches $mynetworks. +# check_client_access maptype:mapname +# maptype:mapname: look up client name, parent domains, client address, +# or networks obtained by stripping octets. +# Reject if result is REJECT or "[45]xx text" +# Permit otherwise. +# reject_maps_rbl: reject if the reverse client network address +# is listed under $maps_rbl_domains. +# reject: reject the request. Place this at the end of a restriction. +# permit: permit the request. Place this at the end of a restriction. +smtpd_etrn_restrictions = + # The smtpd_recipient_limit parameter restricts the number of recipients # that the SMTP server accepts per message delivery. # @@ -313,7 +313,7 @@ maps_rbl_domains = rbl.maps.vix.com # permit_mx_backup restriction, in the description of the # smtpd_recipient_restrictions parameter. # -relay_domains = $mydestination $fast_flush_maps +relay_domains = $mydestination # # RESPONSE CODES diff --git a/postfix/html/Makefile.in b/postfix/html/Makefile.in index 4fed7b980..35f235000 100644 --- a/postfix/html/Makefile.in +++ b/postfix/html/Makefile.in @@ -11,8 +11,7 @@ COMMANDS= mailq.1.html newaliases.1.html postalias.1.html postcat.1.html \ postlog.1.html postdrop.1.html postmap.1.html sendmail.1.html \ postsuper.1.html CONFIG = access.5.html aliases.5.html canonical.5.html relocated.5.html \ - transport.5.html virtual.5.html pcre_table.5.html regexp_table.5.html \ - etrn.5.html + transport.5.html virtual.5.html pcre_table.5.html regexp_table.5.html update: $(DAEMONS) $(COMMANDS) $(CONFIG) @@ -132,9 +131,6 @@ aliases.5.html: ../proto/aliases canonical.5.html: ../proto/canonical srctoman - $? | nroff -man | man2html | postlink >$@ -etrn.5.html: ../proto/etrn - srctoman - $? | nroff -man | man2html | postlink >$@ - pcre_table.5.html: ../proto/pcre_table srctoman - $? | nroff -man | man2html | postlink >$@ diff --git a/postfix/html/etrn.5.html b/postfix/html/etrn.5.html deleted file mode 100644 index 7b1a13fee..000000000 --- a/postfix/html/etrn.5.html +++ /dev/null @@ -1,134 +0,0 @@ -
-
-
-
-ETRN(5)                                                   ETRN(5)
-
-
-NAME
-       etrn - format of Postfix etrn table
-
-SYNOPSIS
-       etrn_maps = hash:/etc/postfix/etrn
-       etrn_maps = dbm:/etc/postfix/etrn
-
-       postmap /etc/postfix/etrn
-
-DESCRIPTION
-       The  optional  etrn file specifies what destination domain
-       names can be specified in SMTP ETRN commands. This  infor-
-       mation is used by the smtpd(8) and flushd(8) daemon.
-
-       Normally,  the file serves as input to the postmap(1) com-
-       mand.  The result, an indexed file in dbm or db format, is
-       used  for  fast  searching by the mail system. Execute the
-       command postmap /etc/postfix/etrn in order to rebuild  the
-       indexed file after changing the etrn table.
-
-       When  the  table  is provided via other means such as NIS,
-       LDAP, SQL, or as regular expressions, the same lookups are
-       done as for ordinary indexed files.
-
-TABLE FORMAT
-       The format of the etrn table is as follows:
-
-       blanks and comments
-              Blank  lines  are  ignored,  as are lines beginning
-              with `#'.
-
-       domain restrictions
-              The left-hand side, domain, specifies a destination
-              domain name that can be specified in ETRN commands.
-
-              The right-hand side specifies one  or  more  access
-              restrictions.   Restrictions  are  processed in the
-              given order and  the  search  stops  at  the  first
-              match.
-
-              reject_unknown_client
-                     Reject the request if the client hostname is
-                     unknown.
-
-              permit_mynetworks
-                     Permit the request  if  the  client  address
-                     matches $mynetworks.
-
-              reject_maps_rbl
-                     Reject  the  request  if  the reverse client
-                     network    address    is    listed     under
-                     $maps_rbl_domains.
-
-              reject Reject the request. Place this at the end of
-
-
-
-                                                                1
-
-
-
-
-
-ETRN(5)                                                   ETRN(5)
-
-
-                     a restriction list.
-
-              permit Permit the request. Place this at the end of
-                     a restriction list.
-
-
-CONFIGURATION PARAMETERS
-       The  following  main.cf parameters are especially relevant
-       to this topic. See the Postfix  main.cf  file  for  syntax
-       details  and  for  default  values. Use the postfix reload
-       command after a configuration change.
-
-       etrn_maps
-              Tables that specify what domains have ETRN service.
-              For  each table entry, the left-hand side specifies
-              a destination domain name that can be specified  in
-              an  ETRN request, and the right-hand side specifies
-              a list of access restrictions for SMTP clients that
-              issue ETRN for the domain.
-
-       fast_flush_maps
-              The  table with names of destinations that this MTA
-              provides the fast flush service  for.  By  default,
-              this is set to $etrn_maps.
-
-       relay_domains
-              The  list  of  domains  that this MTA is willing to
-              forward mail from or to. This defaults to $mydesti-
-              nation, $fast_flush_maps.
-
-SEE ALSO
-       smtpd(8) Postfix SMTP server
-       flushd(1) Postfix fast flush service
-       sendmail(5) sendmail-compatible interface
-       pcre_table(5) format of PCRE tables
-       regexp_table(5) format of POSIX regular expression tables
-
-LICENSE
-       The  Secure  Mailer  license must be distributed with this
-       software.
-
-AUTHOR(S)
-       Wietse Venema
-       IBM T.J. Watson Research
-       P.O. Box 704
-       Yorktown Heights, NY 10598, USA
-
-
-
-
-
-
-
-
-
-
-
-                                                                2
-
-
-
diff --git a/postfix/html/flushd.8.html b/postfix/html/flushd.8.html index fab4a17f6..9da503d69 100644 --- a/postfix/html/flushd.8.html +++ b/postfix/html/flushd.8.html @@ -20,8 +20,8 @@ FLUSHD(8) FLUSHD(8) This server implements the following requests: FLUSH_REQ_ADD sitename queue_id - Append queue_id to the fast flush logfile for the - specified site. + Append queue_id to the fast flush log for the spec- + ified site. FLUSH_REQ_SEND sitename Arrange for the delivery of all messages that are @@ -39,22 +39,22 @@ FLUSHD(8) FLUSHD(8) name, bad request parameter value). FLUSH_STAT_UNKNOWN - The specified site has no fast flush logfile and is - not configured to have one. + The specified site has no fast flush log. - Fast flush logfiles are truncated only after a flush - request. In order to prevent fast flush logfiles from - growing without bounds, and to prevent them from accumu- - lating too much outdated information, the flush service - generates a pro-active flush request once every every 1000 - append requests. This should not impact operation. + Fast flush logfiles are truncated only after a flush + request. In order to prevent fast flush logs from growing + too large, and to prevent them from accumulating too much + outdated information, the flush service generates a pro- + active flush request once every every 1000 append + requests. This should not impact operation. SECURITY The fast flush server is moderately security-sensitive. It - does not talk to the network, but it does talk to local + does not talk to the network, but it does talk to local unprivileged users, in order to emulate "sendmail -qRsite" - behavior. For this reason all strings in a request are - truncated at line_length_limit. + behavior. For this reason all strings in a request are + truncated at line_length_limit, before they are subjected + to further validation. The fast flush server can run chrooted at fixed low privi- lege. @@ -86,21 +86,8 @@ FLUSHD(8) FLUSHD(8) details and for default values. Use the postfix reload command after a configuration change. - etrn_maps - Tables that specify what domains have ETRN service. - For each table entry, the left-hand side specifies - a destination domain name that can be specified in - an ETRN request, and the right-hand side specifies - a list of access restrictions for SMTP clients that - issue ETRN for the domain. - - fast_flush_maps - The table with names of destinations that this MTA - provides the fast flush service for. By default, - this is set to $etrn_maps. - line_length_limit - Maximal length of strings in a fast flush client + Maximal length of strings in a fast flush client request. SEE ALSO @@ -109,7 +96,7 @@ FLUSHD(8) FLUSHD(8) syslogd(8) system logging LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) @@ -120,6 +107,19 @@ FLUSHD(8) FLUSHD(8) + + + + + + + + + + + + + diff --git a/postfix/html/sendmail.1.html b/postfix/html/sendmail.1.html index 98f8ed9b8..dbc6f4870 100644 --- a/postfix/html/sendmail.1.html +++ b/postfix/html/sendmail.1.html @@ -188,9 +188,9 @@ SENDMAIL(1) SENDMAIL(1) -qRsite Schedule immediate delivery of all mail that is queued for the named site. This functionality is - available only for sites that are configured for - the fast flush service support as described in - flushd(8). For other sites, use the slower + available only for sites that have a so-called fast + flush logfile as described in flushd(8). For other + sites, use the slower sendmail -q command instead. @@ -203,8 +203,6 @@ SENDMAIL(1) SENDMAIL(1) SENDMAIL(1) SENDMAIL(1) - sendmail -q command instead. - -qSsite This command is not implemented. Use the slower sendmail -q command instead. @@ -257,6 +255,8 @@ SENDMAIL(1) SENDMAIL(1) The amount of original message context that is sent along with a non-delivery notification. + database_type + Default alias etc. database type. On many UNIX @@ -269,9 +269,7 @@ SENDMAIL(1) SENDMAIL(1) SENDMAIL(1) SENDMAIL(1) - database_type - Default alias etc. database type. On many UNIX sys- - tems the default type is either dbm or hash. + systems the default type is either dbm or hash. debugger_command Command that is executed after a Postfix daemon has @@ -288,60 +286,36 @@ SENDMAIL(1) SENDMAIL(1) ging level by the amount specified in the debug_peer_level parameter. - etrn_maps - Tables that specify what domains have ETRN service. - For each table entry, the left-hand side specifies - a destination domain name that can be specified in - an ETRN request, and the right-hand side specifies - a list of access restrictions for SMTP clients that - issue ETRN for the domain. - - fast_flush_maps - The table with names of destinations that this MTA - provides the fast flush service for. By default, - this is set to $etrn_maps. - fork_attempts - Number of attempts to fork() a process before giv- + Number of attempts to fork() a process before giv- ing up. fork_delay - Delay in seconds between successive fork() + Delay in seconds between successive fork() attempts. hopcount_limit Limit the number of Received: message headers. mail_owner - The owner of the mail queue and of most Postfix + The owner of the mail queue and of most Postfix processes. command_directory - Directory with Postfix support commands (default: + Directory with Postfix support commands (default: $program_directory). daemon_directory - Directory with Postfix daemon programs (default: + Directory with Postfix daemon programs (default: $program_directory). - - - 5 - - - - - -SENDMAIL(1) SENDMAIL(1) - - queue_directory - Top-level directory of the Postfix queue. This is + Top-level directory of the Postfix queue. This is also the root directory of Postfix daemons that run chrooted. queue_run_delay - The time between successive scans of the deferred + The time between successive scans of the deferred queue. SEE ALSO @@ -349,15 +323,27 @@ SENDMAIL(1) SENDMAIL(1) postalias(1) maintain alias database postdrop(1) privileged posting agent postfix(1) mail system control + + + + 5 + + + + + +SENDMAIL(1) SENDMAIL(1) + + postkick(1) kick a Postfix daemon qmgr(8) queue manager showq(8) list mail queue smtpd(8) SMTP server - flushd(8) fast flush service + flushd(8) fast flush service syslogd(8) system logging LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) @@ -385,6 +371,20 @@ SENDMAIL(1) SENDMAIL(1) + + + + + + + + + + + + + + diff --git a/postfix/html/smtpd.8.html b/postfix/html/smtpd.8.html index d085f68d1..10e377381 100644 --- a/postfix/html/smtpd.8.html +++ b/postfix/html/smtpd.8.html @@ -27,7 +27,7 @@ SMTPD(8) SMTPD(8) The SMTP server implements a variety of policies for con- nection requests, and for parameters given to HELO, ETRN, - MAIL FROM, VRFY, and RCPT TO commands. They are detailed + MAIL FROM, VRFY and RCPT TO commands. They are detailed below and in the main.cf configuration file. SECURITY @@ -143,55 +143,55 @@ SMTPD(8) SMTPD(8) ging level by the amount specified in the debug_peer_level parameter. + enable_fast_flush + Enable the "fast flush" cache for improved ETRN + performance. By default, Postfix attempts to + deliver all messages in the queue after receiving + an ETRN command. The "fast flush" cache keeps a + record of what mail is queued up for specific des- + tinations. Currently, "fast flush" support is + available only for destinations that the local MTA + is willing to relay mail to (i.e. the policy is + hard coded). + error_notice_recipient Recipient of protocol/policy/resource/software error notices. - etrn_maps - Tables that specify what domains have ETRN service. - For each table entry, the left-hand side specifies - a destination domain name that can be specified in - an ETRN request, and the right-hand side specifies - a list of access restrictions for clients that - issue ETRN for the domain. - hopcount_limit Limit the number of Received: message headers. local_recipient_maps - List of maps with user names that are local to + List of maps with user names that are local to $myorigin or $inet_interfaces. If this parameter is - defined, then the SMTP server rejects mail for + defined, then the SMTP server rejects mail for unknown local users. notify_classes List of error classes. Of special interest are: - policy When a client violates any policy, mail a + policy When a client violates any policy, mail a transcript of the entire SMTP session to the postmaster. protocol - When a client violates the SMTP protocol or + When a client violates the SMTP protocol or issues an unimplemented command, mail a transcript of the entire SMTP session to the postmaster. smtpd_banner - Text that follows the 220 status code in the SMTP + Text that follows the 220 status code in the SMTP greeting banner. smtpd_recipient_limit - Restrict the number of recipients that the SMTP + Restrict the number of recipients that the SMTP server accepts per message delivery. smtpd_timeout - Limit the time to send a server response and to + Limit the time to send a server response and to receive a client request. -Resource controls - - 3 @@ -203,8 +203,9 @@ SMTPD(8) SMTPD(8) SMTPD(8) SMTPD(8) +Resource controls line_length_limit - Limit the amount of memory in bytes used for the + Limit the amount of memory in bytes used for the handling of partial input lines. message_size_limit @@ -212,8 +213,8 @@ SMTPD(8) SMTPD(8) ing on-disk storage for envelope information. queue_minfree - Minimal amount of free space in bytes in the queue - file system for the SMTP server to accept any mail + Minimal amount of free space in bytes in the queue + file system for the SMTP server to accept any mail at all. Tarpitting @@ -223,41 +224,40 @@ SMTPD(8) SMTPD(8) smtpd_soft_error_limit When an SMTP client has made this number of errors, - wait error_count seconds before responding to any + wait error_count seconds before responding to any client request. smtpd_hard_error_limit - Disconnect after a client has made this number of + Disconnect after a client has made this number of errors. smtpd_junk_command_limit Limit the number of times a client can issue a junk - command such as NOOP, VRFY, ETRN or RSET in one - SMTP session before it is penalized with tarpit + command such as NOOP, VRFY, ETRN or RSET in one + SMTP session before it is penalized with tarpit delays. +ETRN service + smtpd_etrn_restrictions + Restrict what domain names can be used in ETRN com- + mands, and what clients may issue ETRN commands. + The restrictions are like the UCE restrictions + below. Fast ETRN service is limited to destinations + that list this MTA as mail exchanger. + UCE control restrictions smtpd_client_restrictions Restrict what clients may connect to this mail sys- tem. smtpd_helo_required - Require that clients introduce themselves at the + Require that clients introduce themselves at the beginning of an SMTP session. smtpd_helo_restrictions - Restrict what client hostnames are allowed in HELO + Restrict what client hostnames are allowed in HELO and EHLO commands. - smtpd_sender_restrictions - Restrict what sender addresses are allowed in MAIL - FROM commands. - - smtpd_recipient_restrictions - Restrict what recipient addresses are allowed in - RCPT TO commands. - - 4 @@ -269,59 +269,59 @@ SMTPD(8) SMTPD(8) SMTPD(8) SMTPD(8) + smtpd_sender_restrictions + Restrict what sender addresses are allowed in MAIL + FROM commands. + + smtpd_recipient_restrictions + Restrict what recipient addresses are allowed in + RCPT TO commands. + allow_untrusted_routing - Allow untrusted clients to specify addresses with - sender-specified routing. Enabling this opens up - nasty relay loopholes involving trusted backup MX + Allow untrusted clients to specify addresses with + sender-specified routing. Enabling this opens up + nasty relay loopholes involving trusted backup MX hosts. restriction_classes - Declares the name of zero or more parameters that - contain a list of UCE restrictions. The names of - these parameters can then be used instead of the + Declares the name of zero or more parameters that + contain a list of UCE restrictions. The names of + these parameters can then be used instead of the restriction lists that they represent. maps_rbl_domains - List of DNS domains that publish the addresses of + List of DNS domains that publish the addresses of blacklisted hosts. relay_domains - Restrict what domains or networks this mail system + Restrict what domains or networks this mail system will relay mail from or to. UCE control responses access_map_reject_code - Server response when a client violates an access + Server response when a client violates an access database restriction. invalid_hostname_reject_code - Server response when a client violates the + Server response when a client violates the reject_invalid_hostname restriction. maps_rbl_reject_code - Server response when a client violates the + Server response when a client violates the maps_rbl_domains restriction. reject_code - Response code when the client matches a reject + Response code when the client matches a reject restriction. relay_domains_reject_code - Server response when a client attempts to violate + Server response when a client attempts to violate the mail relay policy. unknown_address_reject_code - Server response when a client violates the + Server response when a client violates the reject_unknown_address restriction. - unknown_client_reject_code - Server response when a client without address to - name mapping violates the reject_unknown_clients - restriction. - - unknown_hostname_reject_code - Server response when a client violates the - reject_unknown_hostname restriction. @@ -335,13 +335,22 @@ SMTPD(8) SMTPD(8) SMTPD(8) SMTPD(8) + unknown_client_reject_code + Server response when a client without address to + name mapping violates the reject_unknown_clients + restriction. + + unknown_hostname_reject_code + Server response when a client violates the + reject_unknown_hostname restriction. + SEE ALSO cleanup(8) message canonicalization master(8) process manager syslogd(8) system logging LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) @@ -373,15 +382,6 @@ SMTPD(8) SMTPD(8) - - - - - - - - - diff --git a/postfix/html/uce.html b/postfix/html/uce.html index 8d88392fe..d35330a2f 100644 --- a/postfix/html/uce.html +++ b/postfix/html/uce.html @@ -1015,16 +1015,7 @@ restriction list.
Default:
relay_domains = -$mydestination $fast_flush_maps - -

- -(The $fast_flush_maps parameter specifies, among others, -what destinations can be used in SMTP ETRN requests or in sendmail --qRsitename commands. This parameter defaults to -$etrn_maps, the list of destinations that can be used in -SMTP ETRN requests. More details in the etrn -manual page.) +$mydestination

diff --git a/postfix/man/Makefile.in b/postfix/man/Makefile.in index 2ffd04b2a..f82ef9269 100644 --- a/postfix/man/Makefile.in +++ b/postfix/man/Makefile.in @@ -11,8 +11,7 @@ COMMANDS= man1/postalias.1 man1/postcat.1 man1/postconf.1 man1/postfix.1 \ man1/postmap.1 man1/sendmail.1 man1/mailq.1 man1/newaliases.1 \ man1/postsuper.1 CONFIG = man5/access.5 man5/aliases.5 man5/canonical.5 man5/relocated.5 \ - man5/transport.5 man5/virtual.5 man5/pcre_table.5 man5/regexp_table.5 \ - man5/etrn.5 + man5/transport.5 man5/virtual.5 man5/pcre_table.5 man5/regexp_table.5 update: $(DAEMONS) $(COMMANDS) $(CONFIG) @@ -129,9 +128,6 @@ man5/aliases.5: ../proto/aliases man5/canonical.5: ../proto/canonical ../mantools/srctoman - $? >$@ -man5/etrn.5: ../proto/etrn - ../mantools/srctoman - $? >$@ - man5/pcre_table.5: ../proto/pcre_table ../mantools/srctoman - $? >$@ diff --git a/postfix/man/man1/sendmail.1 b/postfix/man/man1/sendmail.1 index e9aa0f35e..879301ec2 100644 --- a/postfix/man/man1/sendmail.1 +++ b/postfix/man/man1/sendmail.1 @@ -138,10 +138,9 @@ configuration parameter instead. .IP \fB-qR\fIsite\fR Schedule immediate delivery of all mail that is queued for the named \fIsite\fR. -This functionality is available only for sites that are configured -for the \fBfast flush\fR service support as described in -\fBflushd\fR(8). For other sites, use the slower \fBsendmail -q\fR -command instead. +This functionality is available only for sites that have a so-called +\fBfast flush\fR logfile as described in \fBflushd\fR(8). For other +sites, use the slower \fBsendmail -q\fR command instead. .IP \fB-qS\fIsite\fR This command is not implemented. Use the slower \fBsendmail -q\fR command instead. @@ -208,15 +207,6 @@ pattern in the \fBdebug_peer_list\fR parameter. List of domain or network patterns. When a remote host matches a pattern, increase the verbose logging level by the amount specified in the \fBdebug_peer_level\fR parameter. -.IP \fBetrn_maps\fR -Tables that specify what domains have \fBETRN\fR service. For each -table entry, the left-hand side specifies a destination domain name -that can be specified in an \fBETRN\fR request, and the right-hand -side specifies a list of access restrictions for SMTP clients that -issue \fBETRN\fR for the domain. -.IP \fBfast_flush_maps\fR -The table with names of destinations that this MTA provides the -fast flush service for. By default, this is set to $\fBetrn_maps\fR. .IP \fBfork_attempts\fR Number of attempts to \fBfork\fR() a process before giving up. .IP \fBfork_delay\fR diff --git a/postfix/man/man5/etrn.5 b/postfix/man/man5/etrn.5 deleted file mode 100644 index 8603f8257..000000000 --- a/postfix/man/man5/etrn.5 +++ /dev/null @@ -1,101 +0,0 @@ -.TH ETRN 5 -.ad -.fi -.SH NAME -etrn -\- -format of Postfix etrn table -.SH SYNOPSIS -.na -.nf -\fBetrn_maps = hash:/etc/postfix/etrn\fR -\fBetrn_maps = dbm:/etc/postfix/etrn\fR - -\fBpostmap /etc/postfix/etrn\fR -.SH DESCRIPTION -.ad -.fi -The optional \fBetrn\fR file specifies what destination domain -names can be specified in SMTP \fBETRN\fR commands. This information -is used by the \fBsmtpd\fR(8) and \fBflushd\fR(8) daemon. - -Normally, the file serves as input to the \fBpostmap\fR(1) command. -The result, an indexed file in \fBdbm\fR or \fBdb\fR format, -is used for fast searching by the mail system. Execute the command -\fBpostmap /etc/postfix/etrn\fR in order to rebuild the indexed -file after changing the etrn table. - -When the table is provided via other means such as NIS, LDAP, -SQL, or as regular expressions, the same lookups are done as -for ordinary indexed files. -.SH TABLE FORMAT -.na -.nf -.ad -.fi -The format of the \fBetrn\fR table is as follows: -.IP "blanks and comments" -Blank lines are ignored, as are lines beginning with `#'. -.IP "\fIdomain restrictions\fR" -The left-hand side, \fIdomain\fR, specifies a destination domain -name that can be specified in \fBETRN\fR commands. -.sp -The right-hand side specifies one or more access restrictions. -Restrictions are processed in the given order and the search -stops at the first match. -.RS -.IP \fBreject_unknown_client\fR -Reject the request if the client hostname is unknown. -.IP \fBpermit_mynetworks\fR -Permit the request if the client address matches $mynetworks. -.IP \fBreject_maps_rbl\fR -Reject the request if the reverse client network address -is listed under $maps_rbl_domains. -.IP \fBreject\fR -Reject the request. Place this at the end of a restriction list. -.IP \fBpermit\fR -Permit the request. Place this at the end of a restriction list. -.RE -.PP -.SH CONFIGURATION PARAMETERS -.na -.nf -.ad -.fi -The following \fBmain.cf\fR parameters are especially relevant to -this topic. See the Postfix \fBmain.cf\fR file for syntax details -and for default values. Use the \fBpostfix reload\fR command after -a configuration change. -.IP \fBetrn_maps\fR -Tables that specify what domains have \fBETRN\fR service. For each -table entry, the left-hand side specifies a destination domain name -that can be specified in an \fBETRN\fR request, and the right-hand -side specifies a list of access restrictions for SMTP clients that -issue \fBETRN\fR for the domain. -.IP \fBfast_flush_maps\fR -The table with names of destinations that this MTA provides the -fast flush service for. By default, this is set to $\fBetrn_maps\fR. -.IP \fBrelay_domains\fR -The list of domains that this MTA is willing to forward mail from -or to. This defaults to \fB$mydestination, $fast_flush_maps\fR. -.SH SEE ALSO -.na -.nf -smtpd(8) Postfix SMTP server -flushd(1) Postfix fast flush service -sendmail(5) sendmail-compatible interface -pcre_table(5) format of PCRE tables -regexp_table(5) format of POSIX regular expression tables -.SH LICENSE -.na -.nf -.ad -.fi -The Secure Mailer license must be distributed with this software. -.SH AUTHOR(S) -.na -.nf -Wietse Venema -IBM T.J. Watson Research -P.O. Box 704 -Yorktown Heights, NY 10598, USA diff --git a/postfix/man/man8/flushd.8 b/postfix/man/man8/flushd.8 index eeb8634dc..2f186738d 100644 --- a/postfix/man/man8/flushd.8 +++ b/postfix/man/man8/flushd.8 @@ -19,7 +19,7 @@ manager. This server implements the following requests: .IP "\fBFLUSH_REQ_ADD\fI sitename queue_id\fR" -Append \fIqueue_id\fR to the fast flush logfile for the +Append \fIqueue_id\fR to the fast flush log for the specified site. .IP "\fBFLUSH_REQ_SEND\fI sitename\fR" Arrange for the delivery of all messages that are listed in the fast @@ -33,13 +33,12 @@ The request completed normally. The flush server rejected the request (bad request name, bad request parameter value). .IP \fBFLUSH_STAT_UNKNOWN\fR -The specified site has no fast flush logfile and is not configured -to have one. +The specified site has no fast flush log. .PP Fast flush logfiles are truncated only after a flush request. In -order to prevent fast flush logfiles from growing without bounds, -and to prevent them from accumulating too much outdated information, -the flush service generates a pro-active flush request once every +order to prevent fast flush logs from growing too large, and to +prevent them from accumulating too much outdated information, the +flush service generates a pro-active flush request once every every 1000 append requests. This should not impact operation. .SH SECURITY .na @@ -49,7 +48,8 @@ every 1000 append requests. This should not impact operation. The fast flush server is moderately security-sensitive. It does not talk to the network, but it does talk to local unprivileged users, in order to emulate "sendmail -qRsite" behavior. For this reason all -strings in a request are truncated at \fIline_length_limit\fR. +strings in a request are truncated at \fIline_length_limit\fR, +before they are subjected to further validation. The fast flush server can run chrooted at fixed low privilege. .SH DIAGNOSTICS @@ -71,15 +71,6 @@ The following \fBmain.cf\fR parameters are especially relevant to this program. See the Postfix \fBmain.cf\fR file for syntax details and for default values. Use the \fBpostfix reload\fR command after a configuration change. -.IP \fBetrn_maps\fR -Tables that specify what domains have \fBETRN\fR service. For each -table entry, the left-hand side specifies a destination domain name -that can be specified in an \fBETRN\fR request, and the right-hand -side specifies a list of access restrictions for SMTP clients that -issue \fBETRN\fR for the domain. -.IP \fBfast_flush_maps\fR -The table with names of destinations that this MTA provides the -fast flush service for. By default, this is set to $\fBetrn_maps\fR. .IP \fBline_length_limit\fR Maximal length of strings in a fast flush client request. .SH SEE ALSO diff --git a/postfix/man/man8/smtpd.8 b/postfix/man/man8/smtpd.8 index 2da91e142..ca306d627 100644 --- a/postfix/man/man8/smtpd.8 +++ b/postfix/man/man8/smtpd.8 @@ -26,7 +26,7 @@ mode, the SMTP server can accept mail even while the mail system is not running. The SMTP server implements a variety of policies for connection -requests, and for parameters given to \fBHELO, ETRN, MAIL FROM, VRFY\fR, +requests, and for parameters given to \fBHELO, ETRN, MAIL FROM, VRFY\fR and \fBRCPT TO\fR commands. They are detailed below and in the \fBmain.cf\fR configuration file. .SH SECURITY @@ -111,14 +111,17 @@ pattern in the \fBdebug_peer_list\fR parameter. List of domain or network patterns. When a remote host matches a pattern, increase the verbose logging level by the amount specified in the \fBdebug_peer_level\fR parameter. +.IP \fBenable_fast_flush\fR +Enable the "fast flush" cache for improved ETRN performance. +By default, Postfix attempts to deliver all messages in the queue +after receiving an ETRN command. +The "fast flush" cache keeps a record of what mail is queued up for +specific destinations. +Currently, "fast flush" support is available only for destinations +that the local MTA is willing to relay mail to (i.e. the policy +is hard coded). .IP \fBerror_notice_recipient\fR Recipient of protocol/policy/resource/software error notices. -.IP \fBetrn_maps\fR -Tables that specify what domains have \fBETRN\fR service. For -each table entry, the left-hand side specifies a destination -domain name that can be specified in an \fBETRN\fR request, and -the right-hand side specifies a list of access restrictions for -clients that issue \fBETRN\fR for the domain. .IP \fBhopcount_limit\fR Limit the number of \fBReceived:\fR message headers. .IP \fBlocal_recipient_maps\fR @@ -171,6 +174,14 @@ Disconnect after a client has made this number of errors. Limit the number of times a client can issue a junk command such as NOOP, VRFY, ETRN or RSET in one SMTP session before it is penalized with tarpit delays. +.SH "ETRN service" +.ad +.fi +.IP \fBsmtpd_etrn_restrictions\fR +Restrict what domain names can be used in \fBETRN\fR commands, +and what clients may issue \fBETRN\fR commands. The restrictions +are like the UCE restrictions below. Fast \fBETRN\fR service is +limited to destinations that list this MTA as mail exchanger. .SH "UCE control restrictions" .ad .fi diff --git a/postfix/proto/Makefile.in b/postfix/proto/Makefile.in index a69634774..02397426d 100644 --- a/postfix/proto/Makefile.in +++ b/postfix/proto/Makefile.in @@ -4,7 +4,7 @@ SHELL = /bin/sh CONFIG = ../conf/access ../conf/aliases ../conf/canonical ../conf/relocated \ ../conf/transport ../conf/virtual ../conf/pcre_table \ - ../conf/regexp_table ../conf/etrn + ../conf/regexp_table update: $(CONFIG) @@ -28,9 +28,6 @@ clobber: ../conf/canonical: canonical srctoman - $? | nroff -man | col -bx | uniq | sed 's/^/# /' >$@ -../conf/etrn: etrn - srctoman - $? | nroff -man | col -bx | uniq | sed 's/^/# /' >$@ - ../conf/pcre_table: pcre_table srctoman - $? | nroff -man | col -bx | uniq | sed 's/^/# /' >$@ diff --git a/postfix/proto/etrn b/postfix/proto/etrn deleted file mode 100644 index 4f145e1ab..000000000 --- a/postfix/proto/etrn +++ /dev/null @@ -1,88 +0,0 @@ -#++ -# NAME -# etrn 5 -# SUMMARY -# format of Postfix etrn table -# SYNOPSIS -# \fBetrn_maps = hash:/etc/postfix/etrn\fR -# \fBetrn_maps = dbm:/etc/postfix/etrn\fR -# -# \fBpostmap /etc/postfix/etrn\fR -# DESCRIPTION -# The optional \fBetrn\fR file specifies what destination domain -# names can be specified in SMTP \fBETRN\fR commands. This information -# is used by the \fBsmtpd\fR(8) and \fBflushd\fR(8) daemon. -# -# Normally, the file serves as input to the \fBpostmap\fR(1) command. -# The result, an indexed file in \fBdbm\fR or \fBdb\fR format, -# is used for fast searching by the mail system. Execute the command -# \fBpostmap /etc/postfix/etrn\fR in order to rebuild the indexed -# file after changing the etrn table. -# -# When the table is provided via other means such as NIS, LDAP, -# SQL, or as regular expressions, the same lookups are done as -# for ordinary indexed files. -# TABLE FORMAT -# .ad -# .fi -# The format of the \fBetrn\fR table is as follows: -# .IP "blanks and comments" -# Blank lines are ignored, as are lines beginning with `#'. -# .IP "\fIdomain restrictions\fR" -# The left-hand side, \fIdomain\fR, specifies a destination domain -# name that can be specified in \fBETRN\fR commands. -# .sp -# The right-hand side specifies one or more access restrictions. -# Restrictions are processed in the given order and the search -# stops at the first match. -# .RS -# .IP \fBreject_unknown_client\fR -# Reject the request if the client hostname is unknown. -# .IP \fBpermit_mynetworks\fR -# Permit the request if the client address matches $mynetworks. -# .IP \fBreject_maps_rbl\fR -# Reject the request if the reverse client network address -# is listed under $maps_rbl_domains. -# .IP \fBreject\fR -# Reject the request. Place this at the end of a restriction list. -# .IP \fBpermit\fR -# Permit the request. Place this at the end of a restriction list. -# .RE -# .PP -# CONFIGURATION PARAMETERS -# .ad -# .fi -# The following \fBmain.cf\fR parameters are especially relevant to -# this topic. See the Postfix \fBmain.cf\fR file for syntax details -# and for default values. Use the \fBpostfix reload\fR command after -# a configuration change. -# .IP \fBetrn_maps\fR -# Tables that specify what domains have \fBETRN\fR service. For each -# table entry, the left-hand side specifies a destination domain name -# that can be specified in an \fBETRN\fR request, and the right-hand -# side specifies a list of access restrictions for SMTP clients that -# issue \fBETRN\fR for the domain. -# .IP \fBfast_flush_maps\fR -# The table with names of destinations that this MTA provides the -# fast flush service for. By default, this is set to $\fBetrn_maps\fR. -# .IP \fBrelay_domains\fR -# The list of domains that this MTA is willing to forward mail from -# or to. This defaults to \fB$mydestination, $fast_flush_maps\fR. -# SEE ALSO -# smtpd(8) Postfix SMTP server -# flushd(1) Postfix fast flush service -# sendmail(5) sendmail-compatible interface -# pcre_table(5) format of PCRE tables -# regexp_table(5) format of POSIX regular expression tables -# LICENSE -# .ad -# .fi -# The Secure Mailer license must be distributed with this software. -# AUTHOR(S) -# Wietse Venema -# IBM T.J. Watson Research -# P.O. Box 704 -# Yorktown Heights, NY 10598, USA -#-- - -# By default, this file is not used. See sample-smtpd.cf diff --git a/postfix/src/flushd/flushd.c b/postfix/src/flushd/flushd.c index e85cd926f..324794c3b 100644 --- a/postfix/src/flushd/flushd.c +++ b/postfix/src/flushd/flushd.c @@ -13,7 +13,7 @@ /* /* This server implements the following requests: /* .IP "\fBFLUSH_REQ_ADD\fI sitename queue_id\fR" -/* Append \fIqueue_id\fR to the fast flush logfile for the +/* Append \fIqueue_id\fR to the fast flush log for the /* specified site. /* .IP "\fBFLUSH_REQ_SEND\fI sitename\fR" /* Arrange for the delivery of all messages that are listed in the fast @@ -27,13 +27,12 @@ /* The flush server rejected the request (bad request name, bad /* request parameter value). /* .IP \fBFLUSH_STAT_UNKNOWN\fR -/* The specified site has no fast flush logfile and is not configured -/* to have one. +/* The specified site has no fast flush log. /* .PP /* Fast flush logfiles are truncated only after a flush request. In -/* order to prevent fast flush logfiles from growing without bounds, -/* and to prevent them from accumulating too much outdated information, -/* the flush service generates a pro-active flush request once every +/* order to prevent fast flush logs from growing too large, and to +/* prevent them from accumulating too much outdated information, the +/* flush service generates a pro-active flush request once every /* every 1000 append requests. This should not impact operation. /* SECURITY /* .ad @@ -41,7 +40,8 @@ /* The fast flush server is moderately security-sensitive. It does not /* talk to the network, but it does talk to local unprivileged users, in /* order to emulate "sendmail -qRsite" behavior. For this reason all -/* strings in a request are truncated at \fIline_length_limit\fR. +/* strings in a request are truncated at \fIline_length_limit\fR, +/* before they are subjected to further validation. /* /* The fast flush server can run chrooted at fixed low privilege. /* DIAGNOSTICS @@ -57,15 +57,6 @@ /* this program. See the Postfix \fBmain.cf\fR file for syntax details /* and for default values. Use the \fBpostfix reload\fR command after /* a configuration change. -/* .IP \fBetrn_maps\fR -/* Tables that specify what domains have \fBETRN\fR service. For each -/* table entry, the left-hand side specifies a destination domain name -/* that can be specified in an \fBETRN\fR request, and the right-hand -/* side specifies a list of access restrictions for SMTP clients that -/* issue \fBETRN\fR for the domain. -/* .IP \fBfast_flush_maps\fR -/* The table with names of destinations that this MTA provides the -/* fast flush service for. By default, this is set to $\fBetrn_maps\fR. /* .IP \fBline_length_limit\fR /* Maximal length of strings in a fast flush client request. /* SEE ALSO @@ -116,20 +107,14 @@ #include - /* - * Tunable parameters. - */ -char *var_etrn_maps; -char *var_fflush_maps; - /* Application-specific. */ #define STR(x) vstring_str(x) -#define MAX_DUP_FILTER 10000 - -static MAPS *fflush_maps; +#define FLUSHD_DUP_FILTER_SIZE 10000 /* graceful degradation */ +#define FLUSHD_COMMAND_TIMEOUT 60 /* don't get stuck */ +#define FLUSHD_CHECK_RATE 1000 /* don't accumulate cruft */ -/* flush_append - append queue ID to per-site fast flush logfile */ +/* flush_append - append queue ID to per-site fast flush log */ static int flush_append(const char *site, const char *queue_id) { @@ -140,19 +125,12 @@ static int flush_append(const char *site, const char *queue_id) msg_info("%s: site %s queue_id %s", myname, site, queue_id); /* - * Open or create the logfile. We allow for the fact that a logfile - * exists for a site that is no longer listed in the fast flush maps. + * Open the logfile. */ if ((log = mail_queue_open(MAIL_QUEUE_FLUSH, site, O_APPEND | O_WRONLY, 0600)) == 0) { if (errno != ENOENT) msg_fatal("%s: open fast flush log for site %s: %m", myname, site); - if (maps_find(fflush_maps, site, 0) == 0) { - msg_warn("no fast flush support configured for site %s", site); - return (FLUSH_STAT_UNKNOWN); - } - log = mail_queue_open(MAIL_QUEUE_FLUSH, site, O_CREAT | O_APPEND | O_WRONLY, 0600); - if (log == 0) - msg_fatal("%s: open fast flush log for site %s: %m", myname, site); + return (FLUSH_STAT_UNKNOWN); } /* @@ -175,10 +153,10 @@ static int flush_append(const char *site, const char *queue_id) * Clean up. */ if (myflock(vstream_fileno(log), MYFLOCK_NONE) < 0) - msg_fatal("%s: unlock fast flush logfile for site %s: %m", + msg_fatal("%s: unlock fast flush log for site %s: %m", myname, site); if (vstream_fclose(log) != 0) - msg_warn("write fast flush logfile for site %s: %m", site); + msg_warn("write fast flush log for site %s: %m", site); return (FLUSH_STAT_OK); } @@ -207,13 +185,7 @@ static int flush_site(const char *site) if ((log = mail_queue_open(MAIL_QUEUE_FLUSH, site, O_RDWR, 0600)) == 0) { if (errno != ENOENT) msg_fatal("%s: open fast flush log for site %s: %m", myname, site); - if (maps_find(fflush_maps, site, 0)) { - msg_warn("no fast flush log for site %s", site); - return (FLUSH_STAT_OK); - } else { - msg_warn("no fast flush support configured for site %s", site); - return (FLUSH_STAT_UNKNOWN); - } + return (FLUSH_STAT_UNKNOWN); } /* @@ -239,12 +211,17 @@ static int flush_site(const char *site) dup_filter = htable_create(10); tbuf.actime = tbuf.modtime = event_time(); while (vstring_get_nonl(queue_id, log) != VSTREAM_EOF) { - if (dup_filter->used >= MAX_DUP_FILTER + if (!mail_queue_id_ok(STR(queue_id))) { + msg_warn("bad queue id %.30s... in fast flush log for site %s", + STR(queue_id), site); + continue; + } + if (dup_filter->used >= FLUSHD_DUP_FILTER_SIZE || htable_find(dup_filter, STR(queue_id)) == 0) { if (msg_verbose) msg_info("%s: site %s: update %s time stamps", myname, site, STR(queue_file)); - if (dup_filter->used <= MAX_DUP_FILTER) + if (dup_filter->used <= FLUSHD_DUP_FILTER_SIZE) htable_enter(dup_filter, STR(queue_id), 0); mail_queue_path(queue_file, MAIL_QUEUE_DEFERRED, STR(queue_id)); @@ -271,20 +248,20 @@ static int flush_site(const char *site) vstring_free(queue_id); /* - * Truncate the fast flush logfile. + * Truncate the fast flush log. */ if (ftruncate(vstream_fileno(log), (off_t) 0) < 0) - msg_fatal("%s: truncate fast flush logfile for site %s: %m", + msg_fatal("%s: truncate fast flush log for site %s: %m", myname, site); /* * Request delivery and clean up. */ if (myflock(vstream_fileno(log), MYFLOCK_NONE) < 0) - msg_fatal("%s: unlock fast flush logfile for site %s: %m", + msg_fatal("%s: unlock fast flush log for site %s: %m", myname, site); if (vstream_fclose(log) != 0) - msg_warn("read fast flush logfile for site %s: %m", site); + msg_warn("read fast flush log for site %s: %m", site); if (msg_verbose) msg_info("%s: requesting delivery for site %s", myname, site); mail_trigger(MAIL_CLASS_PUBLIC, MAIL_SERVICE_QUEUE, @@ -312,11 +289,12 @@ static void flush_service(VSTREAM *client_stream, char *unused_service, /* * Vandalism control. Read no unlimited amounts of garbage from a public - * socket. + * socket. Of course we also have to make sure the content is sane. */ vstring_ctl(request, VSTRING_CTL_MAXLEN, var_line_limit, VSTRING_CTL_END); vstring_ctl(site, VSTRING_CTL_MAXLEN, var_line_limit, VSTRING_CTL_END); - + vstream_control(client_stream, VSTREAM_CTL_TIMEOUT, FLUSHD_COMMAND_TIMEOUT, + VSTREAM_CTL_END); /* * This routine runs whenever a client connects to the UNIX-domain socket * dedicated to the fast flush service. What we see below is a little @@ -336,7 +314,8 @@ static void flush_service(VSTREAM *client_stream, char *unused_service, queue_id = vstring_alloc(10); vstring_ctl(queue_id, VSTRING_CTL_MAXLEN, var_line_limit, VSTRING_CTL_END); - if (mail_scan(client_stream, "%s", queue_id) == 1) + if (mail_scan(client_stream, "%s", queue_id) == 1 + && mail_queue_id_ok(STR(queue_id))) status = flush_append(STR(site), STR(queue_id)); vstring_free(queue_id); } else if (STREQ(STR(request), FLUSH_REQ_SEND)) { @@ -352,7 +331,7 @@ static void flush_service(VSTREAM *client_stream, char *unused_service, * so that it does not have to wait while the pro-active flush happens. */ if (status == FLUSH_STAT_OK && STREQ(STR(request), FLUSH_REQ_ADD) - && (++counter + event_time() + getpid()) % 1000 == 0) { + && (++counter + event_time() + getpid()) % FLUSHD_CHECK_RATE == 0) { vstream_fflush(client_stream); if (msg_verbose) msg_info("site %s: time for a pro-active flush", STR(site)); @@ -362,40 +341,9 @@ static void flush_service(VSTREAM *client_stream, char *unused_service, vstring_free(request); } -/* pre_accept - see if tables have changed */ - -static void pre_accept(char *unused_name, char **unused_argv) -{ - if (dict_changed()) { - msg_info("table has changed -- exiting"); - exit(0); - } -} - -/* pre_jail_init - pre-chroot initialization */ - -static void pre_jail_init(char *unused_service, char **unused_argv) -{ - fflush_maps = maps_create(VAR_FFLUSH_MAPS, var_fflush_maps, - DICT_FLAG_LOCK); -} - -/* pre_accept_init - check map status */ - - /* main - pass control to the single-threaded skeleton */ int main(int argc, char **argv) { - static CONFIG_STR_TABLE str_table[] = { - VAR_ETRN_MAPS, DEF_ETRN_MAPS, &var_etrn_maps, 0, 0, - VAR_FFLUSH_MAPS, DEF_FFLUSH_MAPS, &var_fflush_maps, 0, 0, - 0, - }; - - single_server_main(argc, argv, flush_service, - MAIL_SERVER_PRE_INIT, pre_jail_init, - MAIL_SERVER_PRE_ACCEPT, pre_accept, - MAIL_SERVER_STR_TABLE, str_table, - 0); + single_server_main(argc, argv, flush_service, 0); } diff --git a/postfix/src/global/deliver_request.c b/postfix/src/global/deliver_request.c index fee68b991..8930b40cc 100644 --- a/postfix/src/global/deliver_request.c +++ b/postfix/src/global/deliver_request.c @@ -63,6 +63,9 @@ /* closes the queue file, /* and destroys the DELIVER_REQUEST structure. The result is /* non-zero when the status could not be reported to the client. +/* +/* When the fast flush cache is enabled, the fast flush server is +/* notified of deferred mail. /* DIAGNOSTICS /* Warnings: bad data sent by the client. Fatal errors: out of /* memory, queue file open errors. @@ -102,6 +105,8 @@ #include "mail_open_ok.h" #include "recipient_list.h" #include "deliver_request.h" +#include "mail_flush.h" +#include "mail_params.h" /* deliver_request_initial - send initial status code */ @@ -323,7 +328,12 @@ int deliver_request_done(VSTREAM *stream, DELIVER_REQUEST *request, int stat { int err; + /* + * Optionally add this message to the fast flush log for this site. + */ err = deliver_request_final(stream, request->hop_status, status); + if (var_enable_fflush) + mail_flush_append(request->nexthop, request->queue_id); deliver_request_free(request); return (err); } diff --git a/postfix/src/global/mail_flush.c b/postfix/src/global/mail_flush.c index e7b8fc8ca..921f0c367 100644 --- a/postfix/src/global/mail_flush.c +++ b/postfix/src/global/mail_flush.c @@ -15,17 +15,20 @@ /* const char *site; /* const char *queue_id; /* DESCRIPTION -/* This module deals with delivery of backed up mail. +/* This module deals with delivery of delayed mail. /* /* mail_flush_deferred() triggers delivery of all deferred /* or incoming mail. /* -/* mail_flush_site() uses the "fash flush" service to trigger +/* The following services are available only for sites have a +/* "fast flush" logfile. These files list all mail that is queued +/* for a given site, and are created on demand when, for example, +/* an eligible SMTP client issues the ETRN command. +/* +/* mail_flush_site() uses the "fast flush" service to trigger /* delivery of messages queued for the specified site. -/* This service is available only for sites that are configured -/* to have a deferred mail logfile. /* -/* mail_flush_append() appends a record to the "fash flush" +/* mail_flush_append() appends a record to the "fast flush" /* logfile of the specified site, with the queue ID of mail /* that should still be delivered. /* DIAGNOSTICS @@ -34,10 +37,11 @@ /* The request completed normally. /* .IP MAIL_FLUSH_FAIL /* The request failed. -/* .IP "MAIL_FLUSH_UNKNOWN (mail_flush_site() only)" -/* The specified site is not configured for the fast flush service. -/* .IP "MAIL_FLUSH_BAD (mail_flush_site() only)" -/* The fast flush server rejected the request. +/* .IP MAIL_FLUSH_UNKNOWN +/* The specified site has no "fast flush" logfile. +/* .IP MAIL_FLUSH_BAD +/* The "fast flush" server rejected the request (invalid request +/* parameter). /* LICENSE /* .ad /* .fi @@ -86,7 +90,7 @@ int mail_flush_deferred(void) /* mail_flush_clnt - generic fast flush service client */ -static int mail_flush_clnt(const char *format, ...) +static int mail_flush_clnt(const char *format,...) { VSTREAM *flush; int status; diff --git a/postfix/src/global/mail_flush.h b/postfix/src/global/mail_flush.h index dfce76229..baaabe6ae 100644 --- a/postfix/src/global/mail_flush.h +++ b/postfix/src/global/mail_flush.h @@ -34,6 +34,7 @@ extern int mail_flush_append(const char *, const char *); /* LICENSE +/* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) @@ -42,6 +43,5 @@ extern int mail_flush_append(const char *, const char *); /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /*--*/ -/**INDENT** Error@33: Unmatched #endif */ #endif diff --git a/postfix/src/global/mail_params.c b/postfix/src/global/mail_params.c index bc21ed347..05daccb46 100644 --- a/postfix/src/global/mail_params.c +++ b/postfix/src/global/mail_params.c @@ -58,6 +58,7 @@ /* int var_ownreq_special; /* int var_daemon_timeout; /* char *var_syslog_facility; +/* int var_enable_fflush; /* /* void mail_params_init() /* DESCRIPTION @@ -164,6 +165,7 @@ time_t var_starttime; int var_ownreq_special; int var_daemon_timeout; char *var_syslog_facility; +int var_enable_fflush; /* check_myhostname - lookup hostname and validate */ @@ -303,6 +305,7 @@ void mail_params_init() VAR_SOFT_BOUNCE, DEF_SOFT_BOUNCE, &var_soft_bounce, VAR_OWNREQ_SPECIAL, DEF_OWNREQ_SPECIAL, &var_ownreq_special, VAR_MAILTOOL_COMPAT, DEF_MAILTOOL_COMPAT, &var_mailtool_compat, + VAR_ENABLE_FFLUSH, DEF_ENABLE_FFLUSH, &var_enable_fflush, 0, }; diff --git a/postfix/src/global/mail_params.h b/postfix/src/global/mail_params.h index 151826785..4b19bb828 100644 --- a/postfix/src/global/mail_params.h +++ b/postfix/src/global/mail_params.h @@ -441,7 +441,7 @@ extern int var_delay_warn_time; * Queue manager: various in-core message and recipient limits. */ #define VAR_QMGR_ACT_LIMIT "qmgr_message_active_limit" -#define DEF_QMGR_ACT_LIMIT 1000 +#define DEF_QMGR_ACT_LIMIT 10000 extern int var_qmgr_active_limit; #define VAR_QMGR_RCPT_LIMIT "qmgr_message_recipient_limit" @@ -592,7 +592,7 @@ extern int var_debug_peer_level; * subdirectories, and how deep the forest is. */ #define VAR_HASH_QUEUE_NAMES "hash_queue_names" -#define DEF_HASH_QUEUE_NAMES "defer,flush" +#define DEF_HASH_QUEUE_NAMES "active,bounce,defer,flush" extern char *var_hash_queue_names; #define VAR_HASH_QUEUE_DEPTH "hash_queue_depth" @@ -896,7 +896,7 @@ extern int var_trigger_timeout; extern char *var_mynetworks; #define VAR_RELAY_DOMAINS "relay_domains" -#define DEF_RELAY_DOMAINS "$mydestination $fast_flush_maps" +#define DEF_RELAY_DOMAINS "$mydestination" extern char *var_relay_domains; #define VAR_CLIENT_CHECKS "smtpd_client_restrictions" @@ -1065,15 +1065,10 @@ extern void mail_params_init(void); extern char *var_filter_xport; /* - * ETRN and fast flush support. - */ -#define VAR_ETRN_MAPS "etrn_maps" -#define DEF_ETRN_MAPS "" -extern char *var_etrn_maps; - -#define VAR_FFLUSH_MAPS "fast_flush_maps" -#define DEF_FFLUSH_MAPS "$etrn_maps" -extern char *var_fflush_maps; +Fast flush service support. */ +#define VAR_ENABLE_FFLUSH "enable_fast_flush" +#define DEF_ENABLE_FFLUSH 0 +extern bool var_enable_fflush; /* LICENSE /* .ad diff --git a/postfix/src/global/mail_queue.c b/postfix/src/global/mail_queue.c index 3f4703561..62f8c0305 100644 --- a/postfix/src/global/mail_queue.c +++ b/postfix/src/global/mail_queue.c @@ -273,6 +273,8 @@ int mail_queue_name_ok(const char *queue_name) for (cp = queue_name; *cp; cp++) if (!ISALNUM(*cp)) return (0); + if (strlen(queue_name) > 100) + return (0); return (1); } @@ -282,6 +284,9 @@ int mail_queue_id_ok(const char *queue_id) { const char *cp; + if (strlen(queue_id) > 100) + return (0); + /* * Must be in valid hostname form. */ diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 3a0ba75b7..819c8aef1 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -15,7 +15,7 @@ * Version of this program. */ #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "Snapshot-20000928" +#define DEF_MAIL_VERSION "Snapshot-20000929" extern char *var_mail_version; /* LICENSE diff --git a/postfix/src/nqmgr/qmgr.c b/postfix/src/nqmgr/qmgr.c index af253cecc..7c1d11a95 100644 --- a/postfix/src/nqmgr/qmgr.c +++ b/postfix/src/nqmgr/qmgr.c @@ -332,14 +332,12 @@ char *var_relocated_maps; char *var_virtual_maps; char *var_defer_xports; bool var_allow_min_user; -char *var_fflush_maps; static QMGR_SCAN *qmgr_incoming; static QMGR_SCAN *qmgr_deferred; MAPS *qmgr_relocated; MAPS *qmgr_virtual; -MAPS *qmgr_fflush; /* qmgr_deferred_run_event - queue manager heartbeat */ @@ -473,9 +471,6 @@ static void qmgr_pre_init(char *unused_name, char **unused_argv) if (*var_virtual_maps) qmgr_virtual = maps_create("virtual", var_virtual_maps, DICT_FLAG_LOCK); - if (*var_fflush_maps) - qmgr_fflush = maps_create(VAR_FFLUSH_MAPS, var_fflush_maps, - DICT_FLAG_LOCK); } /* qmgr_post_init - post-jail initialization */ @@ -513,7 +508,6 @@ int main(int argc, char **argv) VAR_RELOCATED_MAPS, DEF_RELOCATED_MAPS, &var_relocated_maps, 0, 0, VAR_VIRTUAL_MAPS, DEF_VIRTUAL_MAPS, &var_virtual_maps, 0, 0, VAR_DEFER_XPORTS, DEF_DEFER_XPORTS, &var_defer_xports, 0, 0, - VAR_FFLUSH_MAPS, DEF_FFLUSH_MAPS, &var_fflush_maps, 0, 0, 0, }; static CONFIG_INT_TABLE int_table[] = { diff --git a/postfix/src/nqmgr/qmgr.h b/postfix/src/nqmgr/qmgr.h index b06219759..2da9dea0b 100644 --- a/postfix/src/nqmgr/qmgr.h +++ b/postfix/src/nqmgr/qmgr.h @@ -275,7 +275,6 @@ extern int qmgr_message_count; extern int qmgr_recipient_count; extern MAPS *qmgr_relocated; extern MAPS *qmgr_virtual; -extern MAPS *qmgr_fflush; extern void qmgr_message_free(QMGR_MESSAGE *); extern void qmgr_message_update_warn(QMGR_MESSAGE *); diff --git a/postfix/src/nqmgr/qmgr_defer.c b/postfix/src/nqmgr/qmgr_defer.c index 72d30aac9..504a5b821 100644 --- a/postfix/src/nqmgr/qmgr_defer.c +++ b/postfix/src/nqmgr/qmgr_defer.c @@ -79,6 +79,8 @@ /* Global library. */ #include +#include +#include /* Application-specific. */ @@ -138,6 +140,8 @@ void qmgr_defer_todo(QMGR_QUEUE *queue, const char *reason) recipient = entry->rcpt_list.info + nrcpt; qmgr_defer_recipient(message, recipient->address, reason); } + if (var_enable_fflush) + mail_flush_append(queue->name, message->queue_id); qmgr_entry_done(entry, QMGR_QUEUE_TODO); } } diff --git a/postfix/src/nqmgr/qmgr_deliver.c b/postfix/src/nqmgr/qmgr_deliver.c index 8d70552c7..aacb8efa5 100644 --- a/postfix/src/nqmgr/qmgr_deliver.c +++ b/postfix/src/nqmgr/qmgr_deliver.c @@ -212,12 +212,6 @@ static void qmgr_deliver_update(int unused_event, char *context) if (queue->window == 0) qmgr_defer_todo(queue, queue->reason); } - - /* - * Optionally add this message to the fast flush log for this site. - */ - if (qmgr_fflush && maps_find(qmgr_fflush, queue->name, 0)) - mail_flush_append(queue->name, message->queue_id); } /* diff --git a/postfix/src/postsuper/postsuper.c b/postfix/src/postsuper/postsuper.c index e93ab349a..4f53c3b07 100644 --- a/postfix/src/postsuper/postsuper.c +++ b/postfix/src/postsuper/postsuper.c @@ -143,6 +143,9 @@ static void super(char **queues, int action) */ while ((queue_name = *queues++) != 0) { + if (msg_verbose) + msg_info("queue: %s", queue_name); + /* * Look up queue-specific properties: desired hashing depth, what * file permissions to look for, and whether or not it is desirable @@ -294,6 +297,7 @@ main(int argc, char **argv) MAIL_QUEUE_DEFERRED, MAIL_QUEUE_DEFER, MAIL_QUEUE_BOUNCE, + MAIL_QUEUE_FLUSH, 0, }; diff --git a/postfix/src/qmgr/Makefile.in b/postfix/src/qmgr/Makefile.in index aa974a8c6..ad3320b48 100644 --- a/postfix/src/qmgr/Makefile.in +++ b/postfix/src/qmgr/Makefile.in @@ -135,7 +135,6 @@ qmgr_deliver.o: ../../include/mail_proto.h qmgr_deliver.o: ../../include/recipient_list.h qmgr_deliver.o: ../../include/mail_params.h qmgr_deliver.o: ../../include/deliver_request.h -qmgr_deliver.o: ../../include/mail_flush.h qmgr_deliver.o: qmgr.h qmgr_deliver.o: ../../include/scan_dir.h qmgr_deliver.o: ../../include/maps.h diff --git a/postfix/src/qmgr/qmgr.c b/postfix/src/qmgr/qmgr.c index f8ae84f02..374008e92 100644 --- a/postfix/src/qmgr/qmgr.c +++ b/postfix/src/qmgr/qmgr.c @@ -292,14 +292,12 @@ bool var_allow_min_user; int var_qmgr_fudge; int var_qmgr_hog; int var_local_rcpt_lim; /* XXX */ -char *var_fflush_maps; static QMGR_SCAN *qmgr_incoming; static QMGR_SCAN *qmgr_deferred; MAPS *qmgr_relocated; MAPS *qmgr_virtual; -MAPS *qmgr_fflush; /* qmgr_deferred_run_event - queue manager heartbeat */ @@ -436,9 +434,6 @@ static void qmgr_pre_init(char *unused_name, char **unused_argv) if (*var_virtual_maps) qmgr_virtual = maps_create("virtual", var_virtual_maps, DICT_FLAG_LOCK); - if (*var_fflush_maps) - qmgr_fflush = maps_create(VAR_FFLUSH_MAPS, var_fflush_maps, - DICT_FLAG_LOCK); } /* qmgr_post_init - post-jail initialization */ @@ -476,7 +471,6 @@ int main(int argc, char **argv) VAR_RELOCATED_MAPS, DEF_RELOCATED_MAPS, &var_relocated_maps, 0, 0, VAR_VIRTUAL_MAPS, DEF_VIRTUAL_MAPS, &var_virtual_maps, 0, 0, VAR_DEFER_XPORTS, DEF_DEFER_XPORTS, &var_defer_xports, 0, 0, - VAR_FFLUSH_MAPS, DEF_FFLUSH_MAPS, &var_fflush_maps, 0, 0, 0, }; static CONFIG_INT_TABLE int_table[] = { diff --git a/postfix/src/qmgr/qmgr.h b/postfix/src/qmgr/qmgr.h index 71fe6d777..45ceac8e9 100644 --- a/postfix/src/qmgr/qmgr.h +++ b/postfix/src/qmgr/qmgr.h @@ -242,7 +242,6 @@ extern int qmgr_message_count; extern int qmgr_recipient_count; extern MAPS *qmgr_relocated; extern MAPS *qmgr_virtual; -extern MAPS *qmgr_fflush; extern void qmgr_message_free(QMGR_MESSAGE *); extern void qmgr_message_update_warn(QMGR_MESSAGE *); diff --git a/postfix/src/qmgr/qmgr_defer.c b/postfix/src/qmgr/qmgr_defer.c index 8be8e7247..c6292390e 100644 --- a/postfix/src/qmgr/qmgr_defer.c +++ b/postfix/src/qmgr/qmgr_defer.c @@ -74,6 +74,8 @@ /* Global library. */ #include +#include +#include /* Application-specific. */ @@ -133,6 +135,8 @@ void qmgr_defer_todo(QMGR_QUEUE *queue, const char *reason) recipient = entry->rcpt_list.info + nrcpt; qmgr_defer_recipient(message, recipient->address, reason); } + if (var_enable_fflush) + mail_flush_append(queue->name, message->queue_id); qmgr_entry_done(entry, QMGR_QUEUE_TODO); } } diff --git a/postfix/src/qmgr/qmgr_deliver.c b/postfix/src/qmgr/qmgr_deliver.c index 0c6685c98..cfc49de73 100644 --- a/postfix/src/qmgr/qmgr_deliver.c +++ b/postfix/src/qmgr/qmgr_deliver.c @@ -62,7 +62,6 @@ #include #include #include -#include /* Application-specific. */ @@ -208,12 +207,6 @@ static void qmgr_deliver_update(int unused_event, char *context) if (queue->window == 0) qmgr_defer_todo(queue, queue->reason); } - - /* - * Optionally add this message to the fast flush log for this site. - */ - if (qmgr_fflush && maps_find(qmgr_fflush, queue->name, 0)) - mail_flush_append(queue->name, message->queue_id); } /* diff --git a/postfix/src/qmgr/qmgr_message.c b/postfix/src/qmgr/qmgr_message.c index 31f1a0e38..3732e2990 100644 --- a/postfix/src/qmgr/qmgr_message.c +++ b/postfix/src/qmgr/qmgr_message.c @@ -501,6 +501,7 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) } else if (dict_errno != 0) { qmgr_defer_recipient(message, recipient->address, "relocated map lookup failure"); +XXX mail_flush_append continue; } } @@ -589,6 +590,7 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) if (*cpp) { qmgr_defer_recipient(message, recipient->address, "deferred transport"); +XXX mail_flush_append continue; } } @@ -616,6 +618,7 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) */ if ((transport->flags & QMGR_TRANSPORT_STAT_DEAD) != 0) { qmgr_defer_recipient(message, recipient->address, transport->reason); +XXX mail_flush_append continue; } @@ -633,6 +636,7 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) */ if (queue->window == 0) { qmgr_defer_recipient(message, recipient->address, queue->reason); +XXX mail_flush_append continue; } @@ -649,6 +653,7 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) qmgr_message_count : var_qmgr_active_limit)) { qmgr_defer_recipient(message, recipient->address, "site destination queue overflow"); +XXX mail_flush_append continue; } } diff --git a/postfix/src/sendmail/sendmail.c b/postfix/src/sendmail/sendmail.c index 18c89bdfc..874877627 100644 --- a/postfix/src/sendmail/sendmail.c +++ b/postfix/src/sendmail/sendmail.c @@ -132,10 +132,9 @@ /* .IP \fB-qR\fIsite\fR /* Schedule immediate delivery of all mail that is queued for the named /* \fIsite\fR. -/* This functionality is available only for sites that are configured -/* for the \fBfast flush\fR service support as described in -/* \fBflushd\fR(8). For other sites, use the slower \fBsendmail -q\fR -/* command instead. +/* This functionality is available only for sites that have a so-called +/* \fBfast flush\fR logfile as described in \fBflushd\fR(8). For other +/* sites, use the slower \fBsendmail -q\fR command instead. /* .IP \fB-qS\fIsite\fR /* This command is not implemented. Use the slower \fBsendmail -q\fR /* command instead. @@ -192,15 +191,6 @@ /* List of domain or network patterns. When a remote host matches /* a pattern, increase the verbose logging level by the amount /* specified in the \fBdebug_peer_level\fR parameter. -/* .IP \fBetrn_maps\fR -/* Tables that specify what domains have \fBETRN\fR service. For each -/* table entry, the left-hand side specifies a destination domain name -/* that can be specified in an \fBETRN\fR request, and the right-hand -/* side specifies a list of access restrictions for SMTP clients that -/* issue \fBETRN\fR for the domain. -/* .IP \fBfast_flush_maps\fR -/* The table with names of destinations that this MTA provides the -/* fast flush service for. By default, this is set to $\fBetrn_maps\fR. /* .IP \fBfork_attempts\fR /* Number of attempts to \fBfork\fR() a process before giving up. /* .IP \fBfork_delay\fR @@ -290,7 +280,6 @@ #include #include #include -#include /* Application-specific. */ @@ -580,7 +569,7 @@ static void flush_site(const char *site) case FLUSH_STAT_OK: break; case FLUSH_STAT_UNKNOWN: - msg_fatal("No \"sendmail -qR\" support is configured for %s", site); + msg_fatal("No \"sendmail -qR\" support available for %s - use \"sendmail -q\" instead", site); break; case FLUSH_STAT_BAD: msg_fatal("invalid request: %s", site); diff --git a/postfix/src/smtpd/smtpd.c b/postfix/src/smtpd/smtpd.c index 90e00398a..ef52089c6 100644 --- a/postfix/src/smtpd/smtpd.c +++ b/postfix/src/smtpd/smtpd.c @@ -20,7 +20,7 @@ /* system is not running. /* /* The SMTP server implements a variety of policies for connection -/* requests, and for parameters given to \fBHELO, ETRN, MAIL FROM, VRFY\fR, +/* requests, and for parameters given to \fBHELO, ETRN, MAIL FROM, VRFY\fR /* and \fBRCPT TO\fR commands. They are detailed below and in the /* \fBmain.cf\fR configuration file. /* SECURITY @@ -97,14 +97,17 @@ /* List of domain or network patterns. When a remote host matches /* a pattern, increase the verbose logging level by the amount /* specified in the \fBdebug_peer_level\fR parameter. +/* .IP \fBenable_fast_flush\fR +/* Enable the "fast flush" cache for improved ETRN performance. +/* By default, Postfix attempts to deliver all messages in the queue +/* after receiving an ETRN command. +/* The "fast flush" cache keeps a record of what mail is queued up for +/* specific destinations. +/* Currently, "fast flush" support is available only for destinations +/* that the local MTA is willing to relay mail to (i.e. the policy +/* is hard coded). /* .IP \fBerror_notice_recipient\fR /* Recipient of protocol/policy/resource/software error notices. -/* .IP \fBetrn_maps\fR -/* Tables that specify what domains have \fBETRN\fR service. For -/* each table entry, the left-hand side specifies a destination -/* domain name that can be specified in an \fBETRN\fR request, and -/* the right-hand side specifies a list of access restrictions for -/* clients that issue \fBETRN\fR for the domain. /* .IP \fBhopcount_limit\fR /* Limit the number of \fBReceived:\fR message headers. /* .IP \fBlocal_recipient_maps\fR @@ -157,6 +160,14 @@ /* Limit the number of times a client can issue a junk command /* such as NOOP, VRFY, ETRN or RSET in one SMTP session before /* it is penalized with tarpit delays. +/* .SH "ETRN service" +/* .ad +/* .fi +/* .IP \fBsmtpd_etrn_restrictions\fR +/* Restrict what domain names can be used in \fBETRN\fR commands, +/* and what clients may issue \fBETRN\fR commands. The restrictions +/* are like the UCE restrictions below. Fast \fBETRN\fR service is +/* limited to destinations that list this MTA as mail exchanger. /* .SH "UCE control restrictions" /* .ad /* .fi @@ -344,7 +355,6 @@ bool var_smtpd_sasl_enable; char *var_smtpd_sasl_opts; char *var_smtpd_sasl_realm; char *var_filter_xport; -char *var_fflush_maps; /* * Global state, for stand-alone mode queue file cleanup. When this is @@ -529,21 +539,7 @@ static char *extract_addr(SMTPD_STATE *state, SMTPD_TOKEN *arg, */ if (msg_verbose) msg_info("%s: input: %s", myname, STR(arg->vstrval)); - - /* - * Workaround: Sendmail allows arbitrary nesting of <>, so that overpaid - * peecee programmers can get away with monstrosities such as >. By peeling off the outermost <> we can deal with the - * most common problem instance. Don't destroy the input so that we can - * provide accurate diagnostics. - */ - if (arg->strval[0] == '<' && vstring_end(arg->vstrval)[-1] == '>') { - vstring_end(arg->vstrval)[-1] = 0; - tree = tok822_parse(STR(arg->vstrval) + 1); - vstring_end(arg->vstrval)[-1] = '>'; - } else { - tree = tok822_parse(STR(arg->vstrval)); - } + tree = tok822_parse(STR(arg->vstrval)); /* * Find trouble. @@ -1065,6 +1061,7 @@ static int vrfy_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) static int etrn_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) { + VSTREAM *fp; char *err; /* @@ -1092,6 +1089,10 @@ static int etrn_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) smtpd_chat_reply(state, "501 Error: invalid parameter syntax"); return (-1); } + if (SMTPD_STAND_ALONE(state)) { + smtpd_chat_reply(state, "458 Unable to queue messages"); + return (-1); + } /* * XXX The implementation borrows heavily from the code that implements @@ -1099,20 +1100,47 @@ static int etrn_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) * rejected. RFC 1985 requires that 459 be sent when the server refuses * to perform the request. */ - if (SMTPD_STAND_ALONE(state) == 0 - && (err = smtpd_check_etrn(state, argv[1].strval)) != 0) { + if ((err = smtpd_check_etrn(state, argv[1].strval)) != 0) { smtpd_chat_reply(state, "%s", err); return (-1); } + if (!var_enable_fflush) { + mail_flush_deferred(); + smtpd_chat_reply(state, "250 Queuing started"); + return (0); + } /* - * XXX The preliminary implementation causes a full deferred queue scan. + * Create a fast ETRN cache file on the fly for an eligible site. */ - if (mail_flush_site(argv[1].strval) != 0) - smtpd_chat_reply(state, "458 Unable to queue messages"); - else + switch (mail_flush_site(argv[1].strval)) { + case FLUSH_STAT_UNKNOWN: + if (smtpd_check_etrn_cache_policy_ok(state, argv[1].strval)) { + if ((fp = mail_queue_open(MAIL_QUEUE_FLUSH, argv[1].strval, + O_CREAT | O_APPEND | O_WRONLY, 0600)) == 0) { + msg_warn("create fast ETRN cache for %s: %m", argv[1].strval); + } else { + vstream_fclose(fp); + msg_info("created fast ETRN cache for %s (client=%s)", + argv[1].strval, state->namaddr); + } + } else { + msg_info("refused fast ETRN service for %s (client=%s)", + argv[1].strval, state->namaddr); + } + /* Fallthrough. */ + case FLUSH_STAT_FAIL: + mail_flush_deferred(); + /* Fallthrough. */ + case FLUSH_STAT_OK: smtpd_chat_reply(state, "250 Queuing started"); - return (0); + return (0); + default: + smtpd_chat_reply(state, "458 Unable to queue messages"); + msg_warn("bad ETRN destination %.100s... from %s", + argv[1].strval, state->namaddr); + return (-1); + } } /* quit_cmd - process QUIT command */ @@ -1462,7 +1490,6 @@ int main(int argc, char **argv) VAR_SMTPD_SASL_OPTS, DEF_SMTPD_SASL_OPTS, &var_smtpd_sasl_opts, 0, 0, VAR_SMTPD_SASL_REALM, DEF_SMTPD_SASL_REALM, &var_smtpd_sasl_realm, 1, 0, VAR_FILTER_XPORT, DEF_FILTER_XPORT, &var_filter_xport, 0, 0, - VAR_FFLUSH_MAPS, DEF_FFLUSH_MAPS, &var_fflush_maps, 0, 0, 0, }; diff --git a/postfix/src/smtpd/smtpd_check.c b/postfix/src/smtpd/smtpd_check.c index d0d847a2d..8745857f5 100644 --- a/postfix/src/smtpd/smtpd_check.c +++ b/postfix/src/smtpd/smtpd_check.c @@ -24,9 +24,13 @@ /* SMTPD_STATE *state; /* char *recipient; /* -/* char *smtpd_check_etrn(state, recipient) +/* char *smtpd_check_etrn(state, destination) /* SMTPD_STATE *state; -/* char *recipient; +/* char *destination; +/* +/* int smtpd_check_etrn_cache_policy_ok(state, destination) +/* SMTPD_STATE *state; +/* char *destination; /* DESCRIPTION /* This module implements additional checks on SMTP client requests. /* A client request is validated in the context of the session state. @@ -81,9 +85,6 @@ /* .IP "check_recipient_access maptype:mapname" /* Look up the resolved recipient address in the named access table, /* any parent domains of the recipient domain, and the localpart@. -/* .IP "check_etrn_access maptype:mapname" -/* Look up the client hostname or IP address in the named access table. -/* This table is used for ETRN command access control only. /* .IP reject_maps_rbl /* Look up the reversed client network address in the real-time blackhole /* DNS zones below the domains listed in the "maps_rbl_domains" @@ -178,7 +179,15 @@ /* smtpd_check_etrn() validates the domain name provided with the /* ETRN command, and other client-provided information. Relevant /* configuration parameters: +/* .IP smtpd_etrn_restrictions +/* Restrictions on the hostname that is sent with the HELO/EHLO +/* command. /* .PP +/* smtpd_check_etrn_cache_policy_ok() returns "true" if it is OK to +/* create a fast ETRN cache file for the specified destination. +/* Currently, the hard-coded policy is that the local MTA must be +/* is willing to relay mail to that destination. +/* /* smtpd_check_size() checks if a message with the given size can /* be received (zero means that the message size is unknown). The /* message is rejected when: @@ -313,7 +322,6 @@ static MAPS *rcpt_canon_maps; static MAPS *canonical_maps; static MAPS *virtual_maps; static MAPS *relocated_maps; -static MAPS *fflush_maps; /* * Pre-opened access control lists. @@ -328,6 +336,7 @@ static ARGV *client_restrctions; static ARGV *helo_restrctions; static ARGV *mail_restrctions; static ARGV *rcpt_restrctions; +static ARGV *etrn_restrctions; static HTABLE *smtpd_rest_classes; @@ -458,8 +467,6 @@ void smtpd_check_init(void) DICT_FLAG_LOCK); relocated_maps = maps_create(VAR_RELOCATED_MAPS, var_relocated_maps, DICT_FLAG_LOCK); - fflush_maps = maps_create(VAR_FFLUSH_MAPS, var_fflush_maps, - DICT_FLAG_LOCK); /* * Reply is used as a cache for resolved addresses, and error_text is @@ -477,6 +484,7 @@ void smtpd_check_init(void) helo_restrctions = smtpd_check_parse(var_helo_checks); mail_restrctions = smtpd_check_parse(var_mail_checks); rcpt_restrctions = smtpd_check_parse(var_rcpt_checks); + etrn_restrctions = smtpd_check_parse(var_etrn_checks); /* * Parse the pre-defined restriction classes. @@ -906,7 +914,7 @@ static int has_my_addr(char *host) msg_info("%s: host %s", myname, host); /* - * If we can't lookup the host, play safe and assume it is OK. + * If we can't lookup the host, say we're not listed. */ #define YUP 1 #define NOPE 0 @@ -914,12 +922,12 @@ static int has_my_addr(char *host) if ((hp = gethostbyname(host)) == 0) { if (msg_verbose) msg_info("%s: host %s: not found", myname, host); - return (YUP); + return (NOPE); } if (hp->h_addrtype != AF_INET || hp->h_length != sizeof(addr)) { msg_warn("address type %d length %d for %s", hp->h_addrtype, hp->h_length, host); - return (YUP); + return (NOPE); } for (cpp = hp->h_addr_list; *cpp; cpp++) { memcpy((char *) &addr, *cpp, sizeof(addr)); @@ -1880,8 +1888,6 @@ char *smtpd_check_etrn(SMTPD_STATE *state, char *domain) int status; char *saved_etrn_name; char *err; - const char *pattern; - ARGV *restrictions; /* * Initialize. @@ -1909,32 +1915,41 @@ char *smtpd_check_etrn(SMTPD_STATE *state, char *domain) SMTPD_CHECK_ETRN_RETURN(err); /* - * Apply restrictions in the order as specified. If the domain is not - * configured for ETRN, reject the request. + * Apply restrictions in the order as specified. */ - if (*var_fflush_maps == 0 - || (pattern = maps_find(fflush_maps, domain, 0)) == 0) { - status = smtpd_check_reject(state, MAIL_ERROR_POLICY, - "458 Unable to start queueing for %s", - domain); - } else if (strchr(pattern, ':') != 0) { - msg_warn("A fast flush map has an entry with lookup table: %s", - pattern); - msg_warn("do not specify lookup tables inside fast flush maps"); - msg_warn("define a restriction class and specify its name instead"); - status = SMTPD_CHECK_DUNNO; - } else { - restrictions = argv_split(pattern, " \t\r\n"); - state->recursion = 0; - status = setjmp(smtpd_check_buf); - if (status == 0) - status = generic_checks(state, restrictions, domain, - SMTPD_NAME_ETRN, CHECK_ETRN_ACL); - argv_free(restrictions); - } + state->recursion = 0; + status = setjmp(smtpd_check_buf); + if (status == 0 && etrn_restrctions->argc) + status = generic_checks(state, etrn_restrctions, domain, + SMTPD_NAME_ETRN, CHECK_ETRN_ACL); + SMTPD_CHECK_ETRN_RETURN(status == SMTPD_CHECK_REJECT ? STR(error_text) : 0); } +/* smtpd_check_etrn_cache_policy_ok - is it OK to create a fast ETRN cache? */ + +int smtpd_check_etrn_cache_policy_ok(SMTPD_STATE *unused_state, char *domain) +{ + + /* + * The domain name must be an authorized relay destination. + */ + if (domain_list_match(relay_domains, domain) == 0) + return (0); + + /* + * The domain name must exist. + */ + if (dns_lookup_types(domain, 0, (DNS_RR **) 0, (VSTRING *) 0, + (VSTRING *) 0, T_A, T_MX, 0) != DNS_OK) + return (0); + + /* + * Must be OK then. + */ + return (1); +} + /* smtpd_check_rcptmap - permit if recipient address matches lookup table */ char *smtpd_check_rcptmap(SMTPD_STATE *state, char *recipient) @@ -2226,6 +2241,7 @@ static REST_TABLE rest_table[] = { "helo_restrictions", &helo_restrctions, "sender_restrictions", &mail_restrctions, "recipient_restrictions", &rcpt_restrctions, + "etrn_restrictions", &etrn_restrctions, 0, }; diff --git a/postfix/src/smtpd/smtpd_check.h b/postfix/src/smtpd/smtpd_check.h index 00f923a8f..e28c4421d 100644 --- a/postfix/src/smtpd/smtpd_check.h +++ b/postfix/src/smtpd/smtpd_check.h @@ -20,6 +20,7 @@ extern char *smtpd_check_rcptmap(SMTPD_STATE *, char *); extern char *smtpd_check_size(SMTPD_STATE *, off_t); extern char *smtpd_check_rcpt(SMTPD_STATE *, char *); extern char *smtpd_check_etrn(SMTPD_STATE *, char *); +extern int smtpd_check_etrn_cache_policy_ok(SMTPD_STATE *, char *); /* LICENSE /* .ad -- 2.47.3