From: Wietse Venema Date: Mon, 10 Nov 2003 05:00:00 +0000 (-0500) Subject: postfix-2.0.16-20031110 X-Git-Tag: v2.1-RC1-20040331~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8571298ac4c5aac6b62e74b04bd6e701cf7ebe0;p=thirdparty%2Fpostfix.git postfix-2.0.16-20031110 --- diff --git a/postfix/.indent.pro b/postfix/.indent.pro index d092777b4..8bc9dc097 100644 --- a/postfix/.indent.pro +++ b/postfix/.indent.pro @@ -23,6 +23,8 @@ -TCONFIG_STR_TABLE -TCONFIG_TIME_FN_TABLE -TCONFIG_TIME_TABLE +-TCRATE_LOCAL +-TCRATE_REMOTE -TCTABLE -TCTABLE_ENTRY -TDELIVER_ATTR diff --git a/postfix/HISTORY b/postfix/HISTORY index 01b764542..721301967 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -8706,6 +8706,48 @@ Apologies for any names omitted. Portability: added localhost to mydestination for sites that turn off append_dot_mydomain. File: global/mail_params.h. +20031027 + + Portability: MacOS X Bind8 compatibility. File: makedefs. + +20031103 + + Robustness: flush pipelined "." and "quit" replies to avoid + repeated deliveries in case of a program crash (you know, + the kind of thing that happens before Postfix release :-). + File: smtpd/smtpd.c. + +20031105 + + Portability: turn off NETINFO support for MacOS X Panther + by default. Files: makedefs, util/sys_defs.h. + +20031106 + + Feature: the sample greylist policy server is now case + insensitive. File: examples/smtpd-policy/smtpd-policy.pl. + +20031103-20031110 + + Feature: preliminary support to restrict the number of + simultaneous and successive connections that a client is + can make to the Postfix SMTP server, with a whitelist + capability to disable the restriction for authorized clients. + Most of the work is implemented by a new "crate" server + (connection Count and RATE management). Parameters: + smtpd_client_connection_count_limit, smtpd_client_connection- + _rate_limit, smtpd_client_connection_limit_exceptions, + connection_rate_time_unit, and connection_rate_purge_delay. + Documentation: smtpd(8), crate(8), sample-smtpd.cf. Files: + smtpd/smtpd.c, global/crate_clnt.[hc], crate/crate.c. + + +20031110 + + Cleanup: Postfix now supports the /0 netmask (match every + address). This is useful as a catch-all pattern at the + end of a table. Files: util/dict_cidr.c, util/match_ops.c. + Open problems: High: when virtual aliasing is turned off after content diff --git a/postfix/Makefile.in b/postfix/Makefile.in index ddb60c483..7565c5355 100644 --- a/postfix/Makefile.in +++ b/postfix/Makefile.in @@ -7,7 +7,7 @@ DIRS = src/util src/global src/dns src/master src/postfix src/smtpstone \ src/showq src/postalias src/postcat src/postconf src/postdrop \ src/postkick src/postlock src/postlog src/postmap src/postqueue \ src/postsuper src/nqmgr src/qmqpd src/spawn src/flush src/verify \ - src/virtual src/proxymap + src/virtual src/proxymap src/crate MANDIRS = proto man html default: update diff --git a/postfix/README_FILES/SASL_README b/postfix/README_FILES/SASL_README index b2b6aa9a4..a31496690 100644 --- a/postfix/README_FILES/SASL_README +++ b/postfix/README_FILES/SASL_README @@ -161,7 +161,8 @@ Alternately, in SASL 1.5.5 and later (including 2.1.1), try: The saslauthd daemon is also contained in the cyrus-sasl source tarball. It is more flexible than the pwcheck daemon, in that it -can authenticate against PAM and various other sources. +can authenticate against PAM and various other sources. To use +PAM, start saslauthd with "-a pam". In order to authenticate against SASL's own password database: diff --git a/postfix/README_FILES/SMTPD_POLICY_README b/postfix/README_FILES/SMTPD_POLICY_README index 8275acb6a..172243ec5 100644 --- a/postfix/README_FILES/SMTPD_POLICY_README +++ b/postfix/README_FILES/SMTPD_POLICY_README @@ -258,6 +258,7 @@ sub smtpd_access_policy { # Lookup the time stamp for this client/sender/recipient. $key = $attr{"client_address"}."/".$attr{"sender"}."/".$attr{"recipient"}; + $key =~ tr /A-Z/a-z/; $time_stamp = read_database($key); $now = time(); diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index aa14f09d0..4ac31a4d5 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -22,6 +22,26 @@ snapshot release). Patches change the patchlevel and the release date. Snapshots change only the release date, unless they include the same bugfixes as a patch release. +Incompatible changes with Postfix snapshot 2.0.16-20031110 +========================================================== + +The demo greylist policy server is now case insensitive. + +Major changes with Postfix snapshot 2.0.16-20031110 +=================================================== + +Preliminary support for limiting the number of connection attempts +from an SMTP client. The limits are disabled by default. The +parameter smtpd_client_connection_count_limit restricts the number +of simultaneous connections by any client, and the parameter +smtpd_client_connection_rate_limit restricts the number of connection +attempts per unit time that any client can make. The time unit is +specified with the connection_rate_time_unit parameter, default +one minute). When Postfix rejects a client, it sends a 450 status +code and disconnects. The smtpd_client_connection_limit_exceptions +parameter takes a list of network blocks or domain names that are +excluded from these restrictions (by default, clients in $mynetworks). + Incompatible changes with Postfix snapshot 2.0.16-20031022 ========================================================== diff --git a/postfix/conf/cidr_table b/postfix/conf/cidr_table index b2bbbaa11..2f3e55798 100644 --- a/postfix/conf/cidr_table +++ b/postfix/conf/cidr_table @@ -25,25 +25,26 @@ # # network_address/network_mask result # When a search string matches the specified network -# block, use the corresponding result value. +# block, use the corresponding result value. Specify +# 0.0.0.0/0 to match every address. # # network_address result -# When a search string matches the specified network +# When a search string matches the specified network # address, use the corresponding result value. # # blank lines and comments -# Empty lines and whitespace-only lines are ignored, -# as are lines whose first non-whitespace character +# Empty lines and whitespace-only lines are ignored, +# as are lines whose first non-whitespace character # is a `#'. # # multi-line text -# A logical line starts with non-whitespace text. A -# line that starts with whitespace continues a logi- +# A logical line starts with non-whitespace text. A +# line that starts with whitespace continues a logi- # cal line. # # SEARCH ORDER -# Patterns are applied in the order as specified in the -# table, until a pattern is found that matches the search +# Patterns are applied in the order as specified in the +# table, until a pattern is found that matches the search # string. # # EXAMPLE SMTPD ACCESS MAP diff --git a/postfix/conf/master.cf b/postfix/conf/master.cf index c3b46d85a..501d0aaa9 100644 --- a/postfix/conf/master.cf +++ b/postfix/conf/master.cf @@ -98,6 +98,7 @@ error unix - - n - - error local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - n - - lmtp +crate unix - - n - 1 crate # # Interfaces to non-Postfix software. Be sure to examine the manual # pages of the non-Postfix software to find out what options it wants. diff --git a/postfix/conf/post-install b/postfix/conf/post-install index 7c46000dc..87536f0d5 100644 --- a/postfix/conf/post-install +++ b/postfix/conf/post-install @@ -572,6 +572,15 @@ EOF echo Editing $config_directory/master.cf, adding missing entry for proxymap service cat >>$config_directory/master.cf </dev/null || { + echo Editing $config_directory/master.cf, adding missing entry for crate service + cat >>$config_directory/master.cf <$@ +crate.8.html: ../src/crate/crate.c + PATH=../mantools:$$PATH; \ + srctoman $? | $(AWK) | nroff -man | uniq | man2html | postlink >$@ + lmtp.8.html: ../src/lmtp/lmtp.c PATH=../mantools:$$PATH; \ srctoman $? | $(AWK) | nroff -man | uniq | man2html | postlink >$@ diff --git a/postfix/html/cidr_table.5.html b/postfix/html/cidr_table.5.html index c7cd67312..8fb59b8e8 100644 --- a/postfix/html/cidr_table.5.html +++ b/postfix/html/cidr_table.5.html @@ -1,4 +1,4 @@ -
+  
 CIDR_TABLE(5)                                       CIDR_TABLE(5)
 
 NAME
@@ -24,27 +24,28 @@ CIDR_TABLE(5)                                       CIDR_TABLE(5)
 TABLE FORMAT
        The general form of a Postfix CIDR table is:
 
-       network_address/network_mask     result
+       network_address/network_mask     result
               When a search string matches the specified  network
-              block, use the corresponding result value.
+              block,  use the corresponding result value. Specify
+              0.0.0.0/0 to match every address.
 
-       network_address     result
-              When  a search string matches the specified network
+       network_address     result
+              When a search string matches the specified  network
               address, use the corresponding result value.
 
        blank lines and comments
-              Empty lines and whitespace-only lines are  ignored,
-              as  are  lines whose first non-whitespace character
+              Empty  lines and whitespace-only lines are ignored,
+              as are lines whose first  non-whitespace  character
               is a `#'.
 
        multi-line text
-              A logical line starts with non-whitespace  text.  A
-              line  that starts with whitespace continues a logi-
+              A  logical  line starts with non-whitespace text. A
+              line that starts with whitespace continues a  logi-
               cal line.
 
 SEARCH ORDER
-       Patterns are applied in the  order  as  specified  in  the
-       table,  until  a  pattern is found that matches the search
+       Patterns  are  applied  in  the  order as specified in the
+       table, until a pattern is found that  matches  the  search
        string.
 
 EXAMPLE SMTPD ACCESS MAP
diff --git a/postfix/html/crate.8.html b/postfix/html/crate.8.html
new file mode 100644
index 000000000..4eb168564
--- /dev/null
+++ b/postfix/html/crate.8.html
@@ -0,0 +1,106 @@
+  
+CRATE(8)                                                 CRATE(8)
+
+NAME
+       crate - Postfix connection count and rate management
+
+SYNOPSIS
+       crate [generic Postfix daemon options]
+
+DESCRIPTION
+       The  Postfix  crate server maintains statistics that other
+       Postfix servers can use to limit the number of  simultane-
+       ous  connections  as  well  as the frequency of connection
+       attempts over a configurable unit of time.  This server is
+       designed  to  run  under  control  by  the  Postfix master
+       server.
+
+PROTOCOL
+       When a connection is established, a  rate  limited  server
+       sends the following request to the crate server:
+
+           request=connect
+           ident=string
+
+       This  registers a new connection for the remote client and
+       the rate limited service specified with string. The  crate
+       server answers with the number of simultaneous connections
+       and the number of connections per unit time for that (ser-
+       vice, client) combination:
+
+           status=0
+           count=number
+           rate=number
+
+       It is left up to the rate limited service to decide if the
+       remote client connection request is acceptable.
+
+       When a remote client disconnects, a  rate  limited  server
+       sends the following request to the crate server:
+
+           request=disconnect
+           ident=string
+
+       This  registers  a  disconnect event for the remote client
+       and the rate limited service specified  with  string.  The
+       rate limit management server replies with:
+
+           status=0
+
+SECURITY
+       The  connection  count  and rate management service is not
+       security sensitive. It does not talk  to  the  network  or
+       local  users,  and it can run chrooted at fixed low privi-
+       lege.
+
+       This server maintains an in-memory table with  information
+       about  past and current clients of a rate limited service.
+       Although state is kept only temporarily, this may  require
+       a  lot  of  memory  when a system handles connections from
+       many remote clients, or when a system comes under  a  dis-
+       tributed  denial  of  service attack. In that case, reduce
+       the time unit over which statistics are kept.
+
+       Systems behind  network  address  translating  routers  or
+       proxies appear to have the same client address and can run
+       into connection count and/or rate limits falsely.
+
+DIAGNOSTICS
+       Problems and transactions are logged to syslogd(8).
+
+BUGS
+       All state is lost when the service is restarted.
+
+       In this first implementation,  a  count  or  rate  limited
+       server can have only one client at a time.
+
+CONFIGURATION PARAMETERS
+       The  following  main.cf parameters are especially relevant
+       to this program. Use the postfix reload  command  after  a
+       configuration change.
+
+       connection_rate_purge_delay
+              How  long  remote  client state is remembered after
+              the remote client has disconnected completely. This
+              should  not  be  smaller than the unit of time over
+              which connection rates are calculated.
+
+       connection_rate_time_unit
+              The unit of time over which  connection  rates  are
+              calculated.
+
+SEE ALSO
+       smtpd(8) Postfix SMTP server
+
+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
+
+                                                         CRATE(8)
+
diff --git a/postfix/html/smtpd.8.html b/postfix/html/smtpd.8.html index 8a615624f..ff9a20737 100644 --- a/postfix/html/smtpd.8.html +++ b/postfix/html/smtpd.8.html @@ -301,6 +301,20 @@ SMTPD(8) SMTPD(8) receipt of RSET etc. only if the number of history lines exceeds the given threshold. + smtpd_client_connection_count_limit + The maximal number of simultaneous connections that + any client is allowed to make to this service. + + smtpd_client_connection_rate_limit + The maximal number of connections per unit time + (specified with connection_rate_time_unit) that any + client is allowed to make to this service. + + smtpd_client_connection_limit_exceptions + Hostnames, .domain names or network address blocks + of clients that are excluded from connection count + or rate limits. + Tarpitting smtpd_error_sleep_time Time to wait in seconds before sending a 4xx or 5xx @@ -308,17 +322,17 @@ 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. Delegated policy @@ -327,17 +341,17 @@ SMTPD(8) SMTPD(8) receiving from a delegated SMTPD policy server. smtpd_policy_service_max_idle - Time after which an unused SMTPD policy service + Time after which an unused SMTPD policy service connection is closed. smtpd_policy_service_timeout - Time after which an active SMTPD policy service + Time after which an active SMTPD policy service connection is closed. UCE control restrictions parent_domain_matches_subdomains - List of Postfix features that use domain.tld pat- - terns to match sub.domain.tld (as opposed to + List of Postfix features that use domain.tld pat- + terns to match sub.domain.tld (as opposed to requiring .domain.tld patterns). smtpd_client_restrictions @@ -345,19 +359,19 @@ SMTPD(8) SMTPD(8) 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 + Restrict what sender addresses are allowed in MAIL FROM commands. smtpd_recipient_restrictions - Restrict what recipient addresses are allowed in + Restrict what recipient addresses are allowed in RCPT TO commands. smtpd_etrn_restrictions @@ -365,96 +379,96 @@ SMTPD(8) SMTPD(8) mands, and what clients may issue ETRN commands. smtpd_data_restrictions - Restrictions on the DATA command. Currently, the - only restriction that makes sense here is + Restrictions on the DATA command. Currently, the + only restriction that makes sense here is reject_unauth_pipelining. 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. smtpd_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. smtpd_null_access_lookup_key - The lookup key to be used in SMTPD access tables - instead of the null sender address. A null sender + The lookup key to be used in SMTPD access tables + instead of the null sender address. A null sender address cannot be looked up. maps_rbl_domains (deprecated) - List of DNS domains that publish the addresses of + List of DNS domains that publish the addresses of blacklisted hosts. This is used with the deprecated reject_maps_rbl restriction. permit_mx_backup_networks - Only domains whose primary MX hosts match the - listed networks are eligible for the per- + Only domains whose primary MX hosts match the + listed networks are eligible for the per- mit_mx_backup feature. relay_domains - Restrict what domains this mail system will relay - mail to. The domains are routed to the delivery + Restrict what domains this mail system will relay + mail to. The domains are routed to the delivery agent specified with the relay_transport setting. Sender/recipient address verification Address verification is implemented by sending probe email - messages that are not actually delivered, and is enabled - via the reject_unverified_{sender,recipient} access - restriction. The status of verification probes is main- + messages that are not actually delivered, and is enabled + via the reject_unverified_{sender,recipient} access + restriction. The status of verification probes is main- tained by the address verification service. address_verify_poll_count - How many times to query the address verification - service for completion of an address verification - request. Specify 1 to implement a simple form of - greylisting, that is, always defer the request for + How many times to query the address verification + service for completion of an address verification + request. Specify 1 to implement a simple form of + greylisting, that is, always defer the request for a new sender or recipient address. address_verify_poll_delay - Time to wait after querying the address verifica- + Time to wait after querying the address verifica- tion service for completion of an address verifica- tion request. UCE control responses access_map_reject_code - Response code when a client violates an access + Response code when a client violates an access database restriction. default_rbl_reply Default template reply when a request is RBL black- - listed. This template is used by the reject_rbl_* - and reject_rhsbl_* restrictions. See also: + listed. This template is used by the reject_rbl_* + and reject_rhsbl_* restrictions. See also: rbl_reply_maps and smtpd_expansion_filter. defer_code - Response code when a client request is rejected by + Response code when a client request is rejected by the defer restriction. invalid_hostname_reject_code - Response code when a client violates the + Response code when a client violates the reject_invalid_hostname restriction. maps_rbl_reject_code Response code when a request is RBL blacklisted. multi_recipient_bounce_reject_code - Response code when a multi-recipient bounce is + Response code when a multi-recipient bounce is blocked. rbl_reply_maps - Table with template responses for RBL blacklisted - requests, indexed by RBL domain name. These tem- + Table with template responses for RBL blacklisted + requests, indexed by RBL domain name. These tem- plates are used by the reject_rbl_* and - reject_rhsbl_* restrictions. See also: + reject_rhsbl_* restrictions. See also: default_rbl_reply and smtpd_expansion_filter. reject_code - Response code when the client matches a reject + Response code when the client matches a reject restriction. relay_domains_reject_code @@ -462,7 +476,7 @@ SMTPD(8) SMTPD(8) mail relay policy. unknown_address_reject_code - Response code when a client violates the + Response code when a client violates the reject_unknown_address restriction. unknown_client_reject_code @@ -471,15 +485,15 @@ SMTPD(8) SMTPD(8) tion. unknown_hostname_reject_code - Response code when a client violates the + Response code when a client violates the reject_unknown_hostname restriction. unverified_sender_reject_code - Response code when a sender address is known to be + Response code when a sender address is known to be undeliverable. unverified_recipient_reject_code - Response code when a recipient address is known to + Response code when a recipient address is known to be undeliverable. SEE ALSO @@ -490,7 +504,7 @@ SMTPD(8) SMTPD(8) verify(8) address verification service LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/makedefs b/postfix/makedefs index 0531121f6..0827f00e3 100644 --- a/postfix/makedefs +++ b/postfix/makedefs @@ -251,14 +251,18 @@ ReliantUNIX-?.5.43) SYSTYPE=ReliantUnix543 SYSLIBS="-lresolv -lsocket -lnsl" ;; Rhapsody.5*|Darwin.*) - SYSTYPE=RHAPSODY5 + SYSTYPE=MACOSX # Use the native compiler by default : ${CC=cc} - AWK=gawk case $RELEASE in - 1.[0-3]) ;; + 1.[0-3]) AWK=gawk + ;; + [2-6].*) AWK=awk + SYSLIBS=-flat_namespace + ;; *) AWK=awk SYSLIBS=-flat_namespace + CCARGS="$CCARGS -DBIND_8_COMPAT -DNO_NETINFO" ;; esac ;; diff --git a/postfix/man/Makefile.in b/postfix/man/Makefile.in index 47656a231..1b6f33a24 100644 --- a/postfix/man/Makefile.in +++ b/postfix/man/Makefile.in @@ -6,7 +6,7 @@ DAEMONS = man8/bounce.8 man8/defer.8 man8/cleanup.8 man8/error.8 man8/local.8 \ man8/lmtp.8 man8/master.8 man8/pickup.8 man8/pipe.8 man8/qmgr.8 \ man8/showq.8 man8/smtp.8 man8/smtpd.8 man8/trivial-rewrite.8 \ man8/nqmgr.8 man8/spawn.8 man8/flush.8 man8/virtual.8 man8/qmqpd.8 \ - man8/verify.8 man8/trace.8 man8/proxymap.8 + man8/verify.8 man8/trace.8 man8/proxymap.8 man8/crate.8 COMMANDS= man1/postalias.1 man1/postcat.1 man1/postconf.1 man1/postfix.1 \ man1/postkick.1 man1/postlock.1 man1/postlog.1 man1/postdrop.1 \ man1/postmap.1 man1/sendmail.1 man1/mailq.1 man1/newaliases.1 \ @@ -39,6 +39,9 @@ man8/defer.8: man8/cleanup.8: ../src/cleanup/cleanup.c ../mantools/srctoman $? >$@ +man8/crate.8: ../src/crate/crate.c + ../mantools/srctoman $? >$@ + man8/error.8: ../src/error/error.c ../mantools/srctoman $? >$@ diff --git a/postfix/man/man1/smtp-sink.1 b/postfix/man/man1/smtp-sink.1 index 637ddc97e..b4a53c51f 100644 --- a/postfix/man/man1/smtp-sink.1 +++ b/postfix/man/man1/smtp-sink.1 @@ -18,8 +18,9 @@ multi-threaded SMTP/LMTP test server .fi \fIsmtp-sink\fR listens on the named host (or address) and port. It takes SMTP messages from the network and throws them away. -The purpose is to measure SMTP client performance, not protocol +The purpose is to measure client performance, not protocol compliance. + Connections can be accepted on IPV4 endpoints or UNIX-domain sockets. IPV4 is the default. This program is the complement of the \fIsmtp-source\fR program. @@ -31,18 +32,18 @@ Do not announce SASL authentication support. Display a running counter that is updated whenever an SMTP QUIT command is executed. .IP \fB-e\fR -Disable ESMTP support. +Do not announce ESMTP support. .IP "\fB-f \fIcommand,command,...\fR" Reject the specified commands with a hard (5xx) error code. .IP \fB-h\fI hostname\fR Use \fIhostname\fR in the SMTP greeting, in the HELO response, and in the EHLO response. The default hostname is "smtp-sink". .IP \fB-L\fR -Enable LMTP rather than SMTP. +Enable LMTP instead of SMTP. .IP "\fB-n \fIcount\fR" Terminate after \fIcount\fR sessions. This is for testing purposes. .IP \fB-p\fR -Disable ESMTP command pipelining. +Do not announce support for ESMTP command pipelining. .IP \fB-P\fR Change the server greeting so that it appears to come through a CISCO PIX system. Implies \fB-e\fR. @@ -59,7 +60,7 @@ Show the SMTP conversations. .IP "\fB-w \fIdelay\fR" Wait \fIdelay\fR seconds before responding to a DATA command. .IP \fB-8\fR -Disable 8BITMIME support. +Do not announce 8BITMIME support. .IP [\fBinet:\fR][\fIhost\fR]:\fIport\fR Listen on network interface \fIhost\fR (default: any interface) TCP port \fIport\fR. Both \fIhost\fR and \fIport\fR may be diff --git a/postfix/man/man5/cidr_table.5 b/postfix/man/man5/cidr_table.5 index 645561c7c..000cb1f2c 100644 --- a/postfix/man/man5/cidr_table.5 +++ b/postfix/man/man5/cidr_table.5 @@ -31,7 +31,8 @@ described in the SYNOPSIS above. The general form of a Postfix CIDR table is: .IP "\fInetwork_address\fB/\fInetwork_mask result\fR" When a search string matches the specified network block, -use the corresponding \fIresult\fR value. +use the corresponding \fIresult\fR value. Specify +0.0.0.0/0 to match every address. .IP "\fInetwork_address result\fR" When a search string matches the specified network address, use the corresponding \fIresult\fR value. diff --git a/postfix/man/man8/crate.8 b/postfix/man/man8/crate.8 new file mode 100644 index 000000000..0481e5d15 --- /dev/null +++ b/postfix/man/man8/crate.8 @@ -0,0 +1,128 @@ +.TH CRATE 8 +.ad +.fi +.SH NAME +crate +\- +Postfix connection count and rate management +.SH SYNOPSIS +.na +.nf +\fBcrate\fR [generic Postfix daemon options] +.SH DESCRIPTION +.ad +.fi +The Postfix \fBcrate\fR server maintains statistics that other +Postfix servers can use to limit the number of simultaneous +connections as well as the frequency of connection attempts +over a configurable unit of time. +This server is designed to run under control by the Postfix +master server. +.SH PROTOCOL +.na +.nf +.ad +.fi +When a connection is established, a rate limited server +sends the following request to the \fBcrate\fR server: +.PP +.in +4 +\fBrequest=connect\fR +.br +\fBident=\fIstring\fR +.in +.PP +This registers a new connection for the remote client and the rate +limited service specified with \fIstring\fR. The \fBcrate\fR server +answers with the number of simultaneous connections and the +number of connections per unit time for that (service, client) +combination: +.PP +.in +4 +\fBstatus=0\fR +.br +\fBcount=\fInumber\fR +.br +\fBrate=\fInumber\fR +.in +.PP +It is left up to the rate limited service to decide if the +remote client connection request is acceptable. +.PP +When a remote client disconnects, a rate limited server +sends the following request to the \fBcrate\fR server: +.PP +.in +4 +\fBrequest=disconnect\fR +.br +\fBident=\fIstring\fR +.in +.PP +This registers a disconnect event for the remote client and the rate +limited service specified with \fIstring\fR. The rate limit management +server replies with: +.PP +.ti +4 +\fBstatus=0\fR +.PP +.SH SECURITY +.na +.nf +.ad +.fi +The connection count and rate management service is not security +sensitive. It does not talk to the network or local users, +and it can run chrooted at fixed low privilege. + +This server maintains an in-memory table with information about +past and current clients of a rate limited service. Although state +is kept only temporarily, this may require a lot of memory when a +system handles connections from many remote clients, or when a system +comes under a distributed denial of service attack. In that case, +reduce the time unit over which statistics are kept. + +Systems behind network address translating routers or proxies +appear to have the same client address and can run into connection +count and/or rate limits falsely. +.SH DIAGNOSTICS +.ad +.fi +Problems and transactions are logged to \fBsyslogd\fR(8). +.SH BUGS +.ad +.fi +All state is lost when the service is restarted. + +In this first implementation, a count or rate limited server +can have only one client at a time. +.SH CONFIGURATION PARAMETERS +.na +.nf +.ad +.fi +The following \fBmain.cf\fR parameters are especially relevant to +this program. Use the \fBpostfix reload\fR command after +a configuration change. +.IP \fBconnection_rate_purge_delay\fR +How long remote client state is remembered after the remote client +has disconnected completely. This should not be smaller than the +unit of time over which connection rates are calculated. +.IP \fBconnection_rate_time_unit\fR +The unit of time over which connection rates are calculated. +.SH SEE ALSO +.na +.nf +smtpd(8) Postfix SMTP server +.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/smtpd.8 b/postfix/man/man8/smtpd.8 index 585c8c36f..ecc3b9d2b 100644 --- a/postfix/man/man8/smtpd.8 +++ b/postfix/man/man8/smtpd.8 @@ -252,6 +252,16 @@ the \fBmessage_size_limit\fR value). .IP \fBsmtpd_history_flush_threshold\fR Flush the command history to postmaster after receipt of RSET etc. only if the number of history lines exceeds the given threshold. +.IP \fBsmtpd_client_connection_count_limit\fR +The maximal number of simultaneous connections that any +client is allowed to make to this service. +.IP \fBsmtpd_client_connection_rate_limit\fR +The maximal number of connections per unit time (specified +with \fBconnection_rate_time_unit\fR) that any client +is allowed to make to this service. +.IP \fBsmtpd_client_connection_limit_exceptions\fR +Hostnames, .domain names or network address blocks of clients +that are excluded from connection count or rate limits. .SH Tarpitting .ad .fi diff --git a/postfix/proto/cidr_table b/postfix/proto/cidr_table index 470e0a8b1..253ba3caf 100644 --- a/postfix/proto/cidr_table +++ b/postfix/proto/cidr_table @@ -23,7 +23,8 @@ # The general form of a Postfix CIDR table is: # .IP "\fInetwork_address\fB/\fInetwork_mask result\fR" # When a search string matches the specified network block, -# use the corresponding \fIresult\fR value. +# use the corresponding \fIresult\fR value. Specify +# 0.0.0.0/0 to match every address. # .IP "\fInetwork_address result\fR" # When a search string matches the specified network address, # use the corresponding \fIresult\fR value. diff --git a/postfix/src/bounce/Makefile.in b/postfix/src/bounce/Makefile.in index 533eb0a73..9cd99c3af 100644 --- a/postfix/src/bounce/Makefile.in +++ b/postfix/src/bounce/Makefile.in @@ -72,6 +72,8 @@ bounce.o: ../../include/iostuff.h bounce.o: ../../include/attr.h bounce.o: ../../include/mail_queue.h bounce.o: ../../include/mail_params.h +bounce.o: ../../include/crate_clnt.h +bounce.o: ../../include/attr_clnt.h bounce.o: ../../include/mail_conf.h bounce.o: ../../include/bounce.h bounce.o: ../../include/deliver_request.h @@ -88,6 +90,9 @@ bounce_append_service.o: ../../include/vbuf.h bounce_append_service.o: ../../include/vstream.h bounce_append_service.o: ../../include/stringops.h bounce_append_service.o: ../../include/mail_params.h +bounce_append_service.o: ../../include/crate_clnt.h +bounce_append_service.o: ../../include/attr_clnt.h +bounce_append_service.o: ../../include/attr.h bounce_append_service.o: ../../include/mail_queue.h bounce_append_service.o: ../../include/quote_822_local.h bounce_append_service.o: ../../include/quote_flags.h @@ -95,7 +100,6 @@ bounce_append_service.o: ../../include/deliver_flock.h bounce_append_service.o: ../../include/myflock.h bounce_append_service.o: ../../include/mail_proto.h bounce_append_service.o: ../../include/iostuff.h -bounce_append_service.o: ../../include/attr.h bounce_append_service.o: bounce_service.h bounce_append_service.o: ../../include/bounce_log.h bounce_cleanup.o: bounce_cleanup.c @@ -115,6 +119,9 @@ bounce_notify_service.o: ../../include/vstream.h bounce_notify_service.o: ../../include/vbuf.h bounce_notify_service.o: ../../include/name_mask.h bounce_notify_service.o: ../../include/mail_params.h +bounce_notify_service.o: ../../include/crate_clnt.h +bounce_notify_service.o: ../../include/attr_clnt.h +bounce_notify_service.o: ../../include/attr.h bounce_notify_service.o: ../../include/mail_queue.h bounce_notify_service.o: ../../include/vstring.h bounce_notify_service.o: ../../include/post_mail.h @@ -137,10 +144,14 @@ bounce_notify_util.o: ../../include/vstream.h bounce_notify_util.o: ../../include/line_wrap.h bounce_notify_util.o: ../../include/stringops.h bounce_notify_util.o: ../../include/xtext.h +bounce_notify_util.o: ../../include/myflock.h bounce_notify_util.o: ../../include/mail_queue.h bounce_notify_util.o: ../../include/quote_822_local.h bounce_notify_util.o: ../../include/quote_flags.h bounce_notify_util.o: ../../include/mail_params.h +bounce_notify_util.o: ../../include/crate_clnt.h +bounce_notify_util.o: ../../include/attr_clnt.h +bounce_notify_util.o: ../../include/attr.h bounce_notify_util.o: ../../include/is_header.h bounce_notify_util.o: ../../include/record.h bounce_notify_util.o: ../../include/rec_type.h @@ -153,7 +164,6 @@ bounce_notify_util.o: ../../include/bounce_log.h bounce_notify_util.o: ../../include/mail_date.h bounce_notify_util.o: ../../include/mail_proto.h bounce_notify_util.o: ../../include/iostuff.h -bounce_notify_util.o: ../../include/attr.h bounce_notify_util.o: ../../include/lex_822.h bounce_notify_util.o: ../../include/deliver_completed.h bounce_notify_util.o: bounce_service.h @@ -164,6 +174,9 @@ bounce_notify_verp.o: ../../include/vstream.h bounce_notify_verp.o: ../../include/vbuf.h bounce_notify_verp.o: ../../include/name_mask.h bounce_notify_verp.o: ../../include/mail_params.h +bounce_notify_verp.o: ../../include/crate_clnt.h +bounce_notify_verp.o: ../../include/attr_clnt.h +bounce_notify_verp.o: ../../include/attr.h bounce_notify_verp.o: ../../include/mail_queue.h bounce_notify_verp.o: ../../include/vstring.h bounce_notify_verp.o: ../../include/post_mail.h @@ -183,6 +196,9 @@ bounce_one_service.o: ../../include/vstream.h bounce_one_service.o: ../../include/vbuf.h bounce_one_service.o: ../../include/name_mask.h bounce_one_service.o: ../../include/mail_params.h +bounce_one_service.o: ../../include/crate_clnt.h +bounce_one_service.o: ../../include/attr_clnt.h +bounce_one_service.o: ../../include/attr.h bounce_one_service.o: ../../include/post_mail.h bounce_one_service.o: ../../include/cleanup_user.h bounce_one_service.o: ../../include/mail_addr.h @@ -199,6 +215,9 @@ bounce_trace_service.o: ../../include/msg.h bounce_trace_service.o: ../../include/vstream.h bounce_trace_service.o: ../../include/vbuf.h bounce_trace_service.o: ../../include/mail_params.h +bounce_trace_service.o: ../../include/crate_clnt.h +bounce_trace_service.o: ../../include/attr_clnt.h +bounce_trace_service.o: ../../include/attr.h bounce_trace_service.o: ../../include/mail_queue.h bounce_trace_service.o: ../../include/vstring.h bounce_trace_service.o: ../../include/post_mail.h @@ -215,6 +234,9 @@ bounce_warn_service.o: ../../include/vstream.h bounce_warn_service.o: ../../include/vbuf.h bounce_warn_service.o: ../../include/name_mask.h bounce_warn_service.o: ../../include/mail_params.h +bounce_warn_service.o: ../../include/crate_clnt.h +bounce_warn_service.o: ../../include/attr_clnt.h +bounce_warn_service.o: ../../include/attr.h bounce_warn_service.o: ../../include/mail_queue.h bounce_warn_service.o: ../../include/vstring.h bounce_warn_service.o: ../../include/post_mail.h diff --git a/postfix/src/cleanup/Makefile.in b/postfix/src/cleanup/Makefile.in index 8eb9a8807..529f1d888 100644 --- a/postfix/src/cleanup/Makefile.in +++ b/postfix/src/cleanup/Makefile.in @@ -98,6 +98,8 @@ cleanup.o: ../../include/mail_proto.h cleanup.o: ../../include/iostuff.h cleanup.o: ../../include/attr.h cleanup.o: ../../include/mail_params.h +cleanup.o: ../../include/crate_clnt.h +cleanup.o: ../../include/attr_clnt.h cleanup.o: ../../include/record.h cleanup.o: ../../include/rec_type.h cleanup.o: ../../include/mail_server.h @@ -126,6 +128,9 @@ cleanup_addr.o: ../../include/stringops.h cleanup_addr.o: ../../include/rec_type.h cleanup_addr.o: ../../include/cleanup_user.h cleanup_addr.o: ../../include/mail_params.h +cleanup_addr.o: ../../include/crate_clnt.h +cleanup_addr.o: ../../include/attr_clnt.h +cleanup_addr.o: ../../include/attr.h cleanup_addr.o: ../../include/ext_prop.h cleanup_addr.o: ../../include/mail_addr.h cleanup_addr.o: ../../include/canon_addr.h @@ -162,6 +167,8 @@ cleanup_api.o: ../../include/bounce.h cleanup_api.o: ../../include/deliver_request.h cleanup_api.o: ../../include/recipient_list.h cleanup_api.o: ../../include/mail_params.h +cleanup_api.o: ../../include/crate_clnt.h +cleanup_api.o: ../../include/attr_clnt.h cleanup_api.o: ../../include/mail_stream.h cleanup_api.o: ../../include/hold_message.h cleanup_api.o: cleanup.h @@ -194,6 +201,9 @@ cleanup_envelope.o: ../../include/rec_type.h cleanup_envelope.o: ../../include/cleanup_user.h cleanup_envelope.o: ../../include/qmgr_user.h cleanup_envelope.o: ../../include/mail_params.h +cleanup_envelope.o: ../../include/crate_clnt.h +cleanup_envelope.o: ../../include/attr_clnt.h +cleanup_envelope.o: ../../include/attr.h cleanup_envelope.o: ../../include/verp_sender.h cleanup_envelope.o: cleanup.h cleanup_envelope.o: ../../include/argv.h @@ -223,9 +233,11 @@ cleanup_extracted.o: ../../include/qmgr_user.h cleanup_extracted.o: ../../include/record.h cleanup_extracted.o: ../../include/rec_type.h cleanup_extracted.o: ../../include/mail_params.h +cleanup_extracted.o: ../../include/crate_clnt.h +cleanup_extracted.o: ../../include/attr_clnt.h +cleanup_extracted.o: ../../include/attr.h cleanup_extracted.o: ../../include/mail_proto.h cleanup_extracted.o: ../../include/iostuff.h -cleanup_extracted.o: ../../include/attr.h cleanup_extracted.o: cleanup.h cleanup_extracted.o: ../../include/argv.h cleanup_extracted.o: ../../include/maps.h @@ -247,11 +259,14 @@ cleanup_init.o: ../../include/iostuff.h cleanup_init.o: ../../include/name_mask.h cleanup_init.o: ../../include/mail_addr.h cleanup_init.o: ../../include/mail_params.h +cleanup_init.o: ../../include/crate_clnt.h +cleanup_init.o: ../../include/attr_clnt.h +cleanup_init.o: ../../include/attr.h +cleanup_init.o: ../../include/vstream.h +cleanup_init.o: ../../include/vbuf.h cleanup_init.o: ../../include/ext_prop.h cleanup_init.o: cleanup.h cleanup_init.o: ../../include/vstring.h -cleanup_init.o: ../../include/vbuf.h -cleanup_init.o: ../../include/vstream.h cleanup_init.o: ../../include/argv.h cleanup_init.o: ../../include/nvtable.h cleanup_init.o: ../../include/htable.h @@ -305,6 +320,9 @@ cleanup_map1n.o: ../../include/vbuf.h cleanup_map1n.o: ../../include/dict.h cleanup_map1n.o: ../../include/vstream.h cleanup_map1n.o: ../../include/mail_params.h +cleanup_map1n.o: ../../include/crate_clnt.h +cleanup_map1n.o: ../../include/attr_clnt.h +cleanup_map1n.o: ../../include/attr.h cleanup_map1n.o: ../../include/mail_addr_map.h cleanup_map1n.o: ../../include/maps.h cleanup_map1n.o: ../../include/cleanup_user.h @@ -333,12 +351,15 @@ cleanup_masquerade.o: ../../include/htable.h cleanup_masquerade.o: ../../include/mymalloc.h cleanup_masquerade.o: ../../include/stringops.h cleanup_masquerade.o: ../../include/mail_params.h +cleanup_masquerade.o: ../../include/crate_clnt.h +cleanup_masquerade.o: ../../include/attr_clnt.h +cleanup_masquerade.o: ../../include/attr.h +cleanup_masquerade.o: ../../include/vstream.h cleanup_masquerade.o: ../../include/tok822.h cleanup_masquerade.o: ../../include/resolve_clnt.h cleanup_masquerade.o: ../../include/quote_822_local.h cleanup_masquerade.o: ../../include/quote_flags.h cleanup_masquerade.o: cleanup.h -cleanup_masquerade.o: ../../include/vstream.h cleanup_masquerade.o: ../../include/nvtable.h cleanup_masquerade.o: ../../include/maps.h cleanup_masquerade.o: ../../include/dict.h @@ -371,13 +392,15 @@ cleanup_message.o: ../../include/header_opts.h cleanup_message.o: ../../include/quote_822_local.h cleanup_message.o: ../../include/quote_flags.h cleanup_message.o: ../../include/mail_params.h +cleanup_message.o: ../../include/crate_clnt.h +cleanup_message.o: ../../include/attr_clnt.h +cleanup_message.o: ../../include/attr.h cleanup_message.o: ../../include/mail_date.h cleanup_message.o: ../../include/mail_addr.h cleanup_message.o: ../../include/is_header.h cleanup_message.o: ../../include/ext_prop.h cleanup_message.o: ../../include/mail_proto.h cleanup_message.o: ../../include/iostuff.h -cleanup_message.o: ../../include/attr.h cleanup_message.o: ../../include/mime_state.h cleanup_message.o: ../../include/lex_822.h cleanup_message.o: cleanup.h @@ -399,6 +422,9 @@ cleanup_out.o: ../../include/record.h cleanup_out.o: ../../include/rec_type.h cleanup_out.o: ../../include/cleanup_user.h cleanup_out.o: ../../include/mail_params.h +cleanup_out.o: ../../include/crate_clnt.h +cleanup_out.o: ../../include/attr_clnt.h +cleanup_out.o: ../../include/attr.h cleanup_out.o: cleanup.h cleanup_out.o: ../../include/argv.h cleanup_out.o: ../../include/nvtable.h @@ -421,13 +447,16 @@ cleanup_out_recipient.o: ../../include/sys_defs.h cleanup_out_recipient.o: ../../include/argv.h cleanup_out_recipient.o: ../../include/been_here.h cleanup_out_recipient.o: ../../include/mail_params.h +cleanup_out_recipient.o: ../../include/crate_clnt.h +cleanup_out_recipient.o: ../../include/attr_clnt.h +cleanup_out_recipient.o: ../../include/attr.h +cleanup_out_recipient.o: ../../include/vstream.h +cleanup_out_recipient.o: ../../include/vbuf.h cleanup_out_recipient.o: ../../include/rec_type.h cleanup_out_recipient.o: ../../include/ext_prop.h cleanup_out_recipient.o: ../../include/cleanup_user.h cleanup_out_recipient.o: cleanup.h cleanup_out_recipient.o: ../../include/vstring.h -cleanup_out_recipient.o: ../../include/vbuf.h -cleanup_out_recipient.o: ../../include/vstream.h cleanup_out_recipient.o: ../../include/nvtable.h cleanup_out_recipient.o: ../../include/htable.h cleanup_out_recipient.o: ../../include/mymalloc.h @@ -476,10 +505,13 @@ cleanup_state.o: ../../include/vbuf.h cleanup_state.o: ../../include/htable.h cleanup_state.o: ../../include/been_here.h cleanup_state.o: ../../include/mail_params.h +cleanup_state.o: ../../include/crate_clnt.h +cleanup_state.o: ../../include/attr_clnt.h +cleanup_state.o: ../../include/attr.h +cleanup_state.o: ../../include/vstream.h cleanup_state.o: ../../include/mime_state.h cleanup_state.o: ../../include/header_opts.h cleanup_state.o: cleanup.h -cleanup_state.o: ../../include/vstream.h cleanup_state.o: ../../include/argv.h cleanup_state.o: ../../include/nvtable.h cleanup_state.o: ../../include/maps.h diff --git a/postfix/src/crate/.indent.pro b/postfix/src/crate/.indent.pro new file mode 120000 index 000000000..5c837eca6 --- /dev/null +++ b/postfix/src/crate/.indent.pro @@ -0,0 +1 @@ +../../.indent.pro \ No newline at end of file diff --git a/postfix/src/crate/.printfck b/postfix/src/crate/.printfck new file mode 100644 index 000000000..66016ed45 --- /dev/null +++ b/postfix/src/crate/.printfck @@ -0,0 +1,25 @@ +been_here_xt 2 0 +bounce_append 5 0 +cleanup_out_format 1 0 +defer_append 5 0 +mail_command 1 0 +mail_print 1 0 +msg_error 0 0 +msg_fatal 0 0 +msg_info 0 0 +msg_panic 0 0 +msg_warn 0 0 +opened 4 0 +post_mail_fprintf 1 0 +qmgr_message_bounce 2 0 +rec_fprintf 2 0 +sent 4 0 +smtp_cmd 1 0 +smtp_mesg_fail 2 0 +smtp_printf 1 0 +smtp_rcpt_fail 3 0 +smtp_site_fail 2 0 +udp_syslog 1 0 +vstream_fprintf 1 0 +vstream_printf 0 0 +vstring_sprintf 1 0 diff --git a/postfix/src/crate/Makefile.in b/postfix/src/crate/Makefile.in new file mode 100644 index 000000000..bb4eba422 --- /dev/null +++ b/postfix/src/crate/Makefile.in @@ -0,0 +1,76 @@ +SHELL = /bin/sh +SRCS = crate.c +OBJS = crate.o +HDRS = +TESTSRC = +WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ + -Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \ + -Wunused +DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE) +CFLAGS = $(DEBUG) $(OPT) $(DEFS) +TESTPROG= +PROG = crate +INC_DIR = ../../include +LIBS = ../../lib/libmaster.a ../../lib/libglobal.a ../../lib/libutil.a + +.c.o:; $(CC) $(CFLAGS) -c $*.c + +$(PROG): $(OBJS) $(LIBS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(SYSLIBS) + +Makefile: Makefile.in + (set -e; echo "# DO NOT EDIT"; $(OPTS) $(SHELL) ../../makedefs && cat $?) >$@ + +test: $(TESTPROG) + +tests: test + +update: ../../libexec/$(PROG) + +../../libexec/$(PROG): $(PROG) + cp $(PROG) ../../libexec + +printfck: $(OBJS) $(PROG) + rm -rf printfck + mkdir printfck + sed '1,/^# do not edit/!d' Makefile >printfck/Makefile + set -e; for i in *.c; do printfck -f .printfck $$i >printfck/$$i; done + cd printfck; make "INC_DIR=../../../include" `cd ..; ls *.o` + +lint: + lint $(DEFS) $(SRCS) $(LINTFIX) + +clean: + rm -f *.o *core $(PROG) $(TESTPROG) junk + rm -rf printfck + +tidy: clean + +depend: $(MAKES) + (sed '1,/^# do not edit/!d' Makefile.in; \ + set -e; for i in [a-z][a-z0-9]*.c; do \ + $(CC) -E $(DEFS) $(INCL) $$i | sed -n -e '/^# *1 *"\([^"]*\)".*/{' \ + -e 's//'`echo $$i|sed 's/c$$/o/'`': \1/' -e 'p' -e '}'; \ + done) | grep -v '[.][o][:][ ][/]' >$$$$ && mv $$$$ Makefile.in + @$(EXPORT) make -f Makefile.in Makefile 1>&2 + +# do not edit below this line - it is generated by 'make depend' +crate.o: crate.c +crate.o: ../../include/sys_defs.h +crate.o: ../../include/msg.h +crate.o: ../../include/mymalloc.h +crate.o: ../../include/htable.h +crate.o: ../../include/binhash.h +crate.o: ../../include/stringops.h +crate.o: ../../include/vstring.h +crate.o: ../../include/vbuf.h +crate.o: ../../include/events.h +crate.o: ../../include/mail_conf.h +crate.o: ../../include/mail_params.h +crate.o: ../../include/crate_clnt.h +crate.o: ../../include/attr_clnt.h +crate.o: ../../include/attr.h +crate.o: ../../include/vstream.h +crate.o: ../../include/mail_proto.h +crate.o: ../../include/iostuff.h +crate.o: ../../include/mail_server.h diff --git a/postfix/src/crate/crate.c b/postfix/src/crate/crate.c new file mode 100644 index 000000000..496c79f74 --- /dev/null +++ b/postfix/src/crate/crate.c @@ -0,0 +1,521 @@ +/*++ +/* NAME +/* crate 8 +/* SUMMARY +/* Postfix connection count and rate management +/* SYNOPSIS +/* \fBcrate\fR [generic Postfix daemon options] +/* DESCRIPTION +/* The Postfix \fBcrate\fR server maintains statistics that other +/* Postfix servers can use to limit the number of simultaneous +/* connections as well as the frequency of connection attempts +/* over a configurable unit of time. +/* This server is designed to run under control by the Postfix +/* master server. +/* PROTOCOL +/* .ad +/* .fi +/* When a connection is established, a rate limited server +/* sends the following request to the \fBcrate\fR server: +/* .PP +/* .in +4 +/* \fBrequest=connect\fR +/* .br +/* \fBident=\fIstring\fR +/* .in +/* .PP +/* This registers a new connection for the remote client and the rate +/* limited service specified with \fIstring\fR. The \fBcrate\fR server +/* answers with the number of simultaneous connections and the +/* number of connections per unit time for that (service, client) +/* combination: +/* .PP +/* .in +4 +/* \fBstatus=0\fR +/* .br +/* \fBcount=\fInumber\fR +/* .br +/* \fBrate=\fInumber\fR +/* .in +/* .PP +/* It is left up to the rate limited service to decide if the +/* remote client connection request is acceptable. +/* .PP +/* When a remote client disconnects, a rate limited server +/* sends the following request to the \fBcrate\fR server: +/* .PP +/* .in +4 +/* \fBrequest=disconnect\fR +/* .br +/* \fBident=\fIstring\fR +/* .in +/* .PP +/* This registers a disconnect event for the remote client and the rate +/* limited service specified with \fIstring\fR. The rate limit management +/* server replies with: +/* .PP +/* .ti +4 +/* \fBstatus=0\fR +/* .PP +/* SECURITY +/* .ad +/* .fi +/* The connection count and rate management service is not security +/* sensitive. It does not talk to the network or local users, +/* and it can run chrooted at fixed low privilege. +/* +/* This server maintains an in-memory table with information about +/* past and current clients of a rate limited service. Although state +/* is kept only temporarily, this may require a lot of memory when a +/* system handles connections from many remote clients, or when a system +/* comes under a distributed denial of service attack. In that case, +/* reduce the time unit over which statistics are kept. +/* +/* Systems behind network address translating routers or proxies +/* appear to have the same client address and can run into connection +/* count and/or rate limits falsely. +/* DIAGNOSTICS +/* Problems and transactions are logged to \fBsyslogd\fR(8). +/* BUGS +/* All state is lost when the service is restarted. +/* +/* In this first implementation, a count or rate limited server +/* can have only one client at a time. +/* CONFIGURATION PARAMETERS +/* .ad +/* .fi +/* The following \fBmain.cf\fR parameters are especially relevant to +/* this program. Use the \fBpostfix reload\fR command after +/* a configuration change. +/* .IP \fBconnection_rate_purge_delay\fR +/* How long remote client state is remembered after the remote client +/* has disconnected completely. This should not be smaller than the +/* unit of time over which connection rates are calculated. +/* .IP \fBconnection_rate_time_unit\fR +/* The unit of time over which connection rates are calculated. +/* SEE ALSO +/* smtpd(8) Postfix SMTP server +/* 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 +/*--*/ + +/* System library. */ + +#include +#include +#include + +/* Utility library. */ + +#include +#include +#include +#include +#include +#include + +/* Global library. */ + +#include +#include +#include +#include + +/* Server skeleton. */ + +#include + +/* Application-specific. */ + +int var_crate_sample; +int var_crate_purge; + + /* + * State. + */ +static HTABLE *crate_remote_map; +static BINHASH *crate_local_map; + + /* + * Remote client state. + */ +typedef struct { + char *ident; /* lookup key */ + int count; /* connection count */ + int rate; /* connection rate */ + time_t start; /* time of first rate sample */ +} CRATE_REMOTE; + + /* + * Local (i.e. rate limit client) state. + */ +typedef struct { + CRATE_REMOTE *crate_remote; /* XXX should be list */ +} CRATE_LOCAL; + + /* + * Silly little macros. + */ +#define STR(x) vstring_str(x) +#define STREQ(x,y) (strcmp((x), (y)) == 0) + + /* + * The following operations are implemented as macros with recognizable + * names so that we don't lose sight of what the code is trying to do, and + * related operations are defined side by side so that it isn't pages apart. + */ +#define CRATE_REMOTE_FIRST(remote, id) \ + do { \ + (remote)->ident = mystrdup(id); \ + (remote)->count = 1; \ + (remote)->rate = 1; \ + (remote)->start = event_time(); \ + } while(0) + +#define CRATE_REMOTE_FREE(remote) \ + do { \ + myfree((remote)->ident); \ + myfree((char *) (remote)); \ + } while(0) + +#define CRATE_REMOTE_NEXT(remote) \ + do { \ + time_t _now = event_time(); \ + if ((remote)->start + var_crate_sample < _now) { \ + (remote)->rate = 1; \ + (remote)->start = _now; \ + } else if ((remote)->rate < INT_MAX) { \ + (remote)->rate += 1; \ + } \ + if ((remote)->count == 0) \ + event_cancel_timer(crate_remote_expire, (char *) remote); \ + (remote)->count++; \ + } while(0) + +#define CRATE_REMOTE_DROP_ONE(remote) \ + do { \ + if ((remote) && (remote)->count > 0) { \ + if (--(remote)->count == 0) \ + event_request_timer(crate_remote_expire, (char *) remote, \ + var_crate_purge); \ + } \ + } while(0) + +#define CRATE_LOCAL_INIT(local) \ + do { \ + (local)->crate_remote = 0; \ + } while(0) + +#define CRATE_LOCAL_ADD_ONE(local, remote) \ + do { \ + /* XXX allow multiple remote clients per local server. */ \ + if ((local)->crate_remote) \ + CRATE_REMOTE_DROP_ONE((local)->crate_remote); \ + (local)->crate_remote = (remote); \ + } while(0) + +#define CRATE_LOCAL_DROP_ONE(local, remote) \ + do { \ + /* XXX allow multiple remote clients per local server. */ \ + if ((local)->crate_remote == (remote)) \ + (local)->crate_remote = 0; \ + } while(0) + +#define CRATE_LOCAL_DROP_ALL(stream, local) \ + do { \ + /* XXX allow multiple remote clients per local server. */ \ + if ((local)->crate_remote) \ + crate_remote_disconnect((stream), (local)->crate_remote->ident); \ + } while (0) + +/* crate_remote_expire - purge expired connection state */ + +static void crate_remote_expire(int unused_event, char *context) +{ + CRATE_REMOTE *crate_remote = (CRATE_REMOTE *) context; + char *myname = "crate_remote_expire"; + + if (msg_verbose) + msg_info("%s %s", myname, crate_remote->ident); + + if (crate_remote->count != 0) + msg_panic("%s: bad connection count: %d", + myname, crate_remote->count); + + htable_delete(crate_remote_map, crate_remote->ident, + (void (*) (char *)) 0); + CRATE_REMOTE_FREE(crate_remote); +} + +/* crate_remote_lookup - dump address status */ + +static void crate_remote_lookup(VSTREAM *client_stream, const char *ident) +{ + CRATE_REMOTE *crate_remote; + char *myname = "crate_remote_lookup"; + HTABLE_INFO **ht_info; + HTABLE_INFO **ht; + + if (msg_verbose) + msg_info("%s fd=%d stream=0x%lx ident=%s", + myname, vstream_fileno(client_stream), + (unsigned long) client_stream, ident); + + /* + * Look up remote client information. + */ + if (STREQ(ident, "*")) { + attr_print_plain(client_stream, ATTR_FLAG_MORE, + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, CRATE_STAT_OK, + ATTR_TYPE_END); + ht_info = htable_list(crate_remote_map); + for (ht = ht_info; *ht; ht++) { + crate_remote = (CRATE_REMOTE *) ht[0]->value; + attr_print_plain(client_stream, ATTR_FLAG_MORE, + ATTR_TYPE_STR, CRATE_ATTR_IDENT, ht[0]->key, + ATTR_TYPE_NUM, CRATE_ATTR_COUNT, crate_remote->count, + ATTR_TYPE_NUM, CRATE_ATTR_RATE, crate_remote->rate, + ATTR_TYPE_END); + } + attr_print_plain(client_stream, ATTR_FLAG_NONE, ATTR_TYPE_END); + myfree((char *) ht_info); + } else if ((crate_remote = + (CRATE_REMOTE *) htable_find(crate_remote_map, ident)) == 0) { + attr_print_plain(client_stream, ATTR_FLAG_NONE, + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, CRATE_STAT_FAIL, + ATTR_TYPE_NUM, CRATE_ATTR_COUNT, 0, + ATTR_TYPE_NUM, CRATE_ATTR_RATE, 0, + ATTR_TYPE_END); + } else { + attr_print_plain(client_stream, ATTR_FLAG_NONE, + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, CRATE_STAT_OK, + ATTR_TYPE_NUM, CRATE_ATTR_COUNT, crate_remote->count, + ATTR_TYPE_NUM, CRATE_ATTR_RATE, crate_remote->rate, + ATTR_TYPE_END); + } +} + +/* crate_remote_connect - report connection event, query address status */ + +static void crate_remote_connect(VSTREAM *client_stream, const char *ident) +{ + CRATE_REMOTE *crate_remote; + CRATE_LOCAL *crate_local; + char *myname = "crate_remote_connect"; + time_t now; + + if (msg_verbose) + msg_info("%s fd=%d stream=0x%lx ident=%s", + myname, vstream_fileno(client_stream), + (unsigned long) client_stream, ident); + + /* + * Look up remote connection count information. Update remote connection + * rate information. Simply reset the counter every var_crate_sample + * seconds. This is easier than maintaining a moving average and it gives + * a quicker response to tresspassers. + */ + if ((crate_remote = + (CRATE_REMOTE *) htable_find(crate_remote_map, ident)) == 0) { + crate_remote = (CRATE_REMOTE *) mymalloc(sizeof(*crate_remote)); + CRATE_REMOTE_FIRST(crate_remote, ident); + htable_enter(crate_remote_map, ident, (char *) crate_remote); + } else { + CRATE_REMOTE_NEXT(crate_remote); + } + + /* + * Record this connection under the local client information, so that we + * can clean up all its connection state when the local client goes away. + */ + if ((crate_local = + (CRATE_LOCAL *) binhash_find(crate_local_map, + (char *) &client_stream, + sizeof(client_stream))) == 0) { + crate_local = (CRATE_LOCAL *) mymalloc(sizeof(*crate_local)); + CRATE_LOCAL_INIT(crate_local); + binhash_enter(crate_local_map, (char *) &client_stream, + sizeof(client_stream), (char *) crate_local); + } + CRATE_LOCAL_ADD_ONE(crate_local, crate_remote); + if (msg_verbose) + msg_info("%s: crate_local 0x%lx", + myname, (unsigned long) crate_local); + + /* + * Respond to the local client. + */ + attr_print_plain(client_stream, ATTR_FLAG_NONE, + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, CRATE_STAT_OK, + ATTR_TYPE_NUM, CRATE_ATTR_COUNT, crate_remote->count, + ATTR_TYPE_NUM, CRATE_ATTR_RATE, crate_remote->rate, + ATTR_TYPE_END); +} + +/* crate_remote_disconnect - report disconnect event */ + +static void crate_remote_disconnect(VSTREAM *client_stream, const char *ident) +{ + CRATE_REMOTE *crate_remote; + CRATE_LOCAL *crate_local; + char *myname = "crate_remote_disconnect"; + + if (msg_verbose) + msg_info("%s fd=%d stream=0x%lx ident=%s", + myname, vstream_fileno(client_stream), + (unsigned long) client_stream, ident); + + /* + * Look up the remote client. + */ + if ((crate_remote = + (CRATE_REMOTE *) htable_find(crate_remote_map, ident)) != 0) + CRATE_REMOTE_DROP_ONE(crate_remote); + + /* + * Update the local client information. + */ + if ((crate_local = + (CRATE_LOCAL *) binhash_find(crate_local_map, + (char *) &client_stream, + sizeof(client_stream))) != 0) + CRATE_LOCAL_DROP_ONE(crate_local, crate_remote); + if (msg_verbose) + msg_info("%s: crate_local 0x%lx", + myname, (unsigned long) crate_local); + + /* + * Respond to the local client. + */ + attr_print_plain(client_stream, ATTR_FLAG_NONE, + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, CRATE_STAT_OK, + ATTR_TYPE_END); +} + +/* crate_service_done - clean up */ + +static void crate_service_done(VSTREAM *client_stream, char *unused_service, + char **unused_argv) +{ + CRATE_LOCAL *crate_local; + char *myname = "crate_service_done"; + + if (msg_verbose) + msg_info("%s fd=%d stream=0x%lx", + myname, vstream_fileno(client_stream), + (unsigned long) client_stream); + + /* + * Look up the local client, and get rid of open remote connection state + * that we still have for this local client. Do not destroy remote client + * status information before it expires. + */ + if ((crate_local = + (CRATE_LOCAL *) binhash_find(crate_local_map, + (char *) &client_stream, + sizeof(client_stream))) != 0) { + if (msg_verbose) + msg_info("%s: crate_local 0x%lx", + myname, (unsigned long) crate_local); + CRATE_LOCAL_DROP_ALL(client_stream, crate_local); + binhash_delete(crate_local_map, + (char *) &client_stream, + sizeof(client_stream), myfree); + } else if (msg_verbose) + msg_info("client socket not found for fd=%d", + vstream_fileno(client_stream)); +} + +/* crate_service - perform service for client */ + +static void crate_service(VSTREAM *client_stream, char *service, char **argv) +{ + VSTRING *request = vstring_alloc(10); + VSTRING *ident = vstring_alloc(10); + + /* + * Sanity check. This service takes no command-line arguments. + */ + if (argv[0]) + msg_fatal("unexpected command-line argument: %s", argv[0]); + + /* + * This routine runs whenever a client connects to the socket dedicated + * to the client connection rate management service. All + * connection-management stuff is handled by the common code in + * multi_server.c. + */ + if (attr_scan_plain(client_stream, + ATTR_FLAG_MISSING | ATTR_FLAG_STRICT, + ATTR_TYPE_STR, CRATE_ATTR_REQ, request, + ATTR_TYPE_STR, CRATE_ATTR_IDENT, ident, + ATTR_TYPE_END) == 2) { + if (STREQ(STR(request), CRATE_REQ_CONN)) { + crate_remote_connect(client_stream, STR(ident)); + } else if (STREQ(STR(request), CRATE_REQ_DISC)) { + crate_remote_disconnect(client_stream, STR(ident)); + } else if (STREQ(STR(request), CRATE_REQ_LOOKUP)) { + crate_remote_lookup(client_stream, STR(ident)); + } else { + msg_warn("unrecognized request: \"%s\", ignored", STR(request)); + attr_print_plain(client_stream, ATTR_FLAG_NONE, + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, CRATE_STAT_FAIL, + ATTR_TYPE_END); + } + vstream_fflush(client_stream); + } else { + /* Note: invokes crate_service_done() */ + multi_server_disconnect(client_stream); + } + vstring_free(ident); + vstring_free(request); +} + +/* post_jail_init - post-jail initialization */ + +static void post_jail_init(char *unused_name, char **unused_argv) +{ + + /* + * Sanity check. + */ + if (var_crate_purge < var_crate_sample) + msg_fatal("%s should not be less than %s", + VAR_CRATE_PURGE, VAR_CRATE_SAMPLE); + + /* + * Initial client state tables. + */ + crate_remote_map = htable_create(1000); + crate_local_map = binhash_create(100); + + /* + * Do not limit the number of client requests. + */ + var_use_limit = 0; +} + +/* main - pass control to the multi-threaded skeleton */ + +int main(int argc, char **argv) +{ + static CONFIG_TIME_TABLE time_table[] = { + VAR_CRATE_SAMPLE, DEF_CRATE_SAMPLE, &var_crate_sample, 1, 0, + VAR_CRATE_PURGE, DEF_CRATE_PURGE, &var_crate_purge, 1, 0, + 0, + }; + + multi_server_main(argc, argv, crate_service, + MAIL_SERVER_TIME_TABLE, time_table, + MAIL_SERVER_POST_INIT, post_jail_init, + MAIL_SERVER_SOLITARY, + MAIL_SERVER_PRE_DISCONN, crate_service_done, + 0); +} diff --git a/postfix/src/flush/Makefile.in b/postfix/src/flush/Makefile.in index 266254d91..f4291ab6e 100644 --- a/postfix/src/flush/Makefile.in +++ b/postfix/src/flush/Makefile.in @@ -70,10 +70,12 @@ flush.o: ../../include/argv.h flush.o: ../../include/scan_dir.h flush.o: ../../include/stringops.h flush.o: ../../include/mail_params.h +flush.o: ../../include/crate_clnt.h +flush.o: ../../include/attr_clnt.h +flush.o: ../../include/attr.h flush.o: ../../include/mail_queue.h flush.o: ../../include/mail_proto.h flush.o: ../../include/iostuff.h -flush.o: ../../include/attr.h flush.o: ../../include/mail_flush.h flush.o: ../../include/flush_clnt.h flush.o: ../../include/mail_conf.h diff --git a/postfix/src/global/Makefile.in b/postfix/src/global/Makefile.in index 4c3761634..575139397 100644 --- a/postfix/src/global/Makefile.in +++ b/postfix/src/global/Makefile.in @@ -22,7 +22,7 @@ SRCS = been_here.c bounce.c canon_addr.c cleanup_strerror.c clnt_stream.c \ verp_sender.c match_parent_style.c mime_state.c header_token.c \ strip_addr.c virtual8_maps.c hold_message.c verify_clnt.c \ trace.c log_adhoc.c verify.c dict_proxy.c mail_dict.c input_transp.c \ - cleanup_strflags.c + cleanup_strflags.c crate_clnt.c OBJS = been_here.o bounce.o canon_addr.o cleanup_strerror.o clnt_stream.o \ debug_peer.o debug_process.o defer.o deliver_completed.o \ deliver_flock.o deliver_pass.o deliver_request.o domain_list.o \ @@ -46,7 +46,7 @@ OBJS = been_here.o bounce.o canon_addr.o cleanup_strerror.o clnt_stream.o \ verp_sender.o match_parent_style.o mime_state.o header_token.o \ strip_addr.o virtual8_maps.o hold_message.o verify_clnt.o \ trace.o log_adhoc.o verify.o dict_proxy.o mail_dict.o input_transp.o \ - cleanup_strflags.o + cleanup_strflags.o crate_clnt.o HDRS = been_here.h bounce.h canon_addr.h cleanup_user.h clnt_stream.h \ config.h debug_peer.h debug_process.h defer.h deliver_completed.h \ deliver_flock.h deliver_pass.h deliver_request.h domain_list.h \ @@ -66,7 +66,7 @@ HDRS = been_here.h bounce.h canon_addr.h cleanup_user.h clnt_stream.h \ match_parent_style.h quote_flags.h mime_state.h header_token.h \ lex_822.h strip_addr.h virtual8_maps.h hold_message.h verify_clnt.h \ trace.h log_adhoc.h verify.h dict_proxy.h mail_dict.h qmgr_user.h \ - input_transp.h + input_transp.h crate_clnt.h TESTSRC = rec2stream.c stream2rec.c recdump.c WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ -Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \ @@ -80,7 +80,7 @@ TESTPROG= domain_list dot_lockfile mail_addr_crunch mail_addr_find \ off_cvt quote_822_local rec2stream recdump resolve_clnt \ resolve_local rewrite_clnt stream2rec string_list tok822_parse \ quote_821_local mail_conf_time mime_state strip_addr \ - virtual8_maps verify_clnt xtext + virtual8_maps verify_clnt xtext crate_clnt LIBS = ../../lib/libutil.a LIB_DIR = ../../lib @@ -248,6 +248,11 @@ xtext: $(LIB) $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS) mv junk $@.o +crate_clnt: $(LIB) + mv $@.o junk + $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS) + mv junk $@.o + tests: tok822_test mime_test mime_nest mime_8bit mime_dom mime_trunc \ mime_cvt mime_cvt2 mime_cvt3 strip_addr_test tok822_limit_test \ virtual8_test xtext_test @@ -375,9 +380,11 @@ abounce.o: ../../include/events.h abounce.o: ../../include/vstream.h abounce.o: ../../include/vbuf.h abounce.o: mail_params.h +abounce.o: crate_clnt.h +abounce.o: ../../include/attr_clnt.h +abounce.o: ../../include/attr.h abounce.o: mail_proto.h abounce.o: ../../include/iostuff.h -abounce.o: ../../include/attr.h abounce.o: abounce.h abounce.o: bounce.h abounce.o: deliver_request.h @@ -398,10 +405,12 @@ bounce.o: ../../include/msg.h bounce.o: ../../include/vstring.h bounce.o: ../../include/vbuf.h bounce.o: mail_params.h -bounce.o: mail_proto.h +bounce.o: crate_clnt.h +bounce.o: ../../include/attr_clnt.h +bounce.o: ../../include/attr.h bounce.o: ../../include/vstream.h +bounce.o: mail_proto.h bounce.o: ../../include/iostuff.h -bounce.o: ../../include/attr.h bounce.o: log_adhoc.h bounce.o: verify.h bounce.o: deliver_request.h @@ -419,9 +428,11 @@ bounce_log.o: ../../include/vstring.h bounce_log.o: ../../include/vstring_vstream.h bounce_log.o: ../../include/stringops.h bounce_log.o: mail_params.h +bounce_log.o: crate_clnt.h +bounce_log.o: ../../include/attr_clnt.h +bounce_log.o: ../../include/attr.h bounce_log.o: mail_proto.h bounce_log.o: ../../include/iostuff.h -bounce_log.o: ../../include/attr.h bounce_log.o: mail_queue.h bounce_log.o: bounce_log.h canon_addr.o: canon_addr.c @@ -453,11 +464,33 @@ clnt_stream.o: ../../include/iostuff.h clnt_stream.o: mail_proto.h clnt_stream.o: ../../include/attr.h clnt_stream.o: mail_params.h +clnt_stream.o: crate_clnt.h +clnt_stream.o: ../../include/attr_clnt.h clnt_stream.o: clnt_stream.h +crate_clnt.o: crate_clnt.c +crate_clnt.o: ../../include/sys_defs.h +crate_clnt.o: ../../include/mymalloc.h +crate_clnt.o: ../../include/msg.h +crate_clnt.o: ../../include/attr_clnt.h +crate_clnt.o: ../../include/attr.h +crate_clnt.o: ../../include/vstream.h +crate_clnt.o: ../../include/vbuf.h +crate_clnt.o: ../../include/stringops.h +crate_clnt.o: ../../include/vstring.h +crate_clnt.o: mail_proto.h +crate_clnt.o: ../../include/iostuff.h +crate_clnt.o: mail_params.h +crate_clnt.o: crate_clnt.h +create_clnt.o: create_clnt.c debug_peer.o: debug_peer.c debug_peer.o: ../../include/sys_defs.h debug_peer.o: ../../include/msg.h debug_peer.o: mail_params.h +debug_peer.o: crate_clnt.h +debug_peer.o: ../../include/attr_clnt.h +debug_peer.o: ../../include/attr.h +debug_peer.o: ../../include/vstream.h +debug_peer.o: ../../include/vbuf.h debug_peer.o: namadr_list.h debug_peer.o: ../../include/match_list.h debug_peer.o: ../../include/match_ops.h @@ -467,6 +500,11 @@ debug_process.o: debug_process.c debug_process.o: ../../include/sys_defs.h debug_process.o: ../../include/msg.h debug_process.o: mail_params.h +debug_process.o: crate_clnt.h +debug_process.o: ../../include/attr_clnt.h +debug_process.o: ../../include/attr.h +debug_process.o: ../../include/vstream.h +debug_process.o: ../../include/vbuf.h debug_process.o: mail_conf.h debug_process.o: debug_process.h defer.o: defer.c @@ -475,11 +513,13 @@ defer.o: ../../include/msg.h defer.o: ../../include/vstring.h defer.o: ../../include/vbuf.h defer.o: mail_params.h -defer.o: mail_queue.h +defer.o: crate_clnt.h +defer.o: ../../include/attr_clnt.h +defer.o: ../../include/attr.h defer.o: ../../include/vstream.h +defer.o: mail_queue.h defer.o: mail_proto.h defer.o: ../../include/iostuff.h -defer.o: ../../include/attr.h defer.o: flush_clnt.h defer.o: verify.h defer.o: deliver_request.h @@ -504,6 +544,10 @@ deliver_flock.o: ../../include/vbuf.h deliver_flock.o: ../../include/myflock.h deliver_flock.o: ../../include/iostuff.h deliver_flock.o: mail_params.h +deliver_flock.o: crate_clnt.h +deliver_flock.o: ../../include/attr_clnt.h +deliver_flock.o: ../../include/attr.h +deliver_flock.o: ../../include/vstream.h deliver_flock.o: deliver_flock.h deliver_pass.o: deliver_pass.c deliver_pass.o: ../../include/sys_defs.h @@ -514,12 +558,14 @@ deliver_pass.o: ../../include/vstream.h deliver_pass.o: ../../include/split_at.h deliver_pass.o: ../../include/mymalloc.h deliver_pass.o: mail_params.h +deliver_pass.o: crate_clnt.h +deliver_pass.o: ../../include/attr_clnt.h +deliver_pass.o: ../../include/attr.h deliver_pass.o: deliver_pass.h deliver_pass.o: deliver_request.h deliver_pass.o: recipient_list.h deliver_pass.o: mail_proto.h deliver_pass.o: ../../include/iostuff.h -deliver_pass.o: ../../include/attr.h deliver_request.o: deliver_request.c deliver_request.o: ../../include/sys_defs.h deliver_request.o: ../../include/msg.h @@ -549,6 +595,8 @@ dict_proxy.o: ../../include/argv.h dict_proxy.o: mail_proto.h dict_proxy.o: ../../include/iostuff.h dict_proxy.o: mail_params.h +dict_proxy.o: crate_clnt.h +dict_proxy.o: ../../include/attr_clnt.h dict_proxy.o: clnt_stream.h dict_proxy.o: dict_proxy.h domain_list.o: domain_list.c @@ -564,6 +612,10 @@ dot_lockfile.o: ../../include/stringops.h dot_lockfile.o: ../../include/mymalloc.h dot_lockfile.o: ../../include/iostuff.h dot_lockfile.o: mail_params.h +dot_lockfile.o: crate_clnt.h +dot_lockfile.o: ../../include/attr_clnt.h +dot_lockfile.o: ../../include/attr.h +dot_lockfile.o: ../../include/vstream.h dot_lockfile.o: dot_lockfile.h dot_lockfile_as.o: dot_lockfile_as.c dot_lockfile_as.o: ../../include/sys_defs.h @@ -577,6 +629,11 @@ ext_prop.o: ext_prop.c ext_prop.o: ../../include/sys_defs.h ext_prop.o: ../../include/name_mask.h ext_prop.o: mail_params.h +ext_prop.o: crate_clnt.h +ext_prop.o: ../../include/attr_clnt.h +ext_prop.o: ../../include/attr.h +ext_prop.o: ../../include/vstream.h +ext_prop.o: ../../include/vbuf.h ext_prop.o: ext_prop.h file_id.o: file_id.c file_id.o: ../../include/sys_defs.h @@ -595,6 +652,8 @@ flush_clnt.o: ../../include/attr.h flush_clnt.o: mail_flush.h flush_clnt.o: flush_clnt.h flush_clnt.o: mail_params.h +flush_clnt.o: crate_clnt.h +flush_clnt.o: ../../include/attr_clnt.h header_opts.o: header_opts.c header_opts.o: ../../include/sys_defs.h header_opts.o: ../../include/msg.h @@ -620,11 +679,19 @@ hold_message.o: ../../include/vstring.h hold_message.o: ../../include/vbuf.h hold_message.o: ../../include/vstream.h hold_message.o: mail_params.h +hold_message.o: crate_clnt.h +hold_message.o: ../../include/attr_clnt.h +hold_message.o: ../../include/attr.h hold_message.o: hold_message.h input_transp.o: input_transp.c input_transp.o: ../../include/sys_defs.h input_transp.o: ../../include/name_mask.h input_transp.o: mail_params.h +input_transp.o: crate_clnt.h +input_transp.o: ../../include/attr_clnt.h +input_transp.o: ../../include/attr.h +input_transp.o: ../../include/vstream.h +input_transp.o: ../../include/vbuf.h input_transp.o: input_transp.h is_header.o: is_header.c is_header.o: ../../include/sys_defs.h @@ -641,6 +708,10 @@ mail_addr.o: ../../include/stringops.h mail_addr.o: ../../include/vstring.h mail_addr.o: ../../include/vbuf.h mail_addr.o: mail_params.h +mail_addr.o: crate_clnt.h +mail_addr.o: ../../include/attr_clnt.h +mail_addr.o: ../../include/attr.h +mail_addr.o: ../../include/vstream.h mail_addr.o: mail_addr.h mail_addr_crunch.o: mail_addr_crunch.c mail_addr_crunch.o: ../../include/sys_defs.h @@ -663,6 +734,9 @@ mail_addr_find.o: ../../include/stringops.h mail_addr_find.o: ../../include/vstring.h mail_addr_find.o: ../../include/mymalloc.h mail_addr_find.o: mail_params.h +mail_addr_find.o: crate_clnt.h +mail_addr_find.o: ../../include/attr_clnt.h +mail_addr_find.o: ../../include/attr.h mail_addr_find.o: strip_addr.h mail_addr_find.o: mail_addr_find.h mail_addr_find.o: maps.h @@ -707,6 +781,9 @@ mail_conf.o: ../../include/safe.h mail_conf.o: ../../include/stringops.h mail_conf.o: ../../include/readlline.h mail_conf.o: mail_params.h +mail_conf.o: crate_clnt.h +mail_conf.o: ../../include/attr_clnt.h +mail_conf.o: ../../include/attr.h mail_conf.o: mail_conf.h mail_conf_bool.o: mail_conf_bool.c mail_conf_bool.o: ../../include/sys_defs.h @@ -778,6 +855,9 @@ mail_copy.o: mail_queue.h mail_copy.o: mail_addr.h mail_copy.o: mark_corrupt.h mail_copy.o: mail_params.h +mail_copy.o: crate_clnt.h +mail_copy.o: ../../include/attr_clnt.h +mail_copy.o: ../../include/attr.h mail_copy.o: mail_copy.h mail_date.o: mail_date.c mail_date.o: ../../include/sys_defs.h @@ -801,11 +881,13 @@ mail_error.o: ../../include/name_mask.h mail_flush.o: mail_flush.c mail_flush.o: ../../include/sys_defs.h mail_flush.o: mail_params.h -mail_flush.o: mail_proto.h +mail_flush.o: crate_clnt.h +mail_flush.o: ../../include/attr_clnt.h +mail_flush.o: ../../include/attr.h mail_flush.o: ../../include/vstream.h mail_flush.o: ../../include/vbuf.h +mail_flush.o: mail_proto.h mail_flush.o: ../../include/iostuff.h -mail_flush.o: ../../include/attr.h mail_flush.o: mail_flush.h mail_open_ok.o: mail_open_ok.c mail_open_ok.o: ../../include/sys_defs.h @@ -837,6 +919,8 @@ mail_params.o: ../../include/iostuff.h mail_params.o: ../../include/attr.h mail_params.o: verp_sender.h mail_params.o: mail_params.h +mail_params.o: crate_clnt.h +mail_params.o: ../../include/attr_clnt.h mail_pathname.o: mail_pathname.c mail_pathname.o: ../../include/sys_defs.h mail_pathname.o: ../../include/stringops.h @@ -861,6 +945,9 @@ mail_queue.o: ../../include/sane_fsops.h mail_queue.o: ../../include/valid_hostname.h mail_queue.o: file_id.h mail_queue.o: mail_params.h +mail_queue.o: crate_clnt.h +mail_queue.o: ../../include/attr_clnt.h +mail_queue.o: ../../include/attr.h mail_queue.o: mail_queue.h mail_run.o: mail_run.c mail_run.o: ../../include/sys_defs.h @@ -870,6 +957,10 @@ mail_run.o: ../../include/vstring.h mail_run.o: ../../include/vbuf.h mail_run.o: ../../include/mymalloc.h mail_run.o: mail_params.h +mail_run.o: crate_clnt.h +mail_run.o: ../../include/attr_clnt.h +mail_run.o: ../../include/attr.h +mail_run.o: ../../include/vstream.h mail_run.o: mail_run.h mail_scan_dir.o: mail_scan_dir.c mail_scan_dir.o: ../../include/sys_defs.h @@ -891,6 +982,8 @@ mail_stream.o: ../../include/attr.h mail_stream.o: mail_queue.h mail_stream.o: opened.h mail_stream.o: mail_params.h +mail_stream.o: crate_clnt.h +mail_stream.o: ../../include/attr_clnt.h mail_stream.o: mail_stream.h mail_task.o: mail_task.c mail_task.o: ../../include/sys_defs.h @@ -898,6 +991,10 @@ mail_task.o: ../../include/vstring.h mail_task.o: ../../include/vbuf.h mail_task.o: ../../include/safe.h mail_task.o: mail_params.h +mail_task.o: crate_clnt.h +mail_task.o: ../../include/attr_clnt.h +mail_task.o: ../../include/attr.h +mail_task.o: ../../include/vstream.h mail_task.o: mail_conf.h mail_task.o: mail_task.h mail_trigger.o: mail_trigger.c @@ -907,10 +1004,12 @@ mail_trigger.o: ../../include/mymalloc.h mail_trigger.o: ../../include/iostuff.h mail_trigger.o: ../../include/trigger.h mail_trigger.o: mail_params.h -mail_trigger.o: mail_proto.h +mail_trigger.o: crate_clnt.h +mail_trigger.o: ../../include/attr_clnt.h +mail_trigger.o: ../../include/attr.h mail_trigger.o: ../../include/vstream.h mail_trigger.o: ../../include/vbuf.h -mail_trigger.o: ../../include/attr.h +mail_trigger.o: mail_proto.h mail_version.o: mail_version.c maps.o: maps.c maps.o: ../../include/sys_defs.h @@ -934,6 +1033,9 @@ mark_corrupt.o: ../../include/set_eugid.h mark_corrupt.o: mail_queue.h mark_corrupt.o: ../../include/vstring.h mark_corrupt.o: mail_params.h +mark_corrupt.o: crate_clnt.h +mark_corrupt.o: ../../include/attr_clnt.h +mark_corrupt.o: ../../include/attr.h mark_corrupt.o: deliver_request.h mark_corrupt.o: recipient_list.h mark_corrupt.o: mark_corrupt.h @@ -943,12 +1045,22 @@ match_parent_style.o: string_list.h match_parent_style.o: ../../include/match_list.h match_parent_style.o: ../../include/match_ops.h match_parent_style.o: mail_params.h +match_parent_style.o: crate_clnt.h +match_parent_style.o: ../../include/attr_clnt.h +match_parent_style.o: ../../include/attr.h +match_parent_style.o: ../../include/vstream.h +match_parent_style.o: ../../include/vbuf.h match_parent_style.o: match_parent_style.h mbox_conf.o: mbox_conf.c mbox_conf.o: ../../include/sys_defs.h mbox_conf.o: ../../include/name_mask.h mbox_conf.o: ../../include/argv.h mbox_conf.o: mail_params.h +mbox_conf.o: crate_clnt.h +mbox_conf.o: ../../include/attr_clnt.h +mbox_conf.o: ../../include/attr.h +mbox_conf.o: ../../include/vstream.h +mbox_conf.o: ../../include/vbuf.h mbox_conf.o: mbox_conf.h mbox_open.o: mbox_open.c mbox_open.o: ../../include/sys_defs.h @@ -975,6 +1087,10 @@ mime_state.o: rec_type.h mime_state.o: is_header.h mime_state.o: header_opts.h mime_state.o: mail_params.h +mime_state.o: crate_clnt.h +mime_state.o: ../../include/attr_clnt.h +mime_state.o: ../../include/attr.h +mime_state.o: ../../include/vstream.h mime_state.o: header_token.h mime_state.o: lex_822.h mime_state.o: mime_state.h @@ -991,6 +1107,9 @@ mkmap_db.o: ../../include/argv.h mkmap_db.o: ../../include/dict_db.h mkmap_db.o: ../../include/myflock.h mkmap_db.o: mail_params.h +mkmap_db.o: crate_clnt.h +mkmap_db.o: ../../include/attr_clnt.h +mkmap_db.o: ../../include/attr.h mkmap_db.o: mkmap.h mkmap_dbm.o: mkmap_dbm.c mkmap_dbm.o: ../../include/sys_defs.h @@ -1026,6 +1145,10 @@ mynetworks.o: ../../include/inet_addr_list.h mynetworks.o: ../../include/name_mask.h mynetworks.o: own_inet_addr.h mynetworks.o: mail_params.h +mynetworks.o: crate_clnt.h +mynetworks.o: ../../include/attr_clnt.h +mynetworks.o: ../../include/attr.h +mynetworks.o: ../../include/vstream.h mynetworks.o: mynetworks.h mypwd.o: mypwd.c mypwd.o: ../../include/sys_defs.h @@ -1062,6 +1185,10 @@ own_inet_addr.o: ../../include/stringops.h own_inet_addr.o: ../../include/vstring.h own_inet_addr.o: ../../include/vbuf.h own_inet_addr.o: mail_params.h +own_inet_addr.o: crate_clnt.h +own_inet_addr.o: ../../include/attr_clnt.h +own_inet_addr.o: ../../include/attr.h +own_inet_addr.o: ../../include/vstream.h own_inet_addr.o: own_inet_addr.h peer_name.o: peer_name.c peer_name.o: ../../include/sys_defs.h @@ -1081,6 +1208,9 @@ pipe_command.o: ../../include/set_ugid.h pipe_command.o: ../../include/set_eugid.h pipe_command.o: ../../include/argv.h pipe_command.o: mail_params.h +pipe_command.o: crate_clnt.h +pipe_command.o: ../../include/attr_clnt.h +pipe_command.o: ../../include/attr.h pipe_command.o: mail_copy.h pipe_command.o: ../../include/clean_env.h pipe_command.o: pipe_command.h @@ -1095,11 +1225,13 @@ post_mail.o: ../../include/vstring.h post_mail.o: ../../include/mymalloc.h post_mail.o: ../../include/events.h post_mail.o: mail_params.h +post_mail.o: crate_clnt.h +post_mail.o: ../../include/attr_clnt.h +post_mail.o: ../../include/attr.h post_mail.o: record.h post_mail.o: rec_type.h post_mail.o: mail_proto.h post_mail.o: ../../include/iostuff.h -post_mail.o: ../../include/attr.h post_mail.o: cleanup_user.h post_mail.o: post_mail.h post_mail.o: mail_date.h @@ -1159,6 +1291,10 @@ remove.o: ../../include/sys_defs.h remove.o: ../../include/vstring.h remove.o: ../../include/vbuf.h remove.o: mail_params.h +remove.o: crate_clnt.h +remove.o: ../../include/attr_clnt.h +remove.o: ../../include/attr.h +remove.o: ../../include/vstream.h resolve_clnt.o: resolve_clnt.c resolve_clnt.o: ../../include/sys_defs.h resolve_clnt.o: ../../include/msg.h @@ -1171,6 +1307,8 @@ resolve_clnt.o: ../../include/iostuff.h resolve_clnt.o: mail_proto.h resolve_clnt.o: ../../include/attr.h resolve_clnt.o: mail_params.h +resolve_clnt.o: crate_clnt.h +resolve_clnt.o: ../../include/attr_clnt.h resolve_clnt.o: clnt_stream.h resolve_clnt.o: resolve_clnt.h resolve_local.o: resolve_local.c @@ -1181,6 +1319,11 @@ resolve_local.o: string_list.h resolve_local.o: ../../include/match_list.h resolve_local.o: ../../include/match_ops.h resolve_local.o: mail_params.h +resolve_local.o: crate_clnt.h +resolve_local.o: ../../include/attr_clnt.h +resolve_local.o: ../../include/attr.h +resolve_local.o: ../../include/vstream.h +resolve_local.o: ../../include/vbuf.h resolve_local.o: own_inet_addr.h resolve_local.o: resolve_local.h resolve_local.o: match_parent_style.h @@ -1198,6 +1341,8 @@ rewrite_clnt.o: quote_flags.h rewrite_clnt.o: mail_proto.h rewrite_clnt.o: ../../include/attr.h rewrite_clnt.o: mail_params.h +rewrite_clnt.o: crate_clnt.h +rewrite_clnt.o: ../../include/attr_clnt.h rewrite_clnt.o: clnt_stream.h rewrite_clnt.o: rewrite_clnt.h sent.o: sent.c @@ -1206,9 +1351,12 @@ sent.o: ../../include/msg.h sent.o: ../../include/vstring.h sent.o: ../../include/vbuf.h sent.o: mail_params.h +sent.o: crate_clnt.h +sent.o: ../../include/attr_clnt.h +sent.o: ../../include/attr.h +sent.o: ../../include/vstream.h sent.o: verify.h sent.o: deliver_request.h -sent.o: ../../include/vstream.h sent.o: recipient_list.h sent.o: log_adhoc.h sent.o: trace.h @@ -1228,6 +1376,11 @@ split_addr.o: split_addr.c split_addr.o: ../../include/sys_defs.h split_addr.o: ../../include/split_at.h split_addr.o: mail_params.h +split_addr.o: crate_clnt.h +split_addr.o: ../../include/attr_clnt.h +split_addr.o: ../../include/attr.h +split_addr.o: ../../include/vstream.h +split_addr.o: ../../include/vbuf.h split_addr.o: mail_addr.h split_addr.o: split_addr.h stream2rec.o: stream2rec.c @@ -1258,6 +1411,9 @@ timed_ipc.o: ../../include/msg.h timed_ipc.o: ../../include/vstream.h timed_ipc.o: ../../include/vbuf.h timed_ipc.o: mail_params.h +timed_ipc.o: crate_clnt.h +timed_ipc.o: ../../include/attr_clnt.h +timed_ipc.o: ../../include/attr.h timed_ipc.o: timed_ipc.h tok822_find.o: tok822_find.c tok822_find.o: ../../include/sys_defs.h @@ -1311,10 +1467,12 @@ trace.o: ../../include/msg.h trace.o: ../../include/vstring.h trace.o: ../../include/vbuf.h trace.o: mail_params.h -trace.o: mail_proto.h +trace.o: crate_clnt.h +trace.o: ../../include/attr_clnt.h +trace.o: ../../include/attr.h trace.o: ../../include/vstream.h +trace.o: mail_proto.h trace.o: ../../include/iostuff.h -trace.o: ../../include/attr.h trace.o: verify_clnt.h trace.o: deliver_request.h trace.o: recipient_list.h @@ -1327,10 +1485,12 @@ verify.o: ../../include/msg.h verify.o: ../../include/vstring.h verify.o: ../../include/vbuf.h verify.o: mail_params.h -verify.o: mail_proto.h +verify.o: crate_clnt.h +verify.o: ../../include/attr_clnt.h +verify.o: ../../include/attr.h verify.o: ../../include/vstream.h +verify.o: mail_proto.h verify.o: ../../include/iostuff.h -verify.o: ../../include/attr.h verify.o: verify_clnt.h verify.o: deliver_request.h verify.o: recipient_list.h @@ -1344,6 +1504,8 @@ verify_clnt.o: ../../include/vbuf.h verify_clnt.o: ../../include/vstring.h verify_clnt.o: ../../include/attr.h verify_clnt.o: mail_params.h +verify_clnt.o: crate_clnt.h +verify_clnt.o: ../../include/attr_clnt.h verify_clnt.o: mail_proto.h verify_clnt.o: ../../include/iostuff.h verify_clnt.o: clnt_stream.h @@ -1355,6 +1517,10 @@ verp_sender.o: ../../include/sys_defs.h verp_sender.o: ../../include/vstring.h verp_sender.o: ../../include/vbuf.h verp_sender.o: mail_params.h +verp_sender.o: crate_clnt.h +verp_sender.o: ../../include/attr_clnt.h +verp_sender.o: ../../include/attr.h +verp_sender.o: ../../include/vstream.h verp_sender.o: verp_sender.h virtual8_maps.o: virtual8_maps.c virtual8_maps.o: ../../include/sys_defs.h @@ -1366,6 +1532,9 @@ virtual8_maps.o: ../../include/vstream.h virtual8_maps.o: ../../include/vbuf.h virtual8_maps.o: ../../include/argv.h virtual8_maps.o: mail_params.h +virtual8_maps.o: crate_clnt.h +virtual8_maps.o: ../../include/attr_clnt.h +virtual8_maps.o: ../../include/attr.h virtual8_maps.o: strip_addr.h virtual8_maps.o: virtual8_maps.h xtext.o: xtext.c diff --git a/postfix/src/global/crate_clnt.c b/postfix/src/global/crate_clnt.c new file mode 100644 index 000000000..c46099ff5 --- /dev/null +++ b/postfix/src/global/crate_clnt.c @@ -0,0 +1,254 @@ +/*++ +/* NAME +/* crate_clnt 3 +/* SUMMARY +/* connection rate client interface +/* SYNOPSIS +/* #include +/* +/* CRATE_CLNT *crate_clnt_create(void) +/* +/* void crate_clnt_free(crate_clnt) +/* CRATE_CLNT *crate_clnt; +/* +/* int crate_clnt_connect(crate_clnt, service, addr, +/* count, rate) +/* CRATE_CLNT *crate_clnt; +/* const char *service; +/* const char *addr; +/* int *count; +/* int *rate; +/* +/* int crate_clnt_disconnect(crate_clnt, service, addr) +/* CRATE_CLNT *crate_clnt; +/* const char *service; +/* const char *addr; +/* +/* int crate_clnt_lookup(crate_clnt, service, addr, +/* count, rate) +/* CRATE_CLNT *crate_clnt; +/* const char *service; +/* const char *addr; +/* int *count; +/* int *rate; +/* DESCRIPTION +/* crate_clnt_create() instantiates a crate service client endpoint. +/* +/* crate_clnt_connect() informs the crate server that a +/* client has connected, and returns the current connection +/* count and connection rate for that client. +/* +/* crate_clnt_disconnect() informs the crate server that a +/* client has disconnected. +/* +/* crate_clnt_lookup() looks up the current connection +/* count and connection rate for that client. +/* +/* crate_clnt_free() destroys a crate service client endpoint. +/* +/* Arguments: +/* .IP crate_clnt +/* Client rate control service handle. +/* .IP service +/* The service that the remote client is connected to. +/* .IP addr +/* Null terminated string that identifies the remote client. +/* .IP count +/* Pointer to storage for the current number of connections from +/* this remote client. +/* .IP rate +/* Pointer to storage for the current connection rate for this +/* remote client. +/* DIAGNOSTICS +/* crate_clnt_connect() and crate_clnt_disconnect() return +/* CRATE_STAT_OK in case of success, CRATE_STAT_FAIL otherwise +/* (either the communication with the server is broken or the +/* server experienced a problem). +/* SEE ALSO +/* crate(8) Postfix client rate control service +/* 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 +/*--*/ + +/* System library. */ + +#include + +/* Utility library. */ + +#include +#include +#include +#include + +/* Global library. */ + +#include +#include +#include + +/* Application specific. */ + +#define CRATE_IDENT(service, addr) \ + printable(concatenate(service, ":", addr, (char *) 0), '?') + +/* crate_clnt_create - instantiate connection rate service client */ + +CRATE_CLNT *crate_clnt_create(void) +{ + ATTR_CLNT *crate_clnt; + + crate_clnt = attr_clnt_create(var_crate_service, var_ipc_timeout, 0, 0); + return ((CRATE_CLNT *) crate_clnt); +} + +/* crate_clnt_free - destroy connection rate service client */ + +void crate_clnt_free(CRATE_CLNT * crate_clnt) +{ + attr_clnt_free((ATTR_CLNT *) crate_clnt); +} + +/* crate_clnt_lookup - status query */ + +int crate_clnt_lookup(CRATE_CLNT * crate_clnt, const char *service, + const char *addr, int *count, int *rate) +{ + char *ident = CRATE_IDENT(service, addr); + int status; + + if (attr_clnt_request((ATTR_CLNT *) crate_clnt, + ATTR_FLAG_NONE, /* Query attributes. */ + ATTR_TYPE_STR, CRATE_ATTR_REQ, CRATE_REQ_LOOKUP, + ATTR_TYPE_STR, CRATE_ATTR_IDENT, ident, + ATTR_TYPE_END, + ATTR_FLAG_MISSING, /* Reply attributes. */ + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, &status, + ATTR_TYPE_NUM, CRATE_ATTR_COUNT, count, + ATTR_TYPE_NUM, CRATE_ATTR_RATE, rate, + ATTR_TYPE_END) != 3) + status = CRATE_STAT_FAIL; + myfree(ident); + return (status); +} + +/* crate_clnt_connect - heads-up and policy query */ + +int crate_clnt_connect(CRATE_CLNT * crate_clnt, const char *service, + const char *addr, int *count, int *rate) +{ + char *ident = CRATE_IDENT(service, addr); + int status; + + if (attr_clnt_request((ATTR_CLNT *) crate_clnt, + ATTR_FLAG_NONE, /* Query attributes. */ + ATTR_TYPE_STR, CRATE_ATTR_REQ, CRATE_REQ_CONN, + ATTR_TYPE_STR, CRATE_ATTR_IDENT, ident, + ATTR_TYPE_END, + ATTR_FLAG_MISSING, /* Reply attributes. */ + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, &status, + ATTR_TYPE_NUM, CRATE_ATTR_COUNT, count, + ATTR_TYPE_NUM, CRATE_ATTR_RATE, rate, + ATTR_TYPE_END) != 3) + status = CRATE_STAT_FAIL; + myfree(ident); + return (status); +} + +/* crate_clnt_disconnect - heads-up only */ + +int crate_clnt_disconnect(CRATE_CLNT * crate_clnt, const char *service, + const char *addr) +{ + char *ident = CRATE_IDENT(service, addr); + int status; + + if (attr_clnt_request((ATTR_CLNT *) crate_clnt, + ATTR_FLAG_NONE, /* Query attributes. */ + ATTR_TYPE_STR, CRATE_ATTR_REQ, CRATE_REQ_DISC, + ATTR_TYPE_STR, CRATE_ATTR_IDENT, ident, + ATTR_TYPE_END, + ATTR_FLAG_MISSING, /* Reply attributes. */ + ATTR_TYPE_NUM, CRATE_ATTR_STATUS, &status, + ATTR_TYPE_END) != 1) + status = CRATE_STAT_FAIL; + myfree(ident); + return (status); +} + +#ifdef TEST + + /* + * Stand-alone client for testing. + */ +#include +#include +#include +#include +#include +#include + +int main(int unused_argc, char **argv) +{ + VSTRING *inbuf = vstring_alloc(1); + char *bufp; + char *cmd; + char *service; + char *addr; + int count; + int rate; + CRATE_CLNT *crate; + + msg_vstream_init(argv[0], VSTREAM_ERR); + + mail_conf_read(); + msg_info("using config files in %s", var_config_dir); + if (chdir(var_queue_dir) < 0) + msg_fatal("chdir %s: %m", var_queue_dir); + + msg_verbose++; + + crate = crate_clnt_create(); + + while (vstring_fgets_nonl(inbuf, VSTREAM_IN)) { + bufp = vstring_str(inbuf); + if ((cmd = mystrtok(&bufp, " ")) == 0 || *bufp == 0 + || (service = mystrtok(&bufp, " ")) == 0 || *service == 0 + || (addr = mystrtok(&bufp, " ")) == 0 || *addr == 0 + || mystrtok(&bufp, " ") != 0) { + vstream_printf("usage: connect service addr|disconnect service addr\n"); + vstream_fflush(VSTREAM_OUT); + continue; + } + if (strncmp(cmd, "connect", 1) == 0) { + if (crate_clnt_connect(crate, service, addr, &count, &rate) != CRATE_STAT_OK) + msg_warn("error!"); + else + vstream_printf("count=%d, rate=%d\n", count, rate); + } else if (strncmp(cmd, "disconnect", 1) == 0) { + if (crate_clnt_disconnect(crate, service, addr) != CRATE_STAT_OK) + msg_warn("error!"); + else + vstream_printf("OK\n"); + } else if (strncmp(cmd, "lookup", 1) == 0) { + if (crate_clnt_lookup(crate, service, addr, &count, &rate) != CRATE_STAT_OK) + msg_warn("error!"); + else + vstream_printf("count=%d, rate=%d\n", count, rate); + } else + vstream_printf("usage: connect ident|disconnect ident\n"); + vstream_fflush(VSTREAM_OUT); + } + vstring_free(inbuf); + crate_clnt_free(crate); + return (0); +} + +#endif diff --git a/postfix/src/global/crate_clnt.h b/postfix/src/global/crate_clnt.h new file mode 100644 index 000000000..bf2dee38e --- /dev/null +++ b/postfix/src/global/crate_clnt.h @@ -0,0 +1,63 @@ +#ifndef _CRATE_CLNT_H_INCLUDED_ +#define _CRATE_CLNT_H_INCLUDED_ + +/*++ +/* NAME +/* crate_clnt 3h +/* SUMMARY +/* connection rate client interface +/* SYNOPSIS +/* #include +/* DESCRIPTION +/* .nf + + /* + * System library. + */ +#include + + /* + * Utility library. + */ +#include + + /* + * Protocol interface: requests and endpoints. + */ +#define CRATE_SERVICE "crate" +#define CRATE_CLASS "private" + +#define CRATE_ATTR_REQ "request" +#define CRATE_REQ_CONN "connect" +#define CRATE_REQ_DISC "disconnect" +#define CRATE_REQ_LOOKUP "lookup" +#define CRATE_ATTR_IDENT "ident" +#define CRATE_ATTR_COUNT "count" +#define CRATE_ATTR_RATE "rate" +#define CRATE_ATTR_STATUS "status" + +#define CRATE_STAT_OK 0 +#define CRATE_STAT_FAIL (-1) + + /* + * Functional interface. + */ +typedef struct CRATE_CLNT CRATE_CLNT; + +extern CRATE_CLNT *crate_clnt_create(void); +extern int crate_clnt_connect(CRATE_CLNT *, const char *, const char *, int *, int *); +extern int crate_clnt_disconnect(CRATE_CLNT *, const char *, const char *); +extern void crate_clnt_free(CRATE_CLNT *); + +/* 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 +/*--*/ + +#endif diff --git a/postfix/src/global/mail_params.c b/postfix/src/global/mail_params.c index aa81791d0..ac43f9ecb 100644 --- a/postfix/src/global/mail_params.c +++ b/postfix/src/global/mail_params.c @@ -250,6 +250,7 @@ char *var_error_service; char *var_flush_service; char *var_verify_service; char *var_trace_service; +char *var_crate_service; int var_db_create_buf; int var_db_read_buf; int var_mime_maxdepth; @@ -481,6 +482,7 @@ void mail_params_init() VAR_FLUSH_SERVICE, DEF_FLUSH_SERVICE, &var_flush_service, 1, 0, VAR_VERIFY_SERVICE, DEF_VERIFY_SERVICE, &var_verify_service, 1, 0, VAR_TRACE_SERVICE, DEF_TRACE_SERVICE, &var_trace_service, 1, 0, + VAR_CRATE_SERVICE, DEF_CRATE_SERVICE, &var_crate_service, 1, 0, 0, }; static CONFIG_STR_FN_TABLE function_str_defaults_2[] = { diff --git a/postfix/src/global/mail_params.h b/postfix/src/global/mail_params.h index 81256e336..59f3994b4 100644 --- a/postfix/src/global/mail_params.h +++ b/postfix/src/global/mail_params.h @@ -1902,6 +1902,38 @@ extern int var_smtpd_policy_ttl; #define CHECK_POLICY_SERVICE "check_policy_service" + /* + * Client rate control. + */ +#define VAR_SMTPD_CRATE_LIMIT "smtpd_client_connection_rate_limit" +#define DEF_SMTPD_CRATE_LIMIT 0 +extern int var_smtpd_crate_limit; + +#define VAR_SMTPD_CCONN_LIMIT "smtpd_client_connection_count_limit" +#define DEF_SMTPD_CCONN_LIMIT 0 +extern int var_smtpd_cconn_limit; + +#define VAR_SMTPD_HOGGERS "smtpd_client_connection_limit_exceptions" +#define DEF_SMTPD_HOGGERS "$" VAR_MYNETWORKS +extern char *var_smtpd_hoggers; + +#define VAR_CRATE_SAMPLE "connection_rate_time_unit" +#define DEF_CRATE_SAMPLE "60s" +extern int var_crate_sample; + +#define VAR_CRATE_PURGE "connection_rate_purge_delay" +#define DEF_CRATE_PURGE "$" VAR_CRATE_SAMPLE +extern int var_crate_purge; + + /* + * Temporary stop gap. + */ +#include + +#define VAR_CRATE_SERVICE "connection_rate_service" +#define DEF_CRATE_SERVICE "local:" CRATE_CLASS "/" CRATE_SERVICE +extern char *var_crate_service; + /* LICENSE /* .ad /* .fi diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 5c6b6ce10..d9fd98164 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change the patchlevel and the release date. Snapshots change the * release date only, unless they include the same bugfix as a patch release. */ -#define MAIL_RELEASE_DATE "20031022" +#define MAIL_RELEASE_DATE "20031110" #define VAR_MAIL_VERSION "mail_version" #define DEF_MAIL_VERSION "2.0.16-" MAIL_RELEASE_DATE diff --git a/postfix/src/lmtp/Makefile.in b/postfix/src/lmtp/Makefile.in index 4b86772e8..f4780a39f 100644 --- a/postfix/src/lmtp/Makefile.in +++ b/postfix/src/lmtp/Makefile.in @@ -75,6 +75,9 @@ lmtp.o: ../../include/vstring.h lmtp.o: ../../include/recipient_list.h lmtp.o: ../../include/mail_queue.h lmtp.o: ../../include/mail_params.h +lmtp.o: ../../include/crate_clnt.h +lmtp.o: ../../include/attr_clnt.h +lmtp.o: ../../include/attr.h lmtp.o: ../../include/mail_conf.h lmtp.o: ../../include/debug_peer.h lmtp.o: ../../include/mail_error.h @@ -90,10 +93,13 @@ lmtp_addr.o: ../../include/mymalloc.h lmtp_addr.o: ../../include/inet_addr_list.h lmtp_addr.o: ../../include/stringops.h lmtp_addr.o: ../../include/mail_params.h +lmtp_addr.o: ../../include/crate_clnt.h +lmtp_addr.o: ../../include/attr_clnt.h +lmtp_addr.o: ../../include/attr.h +lmtp_addr.o: ../../include/vstream.h lmtp_addr.o: ../../include/own_inet_addr.h lmtp_addr.o: ../../include/dns.h lmtp_addr.o: lmtp.h -lmtp_addr.o: ../../include/vstream.h lmtp_addr.o: ../../include/argv.h lmtp_addr.o: ../../include/deliver_request.h lmtp_addr.o: ../../include/recipient_list.h @@ -112,6 +118,9 @@ lmtp_chat.o: ../../include/recipient_list.h lmtp_chat.o: ../../include/deliver_request.h lmtp_chat.o: ../../include/smtp_stream.h lmtp_chat.o: ../../include/mail_params.h +lmtp_chat.o: ../../include/crate_clnt.h +lmtp_chat.o: ../../include/attr_clnt.h +lmtp_chat.o: ../../include/attr.h lmtp_chat.o: ../../include/mail_addr.h lmtp_chat.o: ../../include/post_mail.h lmtp_chat.o: ../../include/cleanup_user.h @@ -132,8 +141,10 @@ lmtp_connect.o: ../../include/stringops.h lmtp_connect.o: ../../include/host_port.h lmtp_connect.o: ../../include/sane_connect.h lmtp_connect.o: ../../include/mail_params.h -lmtp_connect.o: ../../include/mail_proto.h +lmtp_connect.o: ../../include/crate_clnt.h +lmtp_connect.o: ../../include/attr_clnt.h lmtp_connect.o: ../../include/attr.h +lmtp_connect.o: ../../include/mail_proto.h lmtp_connect.o: ../../include/dns.h lmtp_connect.o: lmtp.h lmtp_connect.o: ../../include/argv.h @@ -150,6 +161,9 @@ lmtp_proto.o: ../../include/vstring_vstream.h lmtp_proto.o: ../../include/stringops.h lmtp_proto.o: ../../include/mymalloc.h lmtp_proto.o: ../../include/mail_params.h +lmtp_proto.o: ../../include/crate_clnt.h +lmtp_proto.o: ../../include/attr_clnt.h +lmtp_proto.o: ../../include/attr.h lmtp_proto.o: ../../include/smtp_stream.h lmtp_proto.o: ../../include/mail_queue.h lmtp_proto.o: ../../include/recipient_list.h @@ -166,7 +180,6 @@ lmtp_proto.o: ../../include/quote_821_local.h lmtp_proto.o: ../../include/quote_flags.h lmtp_proto.o: ../../include/mail_proto.h lmtp_proto.o: ../../include/iostuff.h -lmtp_proto.o: ../../include/attr.h lmtp_proto.o: lmtp.h lmtp_proto.o: ../../include/argv.h lmtp_proto.o: lmtp_sasl.h @@ -180,12 +193,15 @@ lmtp_sasl_glue.o: ../../include/vbuf.h lmtp_sasl_glue.o: ../../include/split_at.h lmtp_sasl_glue.o: ../../include/name_mask.h lmtp_sasl_glue.o: ../../include/mail_params.h +lmtp_sasl_glue.o: ../../include/crate_clnt.h +lmtp_sasl_glue.o: ../../include/attr_clnt.h +lmtp_sasl_glue.o: ../../include/attr.h +lmtp_sasl_glue.o: ../../include/vstream.h lmtp_sasl_glue.o: ../../include/string_list.h lmtp_sasl_glue.o: ../../include/match_list.h lmtp_sasl_glue.o: ../../include/match_ops.h lmtp_sasl_glue.o: ../../include/maps.h lmtp_sasl_glue.o: ../../include/dict.h -lmtp_sasl_glue.o: ../../include/vstream.h lmtp_sasl_glue.o: ../../include/argv.h lmtp_sasl_glue.o: lmtp.h lmtp_sasl_glue.o: ../../include/deliver_request.h @@ -196,9 +212,12 @@ lmtp_sasl_proto.o: ../../include/sys_defs.h lmtp_sasl_proto.o: ../../include/msg.h lmtp_sasl_proto.o: ../../include/mymalloc.h lmtp_sasl_proto.o: ../../include/mail_params.h -lmtp_sasl_proto.o: lmtp.h +lmtp_sasl_proto.o: ../../include/crate_clnt.h +lmtp_sasl_proto.o: ../../include/attr_clnt.h +lmtp_sasl_proto.o: ../../include/attr.h lmtp_sasl_proto.o: ../../include/vstream.h lmtp_sasl_proto.o: ../../include/vbuf.h +lmtp_sasl_proto.o: lmtp.h lmtp_sasl_proto.o: ../../include/vstring.h lmtp_sasl_proto.o: ../../include/argv.h lmtp_sasl_proto.o: ../../include/deliver_request.h diff --git a/postfix/src/local/Makefile.in b/postfix/src/local/Makefile.in index 038e81edc..e1eb4167c 100644 --- a/postfix/src/local/Makefile.in +++ b/postfix/src/local/Makefile.in @@ -74,6 +74,9 @@ alias.o: ../../include/stringops.h alias.o: ../../include/vstring.h alias.o: ../../include/mymalloc.h alias.o: ../../include/mail_params.h +alias.o: ../../include/crate_clnt.h +alias.o: ../../include/attr_clnt.h +alias.o: ../../include/attr.h alias.o: ../../include/defer.h alias.o: ../../include/bounce.h alias.o: ../../include/deliver_request.h @@ -106,6 +109,9 @@ command.o: ../../include/recipient_list.h command.o: ../../include/sent.h command.o: ../../include/been_here.h command.o: ../../include/mail_params.h +command.o: ../../include/crate_clnt.h +command.o: ../../include/attr_clnt.h +command.o: ../../include/attr.h command.o: ../../include/pipe_command.h command.o: ../../include/mail_copy.h command.o: local.h @@ -176,6 +182,9 @@ dotforward.o: ../../include/deliver_request.h dotforward.o: ../../include/recipient_list.h dotforward.o: ../../include/been_here.h dotforward.o: ../../include/mail_params.h +dotforward.o: ../../include/crate_clnt.h +dotforward.o: ../../include/attr_clnt.h +dotforward.o: ../../include/attr.h dotforward.o: ../../include/mail_conf.h dotforward.o: ../../include/ext_prop.h dotforward.o: ../../include/sent.h @@ -204,6 +213,9 @@ file.o: ../../include/defer.h file.o: ../../include/sent.h file.o: ../../include/been_here.h file.o: ../../include/mail_params.h +file.o: ../../include/crate_clnt.h +file.o: ../../include/attr_clnt.h +file.o: ../../include/attr.h file.o: ../../include/mbox_conf.h file.o: ../../include/argv.h file.o: ../../include/mbox_open.h @@ -236,6 +248,8 @@ forward.o: ../../include/rec_type.h forward.o: ../../include/mark_corrupt.h forward.o: ../../include/mail_date.h forward.o: ../../include/mail_params.h +forward.o: ../../include/crate_clnt.h +forward.o: ../../include/attr_clnt.h forward.o: local.h forward.o: ../../include/been_here.h forward.o: ../../include/tok822.h @@ -261,6 +275,9 @@ include.o: ../../include/recipient_list.h include.o: ../../include/defer.h include.o: ../../include/been_here.h include.o: ../../include/mail_params.h +include.o: ../../include/crate_clnt.h +include.o: ../../include/attr_clnt.h +include.o: ../../include/attr.h include.o: ../../include/ext_prop.h include.o: ../../include/sent.h include.o: local.h @@ -275,11 +292,14 @@ indirect.o: ../../include/sys_defs.h indirect.o: ../../include/msg.h indirect.o: ../../include/htable.h indirect.o: ../../include/mail_params.h +indirect.o: ../../include/crate_clnt.h +indirect.o: ../../include/attr_clnt.h +indirect.o: ../../include/attr.h +indirect.o: ../../include/vstream.h +indirect.o: ../../include/vbuf.h indirect.o: ../../include/bounce.h indirect.o: ../../include/deliver_request.h indirect.o: ../../include/vstring.h -indirect.o: ../../include/vbuf.h -indirect.o: ../../include/vstream.h indirect.o: ../../include/recipient_list.h indirect.o: ../../include/defer.h indirect.o: ../../include/been_here.h @@ -308,6 +328,9 @@ local.o: ../../include/recipient_list.h local.o: ../../include/deliver_request.h local.o: ../../include/deliver_completed.h local.o: ../../include/mail_params.h +local.o: ../../include/crate_clnt.h +local.o: ../../include/attr_clnt.h +local.o: ../../include/attr.h local.o: ../../include/mail_addr.h local.o: ../../include/mail_conf.h local.o: ../../include/been_here.h @@ -325,9 +348,12 @@ local_expand.o: ../../include/vbuf.h local_expand.o: ../../include/mac_expand.h local_expand.o: ../../include/mac_parse.h local_expand.o: ../../include/mail_params.h +local_expand.o: ../../include/crate_clnt.h +local_expand.o: ../../include/attr_clnt.h +local_expand.o: ../../include/attr.h +local_expand.o: ../../include/vstream.h local_expand.o: local.h local_expand.o: ../../include/htable.h -local_expand.o: ../../include/vstream.h local_expand.o: ../../include/been_here.h local_expand.o: ../../include/tok822.h local_expand.o: ../../include/resolve_clnt.h @@ -356,10 +382,12 @@ mailbox.o: ../../include/sent.h mailbox.o: ../../include/mypwd.h mailbox.o: ../../include/been_here.h mailbox.o: ../../include/mail_params.h +mailbox.o: ../../include/crate_clnt.h +mailbox.o: ../../include/attr_clnt.h +mailbox.o: ../../include/attr.h mailbox.o: ../../include/deliver_pass.h mailbox.o: ../../include/mail_proto.h mailbox.o: ../../include/iostuff.h -mailbox.o: ../../include/attr.h mailbox.o: ../../include/mbox_open.h mailbox.o: ../../include/safe_open.h mailbox.o: ../../include/maps.h @@ -389,6 +417,9 @@ maildir.o: ../../include/recipient_list.h maildir.o: ../../include/defer.h maildir.o: ../../include/sent.h maildir.o: ../../include/mail_params.h +maildir.o: ../../include/crate_clnt.h +maildir.o: ../../include/attr_clnt.h +maildir.o: ../../include/attr.h maildir.o: local.h maildir.o: ../../include/htable.h maildir.o: ../../include/been_here.h @@ -416,6 +447,9 @@ recipient.o: ../../include/deliver_request.h recipient.o: ../../include/recipient_list.h recipient.o: ../../include/defer.h recipient.o: ../../include/mail_params.h +recipient.o: ../../include/crate_clnt.h +recipient.o: ../../include/attr_clnt.h +recipient.o: ../../include/attr.h recipient.o: ../../include/split_addr.h recipient.o: ../../include/strip_addr.h recipient.o: ../../include/ext_prop.h @@ -441,6 +475,8 @@ resolve.o: ../../include/resolve_clnt.h resolve.o: ../../include/rewrite_clnt.h resolve.o: ../../include/tok822.h resolve.o: ../../include/mail_params.h +resolve.o: ../../include/crate_clnt.h +resolve.o: ../../include/attr_clnt.h resolve.o: ../../include/defer.h resolve.o: ../../include/bounce.h resolve.o: ../../include/deliver_request.h @@ -465,6 +501,9 @@ token.o: ../../include/stringops.h token.o: ../../include/tok822.h token.o: ../../include/resolve_clnt.h token.o: ../../include/mail_params.h +token.o: ../../include/crate_clnt.h +token.o: ../../include/attr_clnt.h +token.o: ../../include/attr.h token.o: ../../include/bounce.h token.o: ../../include/deliver_request.h token.o: ../../include/recipient_list.h @@ -484,10 +523,12 @@ unknown.o: ../../include/vbuf.h unknown.o: ../../include/mymalloc.h unknown.o: ../../include/been_here.h unknown.o: ../../include/mail_params.h -unknown.o: ../../include/mail_proto.h +unknown.o: ../../include/crate_clnt.h +unknown.o: ../../include/attr_clnt.h +unknown.o: ../../include/attr.h unknown.o: ../../include/vstream.h +unknown.o: ../../include/mail_proto.h unknown.o: ../../include/iostuff.h -unknown.o: ../../include/attr.h unknown.o: ../../include/bounce.h unknown.o: ../../include/deliver_request.h unknown.o: ../../include/recipient_list.h diff --git a/postfix/src/local/alias.c b/postfix/src/local/alias.c index b4fa86859..ad8ebee7a 100644 --- a/postfix/src/local/alias.c +++ b/postfix/src/local/alias.c @@ -283,10 +283,12 @@ int deliver_alias(LOCAL_STATE state, USER_ATTR usr_attr, msg_warn("mailing list \"%s\" needs an \"owner-%s\" alias", name, name); #endif - if (alias_count < 1) + if (alias_count < 1) { + msg_warn("no recipient in alias lookup result for %s", name); *statusp = defer_append(BOUNCE_FLAGS(state.request), BOUNCE_ATTR(state.msg_attr), - "no recipient in alias lookup result"); + "alias database unavailable"); + } myfree(expansion); if (owner) myfree(owner); diff --git a/postfix/src/master/Makefile.in b/postfix/src/master/Makefile.in index eeb2ce986..888541a76 100644 --- a/postfix/src/master/Makefile.in +++ b/postfix/src/master/Makefile.in @@ -104,6 +104,9 @@ master.o: ../../include/clean_env.h master.o: ../../include/argv.h master.o: ../../include/safe.h master.o: ../../include/mail_params.h +master.o: ../../include/crate_clnt.h +master.o: ../../include/attr_clnt.h +master.o: ../../include/attr.h master.o: ../../include/mail_version.h master.o: ../../include/debug_process.h master.o: ../../include/mail_task.h @@ -138,6 +141,8 @@ master_ent.o: ../../include/mail_proto.h master_ent.o: ../../include/iostuff.h master_ent.o: ../../include/attr.h master_ent.o: ../../include/mail_params.h +master_ent.o: ../../include/crate_clnt.h +master_ent.o: ../../include/attr_clnt.h master_ent.o: ../../include/own_inet_addr.h master_ent.o: master_proto.h master_ent.o: master.h @@ -160,6 +165,10 @@ master_listen.o: ../../include/inet_addr_list.h master_listen.o: ../../include/set_eugid.h master_listen.o: ../../include/set_ugid.h master_listen.o: ../../include/mail_params.h +master_listen.o: ../../include/crate_clnt.h +master_listen.o: ../../include/attr_clnt.h +master_listen.o: ../../include/attr.h +master_listen.o: ../../include/vstream.h master_listen.o: master.h master_proto.o: master_proto.c master_proto.o: ../../include/sys_defs.h @@ -203,6 +212,10 @@ master_vars.o: ../../include/vbuf.h master_vars.o: ../../include/mymalloc.h master_vars.o: ../../include/mail_conf.h master_vars.o: ../../include/mail_params.h +master_vars.o: ../../include/crate_clnt.h +master_vars.o: ../../include/attr_clnt.h +master_vars.o: ../../include/attr.h +master_vars.o: ../../include/vstream.h master_vars.o: master.h master_wakeup.o: master_wakeup.c master_wakeup.o: ../../include/sys_defs.h @@ -217,6 +230,8 @@ master_wakeup.o: ../../include/vbuf.h master_wakeup.o: ../../include/iostuff.h master_wakeup.o: ../../include/attr.h master_wakeup.o: ../../include/mail_params.h +master_wakeup.o: ../../include/crate_clnt.h +master_wakeup.o: ../../include/attr_clnt.h master_wakeup.o: mail_server.h master_wakeup.o: master.h multi_server.o: multi_server.c @@ -241,6 +256,9 @@ multi_server.o: ../../include/split_at.h multi_server.o: ../../include/mail_task.h multi_server.o: ../../include/debug_process.h multi_server.o: ../../include/mail_params.h +multi_server.o: ../../include/crate_clnt.h +multi_server.o: ../../include/attr_clnt.h +multi_server.o: ../../include/attr.h multi_server.o: ../../include/mail_conf.h multi_server.o: ../../include/mail_dict.h multi_server.o: ../../include/timed_ipc.h @@ -268,6 +286,9 @@ single_server.o: ../../include/listen.h single_server.o: ../../include/watchdog.h single_server.o: ../../include/split_at.h single_server.o: ../../include/mail_params.h +single_server.o: ../../include/crate_clnt.h +single_server.o: ../../include/attr_clnt.h +single_server.o: ../../include/attr.h single_server.o: ../../include/mail_task.h single_server.o: ../../include/debug_process.h single_server.o: ../../include/mail_conf.h @@ -297,6 +318,9 @@ trigger_server.o: ../../include/listen.h trigger_server.o: ../../include/watchdog.h trigger_server.o: ../../include/split_at.h trigger_server.o: ../../include/mail_params.h +trigger_server.o: ../../include/crate_clnt.h +trigger_server.o: ../../include/attr_clnt.h +trigger_server.o: ../../include/attr.h trigger_server.o: ../../include/mail_task.h trigger_server.o: ../../include/debug_process.h trigger_server.o: ../../include/mail_conf.h diff --git a/postfix/src/master/mail_server.h b/postfix/src/master/mail_server.h index 068354d5d..4800cbc32 100644 --- a/postfix/src/master/mail_server.h +++ b/postfix/src/master/mail_server.h @@ -29,6 +29,7 @@ #define MAIL_SERVER_PRE_ACCEPT 14 #define MAIL_SERVER_SOLITARY 15 #define MAIL_SERVER_UNLIMITED 16 +#define MAIL_SERVER_PRE_DISCONN 17 #define MAIL_SERVER_IN_FLOW_DELAY 20 @@ -36,6 +37,7 @@ typedef void (*MAIL_SERVER_INIT_FN) (char *, char **); typedef int (*MAIL_SERVER_LOOP_FN) (char *, char **); typedef void (*MAIL_SERVER_EXIT_FN) (char *, char **); typedef void (*MAIL_SERVER_ACCEPT_FN) (char *, char **); +typedef void (*MAIL_SERVER_DISCONN_FN) (VSTREAM *, char *, char **); /* * single_server.c diff --git a/postfix/src/master/multi_server.c b/postfix/src/master/multi_server.c index 5e2b48725..5b27eeff6 100644 --- a/postfix/src/master/multi_server.c +++ b/postfix/src/master/multi_server.c @@ -95,6 +95,11 @@ /* Function to be executed prior to accepting a new connection. /* .sp /* Only the last instance of this parameter type is remembered. +/* .IP "MAIL_SERVER_PRE_DISCONN (VSTREAM *, void *(char *service_name, char **argv))" +/* A pointer to a function that is called +/* by the multi_server_disconnect() function (see below). +/* .sp +/* Only the last instance of this parameter type is remembered. /* .IP "MAIL_SERVER_IN_FLOW_DELAY (none)" /* Pause $in_flow_delay seconds when no "mail flow control token" /* is available. A token is consumed for each connection request. @@ -200,6 +205,7 @@ static void (*multi_server_onexit) (char *, char **); static void (*multi_server_pre_accept) (char *, char **); static VSTREAM *multi_server_lock; static int multi_server_in_flow_delay; +static void (*multi_server_pre_disconn) (VSTREAM *, char *, char **); /* multi_server_exit - normal termination */ @@ -234,6 +240,8 @@ void multi_server_disconnect(VSTREAM *stream) { if (msg_verbose) msg_info("connection closed fd %d", vstream_fileno(stream)); + if (multi_server_pre_disconn) + multi_server_pre_disconn(stream, multi_server_name, multi_server_argv); event_disable_readwrite(vstream_fileno(stream)); (void) vstream_fclose(stream); client_count--; @@ -538,6 +546,9 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) case MAIL_SERVER_PRE_ACCEPT: multi_server_pre_accept = va_arg(ap, MAIL_SERVER_ACCEPT_FN); break; + case MAIL_SERVER_PRE_DISCONN: + multi_server_pre_disconn = va_arg(ap, MAIL_SERVER_DISCONN_FN); + break; case MAIL_SERVER_IN_FLOW_DELAY: multi_server_in_flow_delay = 1; break; diff --git a/postfix/src/nqmgr/Makefile.in b/postfix/src/nqmgr/Makefile.in index c5f6254e7..f3a1c84d6 100644 --- a/postfix/src/nqmgr/Makefile.in +++ b/postfix/src/nqmgr/Makefile.in @@ -75,9 +75,11 @@ qmgr.o: ../../include/vstring.h qmgr.o: ../../include/recipient_list.h qmgr.o: ../../include/mail_conf.h qmgr.o: ../../include/mail_params.h +qmgr.o: ../../include/crate_clnt.h +qmgr.o: ../../include/attr_clnt.h +qmgr.o: ../../include/attr.h qmgr.o: ../../include/mail_proto.h qmgr.o: ../../include/iostuff.h -qmgr.o: ../../include/attr.h qmgr.o: ../../include/mail_flow.h qmgr.o: ../../include/master_proto.h qmgr.o: ../../include/mail_server.h @@ -91,6 +93,9 @@ qmgr_active.o: ../../include/mymalloc.h qmgr_active.o: ../../include/vstream.h qmgr_active.o: ../../include/vbuf.h qmgr_active.o: ../../include/mail_params.h +qmgr_active.o: ../../include/crate_clnt.h +qmgr_active.o: ../../include/attr_clnt.h +qmgr_active.o: ../../include/attr.h qmgr_active.o: ../../include/mail_open_ok.h qmgr_active.o: ../../include/mail_queue.h qmgr_active.o: ../../include/vstring.h @@ -140,6 +145,8 @@ qmgr_deliver.o: ../../include/mail_proto.h qmgr_deliver.o: ../../include/attr.h qmgr_deliver.o: ../../include/recipient_list.h qmgr_deliver.o: ../../include/mail_params.h +qmgr_deliver.o: ../../include/crate_clnt.h +qmgr_deliver.o: ../../include/attr_clnt.h qmgr_deliver.o: ../../include/deliver_request.h qmgr_deliver.o: ../../include/verp_sender.h qmgr_deliver.o: qmgr.h @@ -159,6 +166,9 @@ qmgr_entry.o: ../../include/events.h qmgr_entry.o: ../../include/vstream.h qmgr_entry.o: ../../include/vbuf.h qmgr_entry.o: ../../include/mail_params.h +qmgr_entry.o: ../../include/crate_clnt.h +qmgr_entry.o: ../../include/attr_clnt.h +qmgr_entry.o: ../../include/attr.h qmgr_entry.o: qmgr.h qmgr_entry.o: ../../include/scan_dir.h qmgr_job.o: qmgr_job.c @@ -187,6 +197,9 @@ qmgr_message.o: ../../include/sane_time.h qmgr_message.o: ../../include/dict.h qmgr_message.o: ../../include/mail_queue.h qmgr_message.o: ../../include/mail_params.h +qmgr_message.o: ../../include/crate_clnt.h +qmgr_message.o: ../../include/attr_clnt.h +qmgr_message.o: ../../include/attr.h qmgr_message.o: ../../include/canon_addr.h qmgr_message.o: ../../include/record.h qmgr_message.o: ../../include/rec_type.h @@ -198,7 +211,6 @@ qmgr_message.o: ../../include/opened.h qmgr_message.o: ../../include/verp_sender.h qmgr_message.o: ../../include/mail_proto.h qmgr_message.o: ../../include/iostuff.h -qmgr_message.o: ../../include/attr.h qmgr_message.o: ../../include/qmgr_user.h qmgr_message.o: ../../include/rewrite_clnt.h qmgr_message.o: ../../include/resolve_clnt.h @@ -231,10 +243,13 @@ qmgr_queue.o: ../../include/mymalloc.h qmgr_queue.o: ../../include/events.h qmgr_queue.o: ../../include/htable.h qmgr_queue.o: ../../include/mail_params.h -qmgr_queue.o: ../../include/recipient_list.h -qmgr_queue.o: qmgr.h +qmgr_queue.o: ../../include/crate_clnt.h +qmgr_queue.o: ../../include/attr_clnt.h +qmgr_queue.o: ../../include/attr.h qmgr_queue.o: ../../include/vstream.h qmgr_queue.o: ../../include/vbuf.h +qmgr_queue.o: ../../include/recipient_list.h +qmgr_queue.o: qmgr.h qmgr_queue.o: ../../include/scan_dir.h qmgr_rcpt_list.o: qmgr_rcpt_list.c qmgr_rcpt_list.o: ../../include/sys_defs.h @@ -266,5 +281,7 @@ qmgr_transport.o: ../../include/attr.h qmgr_transport.o: ../../include/recipient_list.h qmgr_transport.o: ../../include/mail_conf.h qmgr_transport.o: ../../include/mail_params.h +qmgr_transport.o: ../../include/crate_clnt.h +qmgr_transport.o: ../../include/attr_clnt.h qmgr_transport.o: qmgr.h qmgr_transport.o: ../../include/scan_dir.h diff --git a/postfix/src/pickup/Makefile.in b/postfix/src/pickup/Makefile.in index 44847920d..03a18d11f 100644 --- a/postfix/src/pickup/Makefile.in +++ b/postfix/src/pickup/Makefile.in @@ -73,6 +73,8 @@ pickup.o: ../../include/attr.h pickup.o: ../../include/cleanup_user.h pickup.o: ../../include/mail_date.h pickup.o: ../../include/mail_params.h +pickup.o: ../../include/crate_clnt.h +pickup.o: ../../include/attr_clnt.h pickup.o: ../../include/mail_conf.h pickup.o: ../../include/record.h pickup.o: ../../include/rec_type.h diff --git a/postfix/src/pipe/Makefile.in b/postfix/src/pipe/Makefile.in index 7f0c13f38..7ded12a62 100644 --- a/postfix/src/pipe/Makefile.in +++ b/postfix/src/pipe/Makefile.in @@ -73,6 +73,9 @@ pipe.o: ../../include/stringops.h pipe.o: ../../include/recipient_list.h pipe.o: ../../include/deliver_request.h pipe.o: ../../include/mail_params.h +pipe.o: ../../include/crate_clnt.h +pipe.o: ../../include/attr_clnt.h +pipe.o: ../../include/attr.h pipe.o: ../../include/mail_conf.h pipe.o: ../../include/bounce.h pipe.o: ../../include/defer.h diff --git a/postfix/src/postalias/Makefile.in b/postfix/src/postalias/Makefile.in index acb8e86b9..3449c6e8d 100644 --- a/postfix/src/postalias/Makefile.in +++ b/postfix/src/postalias/Makefile.in @@ -97,6 +97,9 @@ postalias.o: ../../include/resolve_clnt.h postalias.o: ../../include/mail_conf.h postalias.o: ../../include/mail_dict.h postalias.o: ../../include/mail_params.h +postalias.o: ../../include/crate_clnt.h +postalias.o: ../../include/attr_clnt.h +postalias.o: ../../include/attr.h postalias.o: ../../include/mkmap.h postalias.o: ../../include/dict.h postalias.o: ../../include/argv.h diff --git a/postfix/src/postcat/Makefile.in b/postfix/src/postcat/Makefile.in index dca610880..056161ed8 100644 --- a/postfix/src/postcat/Makefile.in +++ b/postfix/src/postcat/Makefile.in @@ -68,3 +68,6 @@ postcat.o: ../../include/rec_type.h postcat.o: ../../include/mail_queue.h postcat.o: ../../include/mail_conf.h postcat.o: ../../include/mail_params.h +postcat.o: ../../include/crate_clnt.h +postcat.o: ../../include/attr_clnt.h +postcat.o: ../../include/attr.h diff --git a/postfix/src/postconf/Makefile.in b/postfix/src/postconf/Makefile.in index 198be229e..3b47fc392 100644 --- a/postfix/src/postconf/Makefile.in +++ b/postfix/src/postconf/Makefile.in @@ -94,6 +94,8 @@ postconf.o: ../../include/iostuff.h postconf.o: ../../include/attr.h postconf.o: ../../include/mail_version.h postconf.o: ../../include/mail_params.h +postconf.o: ../../include/crate_clnt.h +postconf.o: ../../include/attr_clnt.h postconf.o: ../../include/mail_addr.h postconf.o: ../../include/mbox_conf.h postconf.o: time_vars.h diff --git a/postfix/src/postdrop/Makefile.in b/postfix/src/postdrop/Makefile.in index 846e70fde..e0c5172cc 100644 --- a/postfix/src/postdrop/Makefile.in +++ b/postfix/src/postdrop/Makefile.in @@ -71,6 +71,8 @@ postdrop.o: ../../include/mail_proto.h postdrop.o: ../../include/attr.h postdrop.o: ../../include/mail_queue.h postdrop.o: ../../include/mail_params.h +postdrop.o: ../../include/crate_clnt.h +postdrop.o: ../../include/attr_clnt.h postdrop.o: ../../include/mail_conf.h postdrop.o: ../../include/mail_task.h postdrop.o: ../../include/clean_env.h diff --git a/postfix/src/postfix/Makefile.in b/postfix/src/postfix/Makefile.in index bd1e8f5e3..3a2a86aee 100644 --- a/postfix/src/postfix/Makefile.in +++ b/postfix/src/postfix/Makefile.in @@ -73,3 +73,6 @@ postfix.o: ../../include/argv.h postfix.o: ../../include/safe.h postfix.o: ../../include/mail_conf.h postfix.o: ../../include/mail_params.h +postfix.o: ../../include/crate_clnt.h +postfix.o: ../../include/attr_clnt.h +postfix.o: ../../include/attr.h diff --git a/postfix/src/postkick/Makefile.in b/postfix/src/postkick/Makefile.in index ce8b4a485..99e6b91c4 100644 --- a/postfix/src/postkick/Makefile.in +++ b/postfix/src/postkick/Makefile.in @@ -68,4 +68,6 @@ postkick.o: ../../include/mail_proto.h postkick.o: ../../include/iostuff.h postkick.o: ../../include/attr.h postkick.o: ../../include/mail_params.h +postkick.o: ../../include/crate_clnt.h +postkick.o: ../../include/attr_clnt.h postkick.o: ../../include/mail_conf.h diff --git a/postfix/src/postlock/Makefile.in b/postfix/src/postlock/Makefile.in index 3e95260c3..c90227647 100644 --- a/postfix/src/postlock/Makefile.in +++ b/postfix/src/postlock/Makefile.in @@ -64,6 +64,9 @@ postlock.o: ../../include/vstream.h postlock.o: ../../include/msg_vstream.h postlock.o: ../../include/iostuff.h postlock.o: ../../include/mail_params.h +postlock.o: ../../include/crate_clnt.h +postlock.o: ../../include/attr_clnt.h +postlock.o: ../../include/attr.h postlock.o: ../../include/dot_lockfile.h postlock.o: ../../include/deliver_flock.h postlock.o: ../../include/myflock.h diff --git a/postfix/src/postlog/Makefile.in b/postfix/src/postlog/Makefile.in index 5feba3056..8d7f5ca71 100644 --- a/postfix/src/postlog/Makefile.in +++ b/postfix/src/postlog/Makefile.in @@ -70,4 +70,7 @@ postlog.o: ../../include/msg_output.h postlog.o: ../../include/msg_vstream.h postlog.o: ../../include/msg_syslog.h postlog.o: ../../include/mail_params.h +postlog.o: ../../include/crate_clnt.h +postlog.o: ../../include/attr_clnt.h +postlog.o: ../../include/attr.h postlog.o: ../../include/mail_conf.h diff --git a/postfix/src/postmap/Makefile.in b/postfix/src/postmap/Makefile.in index 5dbb4ccfe..04376b49c 100644 --- a/postfix/src/postmap/Makefile.in +++ b/postfix/src/postmap/Makefile.in @@ -95,6 +95,9 @@ postmap.o: ../../include/set_eugid.h postmap.o: ../../include/mail_conf.h postmap.o: ../../include/mail_dict.h postmap.o: ../../include/mail_params.h +postmap.o: ../../include/crate_clnt.h +postmap.o: ../../include/attr_clnt.h +postmap.o: ../../include/attr.h postmap.o: ../../include/mkmap.h postmap.o: ../../include/dict.h postmap.o: ../../include/argv.h diff --git a/postfix/src/postqueue/Makefile.in b/postfix/src/postqueue/Makefile.in index 29ba1bff4..c919f7da9 100644 --- a/postfix/src/postqueue/Makefile.in +++ b/postfix/src/postqueue/Makefile.in @@ -72,6 +72,8 @@ postqueue.o: ../../include/valid_hostname.h postqueue.o: ../../include/mail_proto.h postqueue.o: ../../include/attr.h postqueue.o: ../../include/mail_params.h +postqueue.o: ../../include/crate_clnt.h +postqueue.o: ../../include/attr_clnt.h postqueue.o: ../../include/mail_conf.h postqueue.o: ../../include/mail_task.h postqueue.o: ../../include/debug_process.h diff --git a/postfix/src/postsuper/Makefile.in b/postfix/src/postsuper/Makefile.in index aacc1841a..24884bc4f 100644 --- a/postfix/src/postsuper/Makefile.in +++ b/postfix/src/postsuper/Makefile.in @@ -73,5 +73,8 @@ postsuper.o: ../../include/sane_fsops.h postsuper.o: ../../include/mail_task.h postsuper.o: ../../include/mail_conf.h postsuper.o: ../../include/mail_params.h +postsuper.o: ../../include/crate_clnt.h +postsuper.o: ../../include/attr_clnt.h +postsuper.o: ../../include/attr.h postsuper.o: ../../include/mail_queue.h postsuper.o: ../../include/mail_open_ok.h diff --git a/postfix/src/proxymap/Makefile.in b/postfix/src/proxymap/Makefile.in index 91d20d838..40022668e 100644 --- a/postfix/src/proxymap/Makefile.in +++ b/postfix/src/proxymap/Makefile.in @@ -68,8 +68,10 @@ proxymap.o: ../../include/vstream.h proxymap.o: ../../include/argv.h proxymap.o: ../../include/mail_conf.h proxymap.o: ../../include/mail_params.h +proxymap.o: ../../include/crate_clnt.h +proxymap.o: ../../include/attr_clnt.h +proxymap.o: ../../include/attr.h proxymap.o: ../../include/mail_proto.h proxymap.o: ../../include/iostuff.h -proxymap.o: ../../include/attr.h proxymap.o: ../../include/dict_proxy.h proxymap.o: ../../include/mail_server.h diff --git a/postfix/src/qmgr/Makefile.in b/postfix/src/qmgr/Makefile.in index 06ead6374..a6d3dea23 100644 --- a/postfix/src/qmgr/Makefile.in +++ b/postfix/src/qmgr/Makefile.in @@ -73,9 +73,11 @@ qmgr.o: ../../include/vstring.h qmgr.o: ../../include/recipient_list.h qmgr.o: ../../include/mail_conf.h qmgr.o: ../../include/mail_params.h +qmgr.o: ../../include/crate_clnt.h +qmgr.o: ../../include/attr_clnt.h +qmgr.o: ../../include/attr.h qmgr.o: ../../include/mail_proto.h qmgr.o: ../../include/iostuff.h -qmgr.o: ../../include/attr.h qmgr.o: ../../include/mail_flow.h qmgr.o: ../../include/master_proto.h qmgr.o: ../../include/mail_server.h @@ -89,6 +91,9 @@ qmgr_active.o: ../../include/mymalloc.h qmgr_active.o: ../../include/vstream.h qmgr_active.o: ../../include/vbuf.h qmgr_active.o: ../../include/mail_params.h +qmgr_active.o: ../../include/crate_clnt.h +qmgr_active.o: ../../include/attr_clnt.h +qmgr_active.o: ../../include/attr.h qmgr_active.o: ../../include/mail_open_ok.h qmgr_active.o: ../../include/mail_queue.h qmgr_active.o: ../../include/vstring.h @@ -138,6 +143,8 @@ qmgr_deliver.o: ../../include/mail_proto.h qmgr_deliver.o: ../../include/attr.h qmgr_deliver.o: ../../include/recipient_list.h qmgr_deliver.o: ../../include/mail_params.h +qmgr_deliver.o: ../../include/crate_clnt.h +qmgr_deliver.o: ../../include/attr_clnt.h qmgr_deliver.o: ../../include/deliver_request.h qmgr_deliver.o: ../../include/verp_sender.h qmgr_deliver.o: qmgr.h @@ -157,6 +164,9 @@ qmgr_entry.o: ../../include/events.h qmgr_entry.o: ../../include/vstream.h qmgr_entry.o: ../../include/vbuf.h qmgr_entry.o: ../../include/mail_params.h +qmgr_entry.o: ../../include/crate_clnt.h +qmgr_entry.o: ../../include/attr_clnt.h +qmgr_entry.o: ../../include/attr.h qmgr_entry.o: qmgr.h qmgr_entry.o: ../../include/scan_dir.h qmgr_message.o: qmgr_message.c @@ -174,6 +184,9 @@ qmgr_message.o: ../../include/myflock.h qmgr_message.o: ../../include/dict.h qmgr_message.o: ../../include/mail_queue.h qmgr_message.o: ../../include/mail_params.h +qmgr_message.o: ../../include/crate_clnt.h +qmgr_message.o: ../../include/attr_clnt.h +qmgr_message.o: ../../include/attr.h qmgr_message.o: ../../include/canon_addr.h qmgr_message.o: ../../include/record.h qmgr_message.o: ../../include/rec_type.h @@ -185,7 +198,6 @@ qmgr_message.o: ../../include/opened.h qmgr_message.o: ../../include/verp_sender.h qmgr_message.o: ../../include/mail_proto.h qmgr_message.o: ../../include/iostuff.h -qmgr_message.o: ../../include/attr.h qmgr_message.o: ../../include/qmgr_user.h qmgr_message.o: ../../include/rewrite_clnt.h qmgr_message.o: ../../include/resolve_clnt.h @@ -209,10 +221,13 @@ qmgr_queue.o: ../../include/mymalloc.h qmgr_queue.o: ../../include/events.h qmgr_queue.o: ../../include/htable.h qmgr_queue.o: ../../include/mail_params.h -qmgr_queue.o: ../../include/recipient_list.h -qmgr_queue.o: qmgr.h +qmgr_queue.o: ../../include/crate_clnt.h +qmgr_queue.o: ../../include/attr_clnt.h +qmgr_queue.o: ../../include/attr.h qmgr_queue.o: ../../include/vstream.h qmgr_queue.o: ../../include/vbuf.h +qmgr_queue.o: ../../include/recipient_list.h +qmgr_queue.o: qmgr.h qmgr_queue.o: ../../include/scan_dir.h qmgr_rcpt_list.o: qmgr_rcpt_list.c qmgr_rcpt_list.o: ../../include/sys_defs.h @@ -244,5 +259,7 @@ qmgr_transport.o: ../../include/attr.h qmgr_transport.o: ../../include/recipient_list.h qmgr_transport.o: ../../include/mail_conf.h qmgr_transport.o: ../../include/mail_params.h +qmgr_transport.o: ../../include/crate_clnt.h +qmgr_transport.o: ../../include/attr_clnt.h qmgr_transport.o: qmgr.h qmgr_transport.o: ../../include/scan_dir.h diff --git a/postfix/src/qmqpd/Makefile.in b/postfix/src/qmqpd/Makefile.in index 2ccd7d449..3af4be58e 100644 --- a/postfix/src/qmqpd/Makefile.in +++ b/postfix/src/qmqpd/Makefile.in @@ -78,11 +78,13 @@ qmqpd.o: ../../include/netstring.h qmqpd.o: ../../include/dict.h qmqpd.o: ../../include/argv.h qmqpd.o: ../../include/mail_params.h +qmqpd.o: ../../include/crate_clnt.h +qmqpd.o: ../../include/attr_clnt.h +qmqpd.o: ../../include/attr.h qmqpd.o: ../../include/record.h qmqpd.o: ../../include/rec_type.h qmqpd.o: ../../include/mail_proto.h qmqpd.o: ../../include/iostuff.h -qmqpd.o: ../../include/attr.h qmqpd.o: ../../include/cleanup_user.h qmqpd.o: ../../include/mail_date.h qmqpd.o: ../../include/mail_conf.h diff --git a/postfix/src/sendmail/Makefile.in b/postfix/src/sendmail/Makefile.in index 7fdaae232..85f4bba0f 100644 --- a/postfix/src/sendmail/Makefile.in +++ b/postfix/src/sendmail/Makefile.in @@ -78,6 +78,8 @@ sendmail.o: ../../include/mail_queue.h sendmail.o: ../../include/mail_proto.h sendmail.o: ../../include/attr.h sendmail.o: ../../include/mail_params.h +sendmail.o: ../../include/crate_clnt.h +sendmail.o: ../../include/attr_clnt.h sendmail.o: ../../include/record.h sendmail.o: ../../include/rec_type.h sendmail.o: ../../include/rec_streamlf.h diff --git a/postfix/src/showq/Makefile.in b/postfix/src/showq/Makefile.in index 2001e4df3..4ceb0c058 100644 --- a/postfix/src/showq/Makefile.in +++ b/postfix/src/showq/Makefile.in @@ -73,6 +73,8 @@ showq.o: ../../include/iostuff.h showq.o: ../../include/attr.h showq.o: ../../include/mail_date.h showq.o: ../../include/mail_params.h +showq.o: ../../include/crate_clnt.h +showq.o: ../../include/attr_clnt.h showq.o: ../../include/mail_scan_dir.h showq.o: ../../include/mail_conf.h showq.o: ../../include/record.h diff --git a/postfix/src/smtp/Makefile.in b/postfix/src/smtp/Makefile.in index d51009814..0fb65aac0 100644 --- a/postfix/src/smtp/Makefile.in +++ b/postfix/src/smtp/Makefile.in @@ -76,13 +76,15 @@ smtp.o: ../../include/deliver_request.h smtp.o: ../../include/vstring.h smtp.o: ../../include/recipient_list.h smtp.o: ../../include/mail_params.h +smtp.o: ../../include/crate_clnt.h +smtp.o: ../../include/attr_clnt.h +smtp.o: ../../include/attr.h smtp.o: ../../include/mail_conf.h smtp.o: ../../include/debug_peer.h smtp.o: ../../include/mail_error.h smtp.o: ../../include/deliver_pass.h smtp.o: ../../include/mail_proto.h smtp.o: ../../include/iostuff.h -smtp.o: ../../include/attr.h smtp.o: ../../include/mail_server.h smtp.o: smtp.h smtp.o: smtp_sasl.h @@ -96,10 +98,13 @@ smtp_addr.o: ../../include/inet_addr_list.h smtp_addr.o: ../../include/stringops.h smtp_addr.o: ../../include/myrand.h smtp_addr.o: ../../include/mail_params.h +smtp_addr.o: ../../include/crate_clnt.h +smtp_addr.o: ../../include/attr_clnt.h +smtp_addr.o: ../../include/attr.h +smtp_addr.o: ../../include/vstream.h smtp_addr.o: ../../include/own_inet_addr.h smtp_addr.o: ../../include/dns.h smtp_addr.o: smtp.h -smtp_addr.o: ../../include/vstream.h smtp_addr.o: ../../include/argv.h smtp_addr.o: ../../include/deliver_request.h smtp_addr.o: ../../include/recipient_list.h @@ -118,6 +123,9 @@ smtp_chat.o: ../../include/recipient_list.h smtp_chat.o: ../../include/deliver_request.h smtp_chat.o: ../../include/smtp_stream.h smtp_chat.o: ../../include/mail_params.h +smtp_chat.o: ../../include/crate_clnt.h +smtp_chat.o: ../../include/attr_clnt.h +smtp_chat.o: ../../include/attr.h smtp_chat.o: ../../include/mail_addr.h smtp_chat.o: ../../include/post_mail.h smtp_chat.o: ../../include/cleanup_user.h @@ -139,6 +147,9 @@ smtp_connect.o: ../../include/stringops.h smtp_connect.o: ../../include/host_port.h smtp_connect.o: ../../include/sane_connect.h smtp_connect.o: ../../include/mail_params.h +smtp_connect.o: ../../include/crate_clnt.h +smtp_connect.o: ../../include/attr_clnt.h +smtp_connect.o: ../../include/attr.h smtp_connect.o: ../../include/own_inet_addr.h smtp_connect.o: ../../include/dns.h smtp_connect.o: smtp.h @@ -158,6 +169,9 @@ smtp_proto.o: ../../include/mymalloc.h smtp_proto.o: ../../include/iostuff.h smtp_proto.o: ../../include/split_at.h smtp_proto.o: ../../include/mail_params.h +smtp_proto.o: ../../include/crate_clnt.h +smtp_proto.o: ../../include/attr_clnt.h +smtp_proto.o: ../../include/attr.h smtp_proto.o: ../../include/smtp_stream.h smtp_proto.o: ../../include/mail_queue.h smtp_proto.o: ../../include/recipient_list.h @@ -173,7 +187,6 @@ smtp_proto.o: ../../include/mark_corrupt.h smtp_proto.o: ../../include/quote_821_local.h smtp_proto.o: ../../include/quote_flags.h smtp_proto.o: ../../include/mail_proto.h -smtp_proto.o: ../../include/attr.h smtp_proto.o: ../../include/mime_state.h smtp_proto.o: ../../include/header_opts.h smtp_proto.o: smtp.h @@ -189,12 +202,15 @@ smtp_sasl_glue.o: ../../include/vbuf.h smtp_sasl_glue.o: ../../include/split_at.h smtp_sasl_glue.o: ../../include/name_mask.h smtp_sasl_glue.o: ../../include/mail_params.h +smtp_sasl_glue.o: ../../include/crate_clnt.h +smtp_sasl_glue.o: ../../include/attr_clnt.h +smtp_sasl_glue.o: ../../include/attr.h +smtp_sasl_glue.o: ../../include/vstream.h smtp_sasl_glue.o: ../../include/string_list.h smtp_sasl_glue.o: ../../include/match_list.h smtp_sasl_glue.o: ../../include/match_ops.h smtp_sasl_glue.o: ../../include/maps.h smtp_sasl_glue.o: ../../include/dict.h -smtp_sasl_glue.o: ../../include/vstream.h smtp_sasl_glue.o: ../../include/argv.h smtp_sasl_glue.o: smtp.h smtp_sasl_glue.o: ../../include/deliver_request.h @@ -205,9 +221,12 @@ smtp_sasl_proto.o: ../../include/sys_defs.h smtp_sasl_proto.o: ../../include/msg.h smtp_sasl_proto.o: ../../include/mymalloc.h smtp_sasl_proto.o: ../../include/mail_params.h -smtp_sasl_proto.o: smtp.h +smtp_sasl_proto.o: ../../include/crate_clnt.h +smtp_sasl_proto.o: ../../include/attr_clnt.h +smtp_sasl_proto.o: ../../include/attr.h smtp_sasl_proto.o: ../../include/vstream.h smtp_sasl_proto.o: ../../include/vbuf.h +smtp_sasl_proto.o: smtp.h smtp_sasl_proto.o: ../../include/vstring.h smtp_sasl_proto.o: ../../include/argv.h smtp_sasl_proto.o: ../../include/deliver_request.h diff --git a/postfix/src/smtpd/Makefile.in b/postfix/src/smtpd/Makefile.in index b098fceb1..797c5805e 100644 --- a/postfix/src/smtpd/Makefile.in +++ b/postfix/src/smtpd/Makefile.in @@ -123,10 +123,12 @@ smtpd.o: ../../include/argv.h smtpd.o: ../../include/watchdog.h smtpd.o: ../../include/iostuff.h smtpd.o: ../../include/mail_params.h +smtpd.o: ../../include/crate_clnt.h +smtpd.o: ../../include/attr_clnt.h +smtpd.o: ../../include/attr.h smtpd.o: ../../include/record.h smtpd.o: ../../include/rec_type.h smtpd.o: ../../include/mail_proto.h -smtpd.o: ../../include/attr.h smtpd.o: ../../include/cleanup_user.h smtpd.o: ../../include/mail_date.h smtpd.o: ../../include/mail_conf.h @@ -173,6 +175,8 @@ smtpd_chat.o: ../../include/mail_proto.h smtpd_chat.o: ../../include/iostuff.h smtpd_chat.o: ../../include/attr.h smtpd_chat.o: ../../include/mail_params.h +smtpd_chat.o: ../../include/crate_clnt.h +smtpd_chat.o: ../../include/attr_clnt.h smtpd_chat.o: ../../include/mail_addr.h smtpd_chat.o: ../../include/post_mail.h smtpd_chat.o: ../../include/cleanup_user.h @@ -207,6 +211,7 @@ smtpd_check.o: ../../include/match_ops.h smtpd_check.o: ../../include/namadr_list.h smtpd_check.o: ../../include/domain_list.h smtpd_check.o: ../../include/mail_params.h +smtpd_check.o: ../../include/crate_clnt.h smtpd_check.o: ../../include/canon_addr.h smtpd_check.o: ../../include/resolve_clnt.h smtpd_check.o: ../../include/mail_error.h @@ -259,6 +264,9 @@ smtpd_proxy.o: ../../include/name_mask.h smtpd_proxy.o: ../../include/smtp_stream.h smtpd_proxy.o: ../../include/cleanup_user.h smtpd_proxy.o: ../../include/mail_params.h +smtpd_proxy.o: ../../include/crate_clnt.h +smtpd_proxy.o: ../../include/attr_clnt.h +smtpd_proxy.o: ../../include/attr.h smtpd_proxy.o: ../../include/rec_type.h smtpd_proxy.o: smtpd.h smtpd_proxy.o: ../../include/argv.h @@ -273,10 +281,13 @@ smtpd_sasl_glue.o: ../../include/match_list.h smtpd_sasl_glue.o: ../../include/match_ops.h smtpd_sasl_glue.o: ../../include/name_mask.h smtpd_sasl_glue.o: ../../include/mail_params.h +smtpd_sasl_glue.o: ../../include/crate_clnt.h +smtpd_sasl_glue.o: ../../include/attr_clnt.h +smtpd_sasl_glue.o: ../../include/attr.h +smtpd_sasl_glue.o: ../../include/vstream.h +smtpd_sasl_glue.o: ../../include/vbuf.h smtpd_sasl_glue.o: ../../include/smtp_stream.h smtpd_sasl_glue.o: ../../include/vstring.h -smtpd_sasl_glue.o: ../../include/vbuf.h -smtpd_sasl_glue.o: ../../include/vstream.h smtpd_sasl_glue.o: smtpd.h smtpd_sasl_glue.o: ../../include/argv.h smtpd_sasl_glue.o: ../../include/mail_stream.h @@ -287,11 +298,13 @@ smtpd_sasl_proto.o: ../../include/sys_defs.h smtpd_sasl_proto.o: ../../include/msg.h smtpd_sasl_proto.o: ../../include/mymalloc.h smtpd_sasl_proto.o: ../../include/mail_params.h -smtpd_sasl_proto.o: ../../include/mail_proto.h +smtpd_sasl_proto.o: ../../include/crate_clnt.h +smtpd_sasl_proto.o: ../../include/attr_clnt.h +smtpd_sasl_proto.o: ../../include/attr.h smtpd_sasl_proto.o: ../../include/vstream.h smtpd_sasl_proto.o: ../../include/vbuf.h +smtpd_sasl_proto.o: ../../include/mail_proto.h smtpd_sasl_proto.o: ../../include/iostuff.h -smtpd_sasl_proto.o: ../../include/attr.h smtpd_sasl_proto.o: ../../include/mail_error.h smtpd_sasl_proto.o: ../../include/name_mask.h smtpd_sasl_proto.o: smtpd.h @@ -312,10 +325,12 @@ smtpd_state.o: ../../include/name_mask.h smtpd_state.o: ../../include/msg.h smtpd_state.o: ../../include/cleanup_user.h smtpd_state.o: ../../include/mail_params.h +smtpd_state.o: ../../include/crate_clnt.h +smtpd_state.o: ../../include/attr_clnt.h +smtpd_state.o: ../../include/attr.h smtpd_state.o: ../../include/mail_error.h smtpd_state.o: ../../include/mail_proto.h smtpd_state.o: ../../include/iostuff.h -smtpd_state.o: ../../include/attr.h smtpd_state.o: smtpd.h smtpd_state.o: ../../include/vstring.h smtpd_state.o: ../../include/argv.h diff --git a/postfix/src/smtpd/smtpd.c b/postfix/src/smtpd/smtpd.c index add76b4b6..a31f3953d 100644 --- a/postfix/src/smtpd/smtpd.c +++ b/postfix/src/smtpd/smtpd.c @@ -238,6 +238,16 @@ /* .IP \fBsmtpd_history_flush_threshold\fR /* Flush the command history to postmaster after receipt of RSET etc. /* only if the number of history lines exceeds the given threshold. +/* .IP \fBsmtpd_client_connection_count_limit\fR +/* The maximal number of simultaneous connections that any +/* client is allowed to make to this service. +/* .IP \fBsmtpd_client_connection_rate_limit\fR +/* The maximal number of connections per unit time (specified +/* with \fBconnection_rate_time_unit\fR) that any client +/* is allowed to make to this service. +/* .IP \fBsmtpd_client_connection_limit_exceptions\fR +/* Hostnames, .domain names or network address blocks of clients +/* that are excluded from connection count or rate limits. /* .SH Tarpitting /* .ad /* .fi @@ -446,6 +456,7 @@ #include #include #include +#include /* Single-threaded server skeleton. */ @@ -544,6 +555,9 @@ int var_smtpd_policy_idle; int var_smtpd_policy_ttl; char *var_xaddr_clients; char *var_xloginfo_clients; +int var_smtpd_crate_limit; +int var_smtpd_cconn_limit; +char *var_smtpd_hoggers; /* * Silly little macros. @@ -571,6 +585,12 @@ static NAMADR_LIST *xaddr_clients; */ static NAMADR_LIST *xloginfo_clients; + /* + * Client connection and rate limiting. + */ +CRATE_CLNT *crate_clnt; +static NAMADR_LIST *hogger_list; + /* * Other application-specific globals. */ @@ -1616,6 +1636,13 @@ static int quit_cmd(SMTPD_STATE *state, int unused_argc, SMTPD_TOKEN *unused_arg * Don't bother checking the syntax. */ smtpd_chat_reply(state, "221 Bye"); + + /* + * When the "." and quit replies are pipelined, make sure they are + * flushed now, to avoid repeated mail deliveries in case of a crash in + * the "clean up before disconnect" code. + */ + vstream_fflush(state->client); return (0); } @@ -1663,7 +1690,6 @@ static int xaddr_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) static int xloginfo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) { - char *cp; /* * Sanity checks. @@ -1760,11 +1786,13 @@ static STRING_LIST *smtpd_noop_cmds; /* smtpd_proto - talk the SMTP protocol */ -static void smtpd_proto(SMTPD_STATE *state) +static void smtpd_proto(SMTPD_STATE *state, const char *service) { int argc; SMTPD_TOKEN *argv; SMTPD_CMD *cmdp; + int count; + int crate; /* * Print a greeting banner and run the state machine. Read SMTP commands @@ -1803,6 +1831,26 @@ static void smtpd_proto(SMTPD_STATE *state) break; case 0: + if (SMTPD_STAND_ALONE(state) == 0 + && crate_clnt + && !namadr_list_match(hogger_list, state->name, state->addr) + && crate_clnt_connect(crate_clnt, service, state->addr, + &count, &crate) == CRATE_STAT_OK) { + if (var_smtpd_cconn_limit > 0 && count > var_smtpd_cconn_limit) { + smtpd_chat_reply(state, "450 Too many connections from %s", + state->addr); + msg_warn("Too many connections from %s for service %s", + state->addr, service); + break; + } + if (var_smtpd_crate_limit > 0 && crate > var_smtpd_crate_limit) { + smtpd_chat_reply(state, "450 Too many connections from %s", + state->addr); + msg_warn("Too frequent connections from %s for service %s", + state->addr, service); + break; + } + } if (SMTPD_STAND_ALONE(state) == 0 && var_smtpd_delay_reject == 0 && (state->access_denied = smtpd_check_client(state)) != 0) { @@ -1865,6 +1913,8 @@ static void smtpd_proto(SMTPD_STATE *state) } break; } + if (crate_clnt) + crate_clnt_disconnect(crate_clnt, service, state->addr); /* * Log abnormal session termination, in case postmaster notification has @@ -1894,7 +1944,7 @@ static void smtpd_proto(SMTPD_STATE *state) /* smtpd_service - service one client */ -static void smtpd_service(VSTREAM *stream, char *unused_service, char **argv) +static void smtpd_service(VSTREAM *stream, char *service, char **argv) { SMTPD_STATE state; @@ -1924,7 +1974,7 @@ static void smtpd_service(VSTREAM *stream, char *unused_service, char **argv) /* * Provide the SMTP service. */ - smtpd_proto(&state); + smtpd_proto(&state, service); /* * After the client has gone away, clean up whatever we have set up at @@ -1960,6 +2010,7 @@ static void pre_jail_init(char *unused_name, char **unused_argv) verp_clients = namadr_list_init(MATCH_FLAG_NONE, var_verp_clients); xaddr_clients = namadr_list_init(MATCH_FLAG_NONE, var_xaddr_clients); xloginfo_clients = namadr_list_init(MATCH_FLAG_NONE, var_xloginfo_clients); + hogger_list = namadr_list_init(MATCH_FLAG_NONE, var_smtpd_hoggers); if (getuid() == 0 || getuid() == var_owner_uid) smtpd_check_init(); debug_peer_init(); @@ -1988,7 +2039,7 @@ static void post_jail_init(char *unused_name, char **unused_argv) * recipient checks, address mapping, header_body_checks?. */ smtpd_input_transp_mask = - input_transp_mask(VAR_INPUT_TRANSP, var_input_transp); + input_transp_mask(VAR_INPUT_TRANSP, var_input_transp); /* * Sanity checks. The queue_minfree value should be at least as large as @@ -1999,8 +2050,14 @@ static void post_jail_init(char *unused_name, char **unused_argv) && var_message_limit > 0 && var_queue_minfree / 2 < var_message_limit) msg_warn("%s(%lu) should be at least 2*%s(%lu)", - VAR_QUEUE_MINFREE, (unsigned long) var_queue_minfree, - VAR_MESSAGE_LIMIT, (unsigned long) var_message_limit); + VAR_QUEUE_MINFREE, (unsigned long) var_queue_minfree, + VAR_MESSAGE_LIMIT, (unsigned long) var_message_limit); + + /* + * Connection rate management. + */ + if (var_smtpd_crate_limit || var_smtpd_cconn_limit) + crate_clnt = crate_clnt_create(); } /* main - the main program */ @@ -2032,6 +2089,8 @@ int main(int argc, char **argv) VAR_VIRT_MAILBOX_CODE, DEF_VIRT_MAILBOX_CODE, &var_virt_mailbox_code, 0, 0, VAR_RELAY_RCPT_CODE, DEF_RELAY_RCPT_CODE, &var_relay_rcpt_code, 0, 0, VAR_VERIFY_POLL_COUNT, DEF_VERIFY_POLL_COUNT, &var_verify_poll_count, 1, 0, + VAR_SMTPD_CRATE_LIMIT, DEF_SMTPD_CRATE_LIMIT, &var_smtpd_crate_limit, 0, 0, + VAR_SMTPD_CCONN_LIMIT, DEF_SMTPD_CCONN_LIMIT, &var_smtpd_cconn_limit, 0, 0, 0, }; static CONFIG_TIME_TABLE time_table[] = { @@ -2090,6 +2149,7 @@ int main(int argc, char **argv) VAR_INPUT_TRANSP, DEF_INPUT_TRANSP, &var_input_transp, 0, 0, VAR_XADDR_CLIENTS, DEF_XADDR_CLIENTS, &var_xaddr_clients, 0, 0, VAR_XLOGINFO_CLIENTS, DEF_XLOGINFO_CLIENTS, &var_xloginfo_clients, 0, 0, + VAR_SMTPD_HOGGERS, DEF_SMTPD_HOGGERS, &var_smtpd_hoggers, 0, 0, 0, }; static CONFIG_RAW_TABLE raw_table[] = { diff --git a/postfix/src/smtpd/smtpd_check.c b/postfix/src/smtpd/smtpd_check.c index 9b583e129..da755fc8e 100644 --- a/postfix/src/smtpd/smtpd_check.c +++ b/postfix/src/smtpd/smtpd_check.c @@ -3799,7 +3799,6 @@ char *smtpd_check_size(SMTPD_STATE *state, off_t size) "552 Message size exceeds fixed limit"); return (STR(error_text)); } - fsspace(".", &fsbuf); if (msg_verbose) msg_info("%s: blocks %lu avail %lu min_free %lu msg_size_limit %lu", diff --git a/postfix/src/smtpstone/smtp-sink.c b/postfix/src/smtpstone/smtp-sink.c index 035e66467..4b088a8b7 100644 --- a/postfix/src/smtpstone/smtp-sink.c +++ b/postfix/src/smtpstone/smtp-sink.c @@ -12,8 +12,9 @@ /* DESCRIPTION /* \fIsmtp-sink\fR listens on the named host (or address) and port. /* It takes SMTP messages from the network and throws them away. -/* The purpose is to measure SMTP client performance, not protocol +/* The purpose is to measure client performance, not protocol /* compliance. +/* /* Connections can be accepted on IPV4 endpoints or UNIX-domain sockets. /* IPV4 is the default. /* This program is the complement of the \fIsmtp-source\fR program. @@ -25,18 +26,18 @@ /* Display a running counter that is updated whenever an SMTP /* QUIT command is executed. /* .IP \fB-e\fR -/* Disable ESMTP support. +/* Do not announce ESMTP support. /* .IP "\fB-f \fIcommand,command,...\fR" /* Reject the specified commands with a hard (5xx) error code. /* .IP \fB-h\fI hostname\fR /* Use \fIhostname\fR in the SMTP greeting, in the HELO response, /* and in the EHLO response. The default hostname is "smtp-sink". /* .IP \fB-L\fR -/* Enable LMTP rather than SMTP. +/* Enable LMTP instead of SMTP. /* .IP "\fB-n \fIcount\fR" /* Terminate after \fIcount\fR sessions. This is for testing purposes. /* .IP \fB-p\fR -/* Disable ESMTP command pipelining. +/* Do not announce support for ESMTP command pipelining. /* .IP \fB-P\fR /* Change the server greeting so that it appears to come through /* a CISCO PIX system. Implies \fB-e\fR. @@ -53,7 +54,7 @@ /* .IP "\fB-w \fIdelay\fR" /* Wait \fIdelay\fR seconds before responding to a DATA command. /* .IP \fB-8\fR -/* Disable 8BITMIME support. +/* Do not announce 8BITMIME support. /* .IP [\fBinet:\fR][\fIhost\fR]:\fIport\fR /* Listen on network interface \fIhost\fR (default: any interface) /* TCP port \fIport\fR. Both \fIhost\fR and \fIport\fR may be diff --git a/postfix/src/spawn/Makefile.in b/postfix/src/spawn/Makefile.in index 95fcb3e31..1b104bb5c 100644 --- a/postfix/src/spawn/Makefile.in +++ b/postfix/src/spawn/Makefile.in @@ -68,5 +68,8 @@ spawn.o: ../../include/split_at.h spawn.o: ../../include/timed_wait.h spawn.o: ../../include/set_eugid.h spawn.o: ../../include/mail_params.h +spawn.o: ../../include/crate_clnt.h +spawn.o: ../../include/attr_clnt.h +spawn.o: ../../include/attr.h spawn.o: ../../include/mail_server.h spawn.o: ../../include/mail_conf.h diff --git a/postfix/src/trivial-rewrite/Makefile.in b/postfix/src/trivial-rewrite/Makefile.in index 556aaf047..fd5725703 100644 --- a/postfix/src/trivial-rewrite/Makefile.in +++ b/postfix/src/trivial-rewrite/Makefile.in @@ -73,9 +73,11 @@ resolve.o: ../../include/valid_hostname.h resolve.o: ../../include/stringops.h resolve.o: ../../include/mymalloc.h resolve.o: ../../include/mail_params.h +resolve.o: ../../include/crate_clnt.h +resolve.o: ../../include/attr_clnt.h +resolve.o: ../../include/attr.h resolve.o: ../../include/mail_proto.h resolve.o: ../../include/iostuff.h -resolve.o: ../../include/attr.h resolve.o: ../../include/rewrite_clnt.h resolve.o: ../../include/resolve_local.h resolve.o: ../../include/mail_conf.h @@ -103,9 +105,11 @@ rewrite.o: ../../include/vstream.h rewrite.o: ../../include/vstring_vstream.h rewrite.o: ../../include/split_at.h rewrite.o: ../../include/mail_params.h +rewrite.o: ../../include/crate_clnt.h +rewrite.o: ../../include/attr_clnt.h +rewrite.o: ../../include/attr.h rewrite.o: ../../include/mail_proto.h rewrite.o: ../../include/iostuff.h -rewrite.o: ../../include/attr.h rewrite.o: ../../include/resolve_local.h rewrite.o: ../../include/tok822.h rewrite.o: ../../include/resolve_clnt.h @@ -124,12 +128,14 @@ transport.o: ../../include/vstream.h transport.o: ../../include/argv.h transport.o: ../../include/strip_addr.h transport.o: ../../include/mail_params.h +transport.o: ../../include/crate_clnt.h +transport.o: ../../include/attr_clnt.h +transport.o: ../../include/attr.h transport.o: ../../include/maps.h transport.o: ../../include/match_parent_style.h transport.o: ../../include/match_ops.h transport.o: ../../include/mail_proto.h transport.o: ../../include/iostuff.h -transport.o: ../../include/attr.h transport.o: transport.h trivial-rewrite.o: trivial-rewrite.c trivial-rewrite.o: ../../include/sys_defs.h @@ -143,9 +149,11 @@ trivial-rewrite.o: ../../include/stringops.h trivial-rewrite.o: ../../include/dict.h trivial-rewrite.o: ../../include/argv.h trivial-rewrite.o: ../../include/mail_params.h +trivial-rewrite.o: ../../include/crate_clnt.h +trivial-rewrite.o: ../../include/attr_clnt.h +trivial-rewrite.o: ../../include/attr.h trivial-rewrite.o: ../../include/mail_proto.h trivial-rewrite.o: ../../include/iostuff.h -trivial-rewrite.o: ../../include/attr.h trivial-rewrite.o: ../../include/resolve_local.h trivial-rewrite.o: ../../include/mail_conf.h trivial-rewrite.o: ../../include/resolve_clnt.h diff --git a/postfix/src/util/attr_clnt.c b/postfix/src/util/attr_clnt.c index 5b5eea328..eabf01537 100644 --- a/postfix/src/util/attr_clnt.c +++ b/postfix/src/util/attr_clnt.c @@ -6,6 +6,9 @@ /* SYNOPSIS /* #include /* +/* typedef int (*ATTR_CLNT_PRINT_FN) (VSTREAM *, int, va_list); +/* typedef int (*ATTR_CLNT_SCAN_FN) (VSTREAM *, int, va_list); +/* /* ATTR_CLNT *attr_clnt_create(server, timeout, max_idle, max_ttl) /* const char *server; /* int timeout; @@ -25,17 +28,23 @@ /* /* void attr_clnt_free(client) /* ATTR_CLNT *client; +/* +/* void attr_clnt_control(client, name, value, ... ATTR_CLNT_CTL_END) +/* ATTR_CLNT *client; +/* int name; /* DESCRIPTION /* This module implements a client for a simple attribute-based -/* protocol as described in attr_scan_plain(3). +/* protocol. The default protocol is described in attr_scan_plain(3). /* /* attr_clnt_create() creates a client handle. The server /* argument specifies "transport:servername" where transport is /* currently limited to "inet" or "unix", and servername has the /* form "host:port", "private/servicename" or "public/servicename". /* The timeout parameter limits the time for sending or receiving -/* a reply, and the ttl parameter controls how long an unused -/* connection is kept open. +/* a reply, max_idle specifies how long an idle connection is +/* kept open, and the max_ttl parameter bounds the time that a +/* connection is kept open. +/* Specify zero to disable a max_idle or max_ttl limit. /* /* attr_clnt_request() sends the specified request attributes and /* receives a reply. The reply argument specifies a name-value table. @@ -43,6 +52,15 @@ /* result is the number of attributes received or -1 in case of trouble. /* /* attr_clnt_free() destroys a client handle and closes its connection. +/* +/* attr_clnt_control() allows the user to fine tune the behavior of +/* the specified client. The arguments are a list of (name, value) +/* terminated with ATTR_CLNT_CTL_END. +/* The following lists the names and the types of the corresponding +/* value arguments. +/* .IP "ATTR_CLNT_CTL_PROTO(ATTR_CLNT_PRINT_FN, ATTR_CLNT_SCAN_FN)" +/* Specifies alternatives for the attr_plain_print() and +/* attr_plain_scan() functions. /* DIAGNOSTICS /* Warnings: communication failure. /* SEE ALSO @@ -86,8 +104,8 @@ struct ATTR_CLNT { int (*connect) (const char *, int, int); char *endpoint; int timeout; - int (*print) (VSTREAM *, int, va_list); - int (*scan) (VSTREAM *, int, va_list); + ATTR_CLNT_PRINT_FN print; + ATTR_CLNT_SCAN_FN scan; }; /* attr_clnt_connect - connect to server */ @@ -99,7 +117,7 @@ static VSTREAM *attr_clnt_connect(void *context) VSTREAM *fp; int fd; - fd = client->connect(client->endpoint, NON_BLOCKING, client->timeout); + fd = client->connect(client->endpoint, BLOCKING, client->timeout); if (fd < 0) { msg_warn("connect to %s: %m", client->endpoint); return (0); @@ -146,6 +164,8 @@ ATTR_CLNT *attr_clnt_create(const char *service, int timeout, client->timeout = timeout; if (strcmp(transport, "inet") == 0) { client->connect = inet_connect; + } else if (strcmp(transport, "local") == 0) { + client->connect = LOCAL_CONNECT; } else if (strcmp(transport, "unix") == 0) { client->connect = unix_connect; } else { @@ -183,6 +203,7 @@ int attr_clnt_request(ATTR_CLNT *client, int send_flags,...) } for (;;) { + errno = 0; if ((stream = auto_clnt_access(client->auto_clnt)) != 0 && readable(vstream_fileno(stream)) == 0) { errno = 0; @@ -220,7 +241,7 @@ int attr_clnt_request(ATTR_CLNT *client, int send_flags,...) } if (++count >= 2 || msg_verbose - || (errno != EPIPE && errno != ENOENT && errno != ECONNRESET)) + || (errno && errno != EPIPE && errno != ENOENT && errno != ECONNRESET)) msg_warn("problem talking to server %s: %m", client->endpoint); if (count >= 2) return (-1); @@ -228,3 +249,22 @@ int attr_clnt_request(ATTR_CLNT *client, int send_flags,...) auto_clnt_recover(client->auto_clnt); } } + +/* attr_clnt_control - fine control */ + +void attr_clnt_control(ATTR_CLNT *client, int name,...) +{ + char *myname = "attr_clnt_control"; + va_list ap; + + for (va_start(ap, name); name != ATTR_CLNT_CTL_END; name = va_arg(ap, int)) { + switch (name) { + case ATTR_CLNT_CTL_PROTO: + client->print = va_arg(ap, ATTR_CLNT_PRINT_FN); + client->scan = va_arg(ap, ATTR_CLNT_SCAN_FN); + break; + default: + msg_panic("%s: bad name %d", myname, name); + } + } +} diff --git a/postfix/src/util/attr_clnt.h b/postfix/src/util/attr_clnt.h index 9edb796fd..5660f1840 100644 --- a/postfix/src/util/attr_clnt.h +++ b/postfix/src/util/attr_clnt.h @@ -20,10 +20,16 @@ * External interface. */ typedef struct ATTR_CLNT ATTR_CLNT; +typedef int (*ATTR_CLNT_PRINT_FN) (VSTREAM *, int, va_list); +typedef int (*ATTR_CLNT_SCAN_FN) (VSTREAM *, int, va_list); extern ATTR_CLNT *attr_clnt_create(const char *, int, int, int); extern int attr_clnt_request(ATTR_CLNT *, int,...); extern void attr_clnt_free(ATTR_CLNT *); +extern void attr_clnt_control(ATTR_CLNT *, int, ...); + +#define ATTR_CLNT_CTL_END 0 +#define ATTR_CLNT_CTL_PROTO 1 /* LICENSE /* .ad diff --git a/postfix/src/util/auto_clnt.c b/postfix/src/util/auto_clnt.c index 093d0a95e..e78ec1946 100644 --- a/postfix/src/util/auto_clnt.c +++ b/postfix/src/util/auto_clnt.c @@ -39,9 +39,11 @@ /* /* Arguments: /* .IP max_idle -/* Idle time after which the client disconnects. +/* Idle time after which the client disconnects. Specify 0 to disable +/* the limit. /* .IP max_ttl /* Upper bound on the time that a connection is allowed to persist. +/* Specify 0 to disable the limit. /* .IP open_action /* Application call-back routine that opens a stream or returns a /* null pointer upon failure. In case of success, the call-back routine @@ -153,10 +155,12 @@ static void auto_clnt_open(AUTO_CLNT *auto_clnt) close_on_exec(vstream_fileno(auto_clnt->vstream), CLOSE_ON_EXEC); event_enable_read(vstream_fileno(auto_clnt->vstream), auto_clnt_event, (char *) auto_clnt); - event_request_timer(auto_clnt_event, (char *) auto_clnt, - auto_clnt->max_idle); - event_request_timer(auto_clnt_ttl_event, (char *) auto_clnt, - auto_clnt->max_ttl); + if (auto_clnt->max_idle > 0) + event_request_timer(auto_clnt_event, (char *) auto_clnt, + auto_clnt->max_idle); + if (auto_clnt->max_ttl > 0) + event_request_timer(auto_clnt_ttl_event, (char *) auto_clnt, + auto_clnt->max_ttl); } } diff --git a/postfix/src/util/dict_cidr.c b/postfix/src/util/dict_cidr.c index 5813107f6..a5f931714 100644 --- a/postfix/src/util/dict_cidr.c +++ b/postfix/src/util/dict_cidr.c @@ -154,15 +154,20 @@ static DICT_CIDR_ENTRY *dict_cidr_parse_rule(const char *mapname, int lineno, /* * Parse the key into network and mask, and destroy the key. Treat a bare * network address as /32. + * + * We need explicit code for /0. The result of << is undefined when the + * shift is greater or equal to the number of bits in the shifted + * operand. */ if ((mask = split_at(key, '/')) != 0) { - if ((mask_shift = atoi(mask)) <= 0 || mask_shift > BITS_PER_ADDR + if (!alldig(mask) || (mask_shift = atoi(mask)) > BITS_PER_ADDR || (net_bits = inet_addr(key)) == INADDR_NONE) { msg_warn("cidr map %s, line %d: bad net/mask pattern: \"%s/%s\": " "skipping this rule", mapname, lineno, key, mask); return (0); } - mask_bits = htonl((0xffffffff) << (BITS_PER_ADDR - mask_shift)); + mask_bits = mask_shift > 0 ? + htonl((0xffffffff) << (BITS_PER_ADDR - mask_shift)) : 0; if (net_bits & ~mask_bits) { net_addr.s_addr = (net_bits & mask_bits); msg_warn("cidr map %s, line %d: net/mask pattern \"%s/%s\" with " diff --git a/postfix/src/util/match_ops.c b/postfix/src/util/match_ops.c index 5d9e6a5d2..fd77937a3 100644 --- a/postfix/src/util/match_ops.c +++ b/postfix/src/util/match_ops.c @@ -180,7 +180,7 @@ int match_hostname(int flags, const char *name, const char *pattern) /* match_parse_mask - parse net/mask pattern */ static int match_parse_mask(const char *pattern, unsigned long *net_bits, - int *mask_shift) + unsigned int *mask_shift) { char *saved_pattern; char *mask; @@ -189,7 +189,7 @@ static int match_parse_mask(const char *pattern, unsigned long *net_bits, saved_pattern = mystrdup(pattern); if ((mask = split_at(saved_pattern, '/')) != 0) { - if ((*mask_shift = atoi(mask)) <= 0 || *mask_shift > BITS_PER_ADDR + if (!alldig(mask) || (*mask_shift = atoi(mask)) > BITS_PER_ADDR || (*net_bits = inet_addr(saved_pattern)) == INADDR_NONE) { msg_fatal("bad net/mask pattern: %s", pattern); } @@ -203,7 +203,7 @@ static int match_parse_mask(const char *pattern, unsigned long *net_bits, int match_hostaddr(int unused_flags, const char *addr, const char *pattern) { char *myname = "match_hostaddr"; - int mask_shift; + unsigned int mask_shift; unsigned long mask_bits; unsigned long net_bits; unsigned long addr_bits; @@ -242,7 +242,8 @@ int match_hostaddr(int unused_flags, const char *addr, const char *pattern) addr_bits = inet_addr(addr); if (addr_bits == INADDR_NONE) msg_fatal("%s: bad address argument: %s", myname, addr); - mask_bits = htonl((0xffffffff) << (BITS_PER_ADDR - mask_shift)); + mask_bits = mask_shift > 0 ? + htonl((0xffffffff) << (BITS_PER_ADDR - mask_shift)) : 0; if ((addr_bits & mask_bits) == net_bits) return (1); if (net_bits & ~mask_bits) { diff --git a/postfix/src/util/sys_defs.h b/postfix/src/util/sys_defs.h index db080b1eb..4ea98c931 100644 --- a/postfix/src/util/sys_defs.h +++ b/postfix/src/util/sys_defs.h @@ -98,7 +98,9 @@ #define NORETURN void #define PRINTFLIKE(x,y) #define SCANFLIKE(x,y) +#ifndef NO_NETINFO #define HAS_NETINFO +#endif #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" #define NATIVE_MAILQ_PATH "/usr/bin/mailq" #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" diff --git a/postfix/src/verify/Makefile.in b/postfix/src/verify/Makefile.in index 169affba0..4ceb30f6d 100644 --- a/postfix/src/verify/Makefile.in +++ b/postfix/src/verify/Makefile.in @@ -68,9 +68,11 @@ verify.o: ../../include/argv.h verify.o: ../../include/split_at.h verify.o: ../../include/mail_conf.h verify.o: ../../include/mail_params.h +verify.o: ../../include/crate_clnt.h +verify.o: ../../include/attr_clnt.h +verify.o: ../../include/attr.h verify.o: ../../include/mail_proto.h verify.o: ../../include/iostuff.h -verify.o: ../../include/attr.h verify.o: ../../include/post_mail.h verify.o: ../../include/cleanup_user.h verify.o: ../../include/verify_clnt.h diff --git a/postfix/src/virtual/Makefile.in b/postfix/src/virtual/Makefile.in index 7ab030855..8b69c723c 100644 --- a/postfix/src/virtual/Makefile.in +++ b/postfix/src/virtual/Makefile.in @@ -87,6 +87,9 @@ mailbox.o: ../../include/deliver_request.h mailbox.o: ../../include/recipient_list.h mailbox.o: ../../include/sent.h mailbox.o: ../../include/mail_params.h +mailbox.o: ../../include/crate_clnt.h +mailbox.o: ../../include/attr_clnt.h +mailbox.o: ../../include/attr.h mailbox.o: ../../include/mail_addr_find.h mailbox.o: ../../include/maps.h mailbox.o: ../../include/dict.h @@ -112,6 +115,9 @@ maildir.o: ../../include/recipient_list.h maildir.o: ../../include/defer.h maildir.o: ../../include/sent.h maildir.o: ../../include/mail_params.h +maildir.o: ../../include/crate_clnt.h +maildir.o: ../../include/attr_clnt.h +maildir.o: ../../include/attr.h maildir.o: virtual.h maildir.o: ../../include/maps.h maildir.o: ../../include/dict.h @@ -162,6 +168,9 @@ virtual.o: ../../include/recipient_list.h virtual.o: ../../include/deliver_request.h virtual.o: ../../include/deliver_completed.h virtual.o: ../../include/mail_params.h +virtual.o: ../../include/crate_clnt.h +virtual.o: ../../include/attr_clnt.h +virtual.o: ../../include/attr.h virtual.o: ../../include/mail_conf.h virtual.o: ../../include/mail_addr_find.h virtual.o: ../../include/maps.h