]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.0.16-20031110
authorWietse Venema <wietse@porcupine.org>
Mon, 10 Nov 2003 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:29:11 +0000 (06:29 +0000)
77 files changed:
postfix/.indent.pro
postfix/HISTORY
postfix/Makefile.in
postfix/README_FILES/SASL_README
postfix/README_FILES/SMTPD_POLICY_README
postfix/RELEASE_NOTES
postfix/conf/cidr_table
postfix/conf/master.cf
postfix/conf/post-install
postfix/conf/postfix-files
postfix/conf/postfix-script
postfix/conf/sample-smtpd.cf
postfix/examples/smtpd-policy/smtpd-policy.pl
postfix/html/Makefile.in
postfix/html/cidr_table.5.html
postfix/html/crate.8.html [new file with mode: 0644]
postfix/html/smtpd.8.html
postfix/makedefs
postfix/man/Makefile.in
postfix/man/man1/smtp-sink.1
postfix/man/man5/cidr_table.5
postfix/man/man8/crate.8 [new file with mode: 0644]
postfix/man/man8/smtpd.8
postfix/proto/cidr_table
postfix/src/bounce/Makefile.in
postfix/src/cleanup/Makefile.in
postfix/src/crate/.indent.pro [new symlink]
postfix/src/crate/.printfck [new file with mode: 0644]
postfix/src/crate/Makefile.in [new file with mode: 0644]
postfix/src/crate/crate.c [new file with mode: 0644]
postfix/src/flush/Makefile.in
postfix/src/global/Makefile.in
postfix/src/global/crate_clnt.c [new file with mode: 0644]
postfix/src/global/crate_clnt.h [new file with mode: 0644]
postfix/src/global/mail_params.c
postfix/src/global/mail_params.h
postfix/src/global/mail_version.h
postfix/src/lmtp/Makefile.in
postfix/src/local/Makefile.in
postfix/src/local/alias.c
postfix/src/master/Makefile.in
postfix/src/master/mail_server.h
postfix/src/master/multi_server.c
postfix/src/nqmgr/Makefile.in
postfix/src/pickup/Makefile.in
postfix/src/pipe/Makefile.in
postfix/src/postalias/Makefile.in
postfix/src/postcat/Makefile.in
postfix/src/postconf/Makefile.in
postfix/src/postdrop/Makefile.in
postfix/src/postfix/Makefile.in
postfix/src/postkick/Makefile.in
postfix/src/postlock/Makefile.in
postfix/src/postlog/Makefile.in
postfix/src/postmap/Makefile.in
postfix/src/postqueue/Makefile.in
postfix/src/postsuper/Makefile.in
postfix/src/proxymap/Makefile.in
postfix/src/qmgr/Makefile.in
postfix/src/qmqpd/Makefile.in
postfix/src/sendmail/Makefile.in
postfix/src/showq/Makefile.in
postfix/src/smtp/Makefile.in
postfix/src/smtpd/Makefile.in
postfix/src/smtpd/smtpd.c
postfix/src/smtpd/smtpd_check.c
postfix/src/smtpstone/smtp-sink.c
postfix/src/spawn/Makefile.in
postfix/src/trivial-rewrite/Makefile.in
postfix/src/util/attr_clnt.c
postfix/src/util/attr_clnt.h
postfix/src/util/auto_clnt.c
postfix/src/util/dict_cidr.c
postfix/src/util/match_ops.c
postfix/src/util/sys_defs.h
postfix/src/verify/Makefile.in
postfix/src/virtual/Makefile.in

index d092777b46d25a2f271401a2f3b8b7a6c37211b7..8bc9dc097a6f306bf775e2e7e47bc9b3edba3368 100644 (file)
@@ -23,6 +23,8 @@
 -TCONFIG_STR_TABLE
 -TCONFIG_TIME_FN_TABLE
 -TCONFIG_TIME_TABLE
+-TCRATE_LOCAL
+-TCRATE_REMOTE
 -TCTABLE
 -TCTABLE_ENTRY
 -TDELIVER_ATTR
index 01b76454285a205d8f08888791c6cb18b85e8198..721301967185fa1e9298dba29179ad95a9d882c6 100644 (file)
@@ -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
index ddb60c483c6fad78d696f19adc283a898f1129fe..7565c53557dd3f53fe6426db987be18bf10b9719 100644 (file)
@@ -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
index b2b6aa9a492e4ee470e2a20fa1a1aa4d35c4e8e9..a31496690b1cef0a35ce58a59c14a324b740536f 100644 (file)
@@ -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:
 
index 8275acb6a931158006039da40af014324da0b871..172243ec5cfd8975c1ec7f23d47acae0cec46017 100644 (file)
@@ -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();
 
index aa14f09d0e3f382f2858076a6a20b7ad88cea243..4ac31a4d58ee28f4fae2763b3b3c9f5efec5ef0e 100644 (file)
@@ -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
 ==========================================================
 
index b2bbbaa11f9168f470794f093279a11232becf6d..2f3e55798c7bc471e585a7ddd3f837b5209f92cf 100644 (file)
 # 
 #        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
index c3b46d85ab6e2b5827acd02787a91cfaae3284c6..501d0aaa9957d6409bcd12f7911032ca585d88aa 100644 (file)
@@ -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.
index 7c46000dc1062a45f82e26ec305e02137f3e16b5..87536f0d5830199b7980b043b57f584ee2542366 100644 (file)
@@ -572,6 +572,15 @@ EOF
        echo Editing $config_directory/master.cf, adding missing entry for proxymap service
        cat >>$config_directory/master.cf <<EOF || exit 1
 proxymap  unix -       -       n       -       -       proxymap
+EOF
+    }
+
+    # Add missing crate service to master.cf.
+
+    grep '^crate.*crate' $config_directory/master.cf >/dev/null || {
+       echo Editing $config_directory/master.cf, adding missing entry for crate service
+       cat >>$config_directory/master.cf <<EOF || exit 1
+crate  unix    -       -       n       -       1       crate
 EOF
     }
 
index 75cade480b1171c148fde7be675d17f08c3e44a9..0bca2e18ca85fa116db98262167f2a47f922a113 100644 (file)
@@ -56,6 +56,7 @@ $queue_directory/pid:d:root:-:755:uc
 $queue_directory/trace:d:$mail_owner:-:700:ucr
 $daemon_directory/bounce:f:root:-:755
 $daemon_directory/cleanup:f:root:-:755
+$daemon_directory/crate:f:root:-:755
 $daemon_directory/error:f:root:-:755
 $daemon_directory/flush:f:root:-:755
 $daemon_directory/lmtp:f:root:-:755
@@ -132,6 +133,7 @@ $manpage_directory/man5/transport.5:f:root:-:644
 $manpage_directory/man5/virtual.5:f:root:-:644
 $manpage_directory/man8/bounce.8:f:root:-:644
 $manpage_directory/man8/cleanup.8:f:root:-:644
+$manpage_directory/man8/crate.8:f:root:-:644
 $manpage_directory/man8/defer.8:f:root:-:644
 $manpage_directory/man8/error.8:f:root:-:644
 $manpage_directory/man8/flush.8:f:root:-:644
index 36a02efa884968bc3ceb405266fcd0c8c04922b0..389d43d6208862cde7709ca3fdd57edbb5c9318f 100644 (file)
@@ -200,8 +200,10 @@ check)
        do
                test -d $dir && find $dir -type f -print | while read path
                do
-                       cmp -s $path /$path || 
-                           $WARN $queue_directory/$path and /$path differ
+                       test -e /$path && {
+                           cmp -s $path /$path || 
+                               $WARN $queue_directory/$path and /$path differ
+                       }
                done
        done
 
index eb501492fcbade217a21dd189d85b37fd1f8e044..29d7e208817407ae9a6e06d48bfb3a6d3da8e549 100644 (file)
@@ -103,6 +103,43 @@ unknown_local_recipient_reject_code = 550
 #
 #smtpd_sender_login_maps =
 
+#
+# Resource limits
+# 
+
+# The smtpd_client_connection_count_limit parameter controls how many
+# simultaneous connections any client is allowed to make to this
+# service.
+# 
+# By default, every client can make as many connections as Postfix
+# can accept (defined by the process limit in the master.cf file).
+# 
+# smtpd_client_connection_count_limit = 10
+smtpd_client_connection_count_limit = 0
+
+# The smtpd_client_connection_rate_limit parameter controls how many
+# connection attempts any client is allowed to make to this service
+# per time unit.
+# 
+# The time unit is specified with the connection_rate_time_unit
+# configuration parameter, and defaults to one minute.
+# 
+# By default, every client can make as many connections as Postfix
+# can accept.
+#
+# smtpd_client_connection_rate_limit = 100
+smtpd_client_connection_rate_limit = 0
+
+# The smtpd_client_connection_limit_exceptions parameter controls what
+# clients are excluded from connection count or connection rate
+# restrictions.
+# 
+# By default, clients in trusted networks are excluded. Specify a
+# list of network blocks, hostnames or .domain names (the initial
+# initial dot causes the domain to match any name below it).
+# 
+smtpd_client_connection_limit_exceptions = $mynetworks
+
 #
 # MISCELLANEOUS
 #
@@ -123,7 +160,8 @@ unknown_local_recipient_reject_code = 550
 #
 # Specify an explicit list of network/netmask patterns, where the
 # mask specifies the number of bits in the network part of a host
-# address.
+# address. You can also specify hostnames or .domain names (the
+# initial dot causes the domain to match any name below it).
 #
 # You can also specify the absolute pathname of a pattern file instead
 # of listing the patterns here. Specify type:table for table-based lookups
@@ -141,7 +179,8 @@ smtpd_authorized_xaddr_clients =
 #
 # Specify an explicit list of network/netmask patterns, where the
 # mask specifies the number of bits in the network part of a host
-# address.
+# address. You can also specify hostnames or .domain names (the
+# initial dot causes the domain to match any name below it).
 #
 # You can also specify the absolute pathname of a pattern file instead
 # of listing the patterns here. Specify type:table for table-based lookups
@@ -149,7 +188,7 @@ smtpd_authorized_xaddr_clients =
 #
 smtpd_authorized_xloginfo_clients =
 
-# The smtpd_authorized_xverp_clients parameter specifies what clients
+# The smtpd_authorized_verp_clients parameter specifies what clients
 # are allowed to specify the SMTP XVERP command. This command requests
 # that mail be delivered one recipient at a time with a per recipient
 # return address.
@@ -158,19 +197,21 @@ smtpd_authorized_xloginfo_clients =
 #
 # Specify an explicit list of network/netmask patterns, where the
 # mask specifies the number of bits in the network part of a host
-# address.
+# address. You can also specify hostnames or .domain names (the
+# initial dot causes the domain to match any name below it).
 #
 # You can also specify the absolute pathname of a pattern file instead
 # of listing the patterns here. Specify type:table for table-based lookups
 # (the value on the table right-hand side is not used).
 #
-smtpd_authorized_xverp_clients =
+smtpd_authorized_verp_clients =
 
 # The smtpd_banner parameter specifies the text that follows the 220
 # status code in the SMTP greeting banner. Some people like to see
 # the mail version advertised. By default, Postfix shows no version.
 #
-# You MUST specify the $myhostname at the start of the text.
+# You MUST specify $myhostname at the start of the text. This is
+# required by the SMTP protocol.
 #
 #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
 smtpd_banner = $myhostname ESMTP $mail_name
index de106cc00bbf7eb1e0b4a8e7f7f0ccb9d5ee2b22..f1666ff7928f81a4ef7313c68228627261ba5b37 100755 (executable)
@@ -94,6 +94,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();
 
index 7fcd4ff0a2f923c68d05ff9c6d0472c8bc732e1e..c87c6812122a143154739e10c428d51905bfa926 100644 (file)
@@ -6,7 +6,7 @@ DAEMONS =  bounce.8.html cleanup.8.html defer.8.html error.8.html local.8.html \
        lmtp.8.html master.8.html pickup.8.html pipe.8.html qmgr.8.html \
        showq.8.html smtp.8.html smtpd.8.html trivial-rewrite.8.html \
        nqmgr.8.html spawn.8.html flush.8.html virtual.8.html qmqpd.8.html \
-       trace.8.html verify.8.html proxymap.8.html
+       trace.8.html verify.8.html proxymap.8.html crate.8.html
 COMMANDS= mailq.1.html newaliases.1.html postalias.1.html postcat.1.html \
        postconf.1.html postfix.1.html postkick.1.html postlock.1.html \
        postlog.1.html postdrop.1.html postmap.1.html sendmail.1.html \
@@ -50,6 +50,10 @@ cleanup.8.html: ../src/cleanup/cleanup.c
        PATH=../mantools:$$PATH; \
        srctoman $? | $(AWK) | nroff -man | uniq | man2html | postlink >$@
 
+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 >$@
index c7cd673126a3042d2d347332af6cbaafdc515412..8fb59b8e8fa785f250b74ccbbc29d6d8ec5c2088 100644 (file)
@@ -1,4 +1,4 @@
-<html> <head> </head> <body> <pre>
+<html> <body> <pre>
 CIDR_TABLE(5)                                       CIDR_TABLE(5)
 
 <b>NAME</b>
@@ -24,27 +24,28 @@ CIDR_TABLE(5)                                       CIDR_TABLE(5)
 <b>TABLE FORMAT</b>
        The general form of a Postfix CIDR table is:
 
-       <i>network_address</i><b>/</b><i>network_mask     result</i>
+       <i>network</i><b>_</b><i>address</i><b>/</b><i>network</i><b>_</b><i>mask     result</i>
               When a search string matches the specified  network
-              block, use the corresponding <i>result</i> value.
+              block,  use the corresponding <i>result</i> value. Specify
+              0.0.0.0/0 to match every address.
 
-       <i>network_address     result</i>
-              When  a search string matches the specified network
+       <i>network</i><b>_</b><i>address     result</i>
+              When a search string matches the specified  network
               address, use the corresponding <i>result</i> 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.
 
 <b>SEARCH ORDER</b>
-       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.
 
 <b>EXAMPLE SMTPD ACCESS MAP</b>
diff --git a/postfix/html/crate.8.html b/postfix/html/crate.8.html
new file mode 100644 (file)
index 0000000..4eb1685
--- /dev/null
@@ -0,0 +1,106 @@
+<html> <body> <pre>
+CRATE(8)                                                 CRATE(8)
+
+<b>NAME</b>
+       crate - Postfix connection count and rate management
+
+<b>SYNOPSIS</b>
+       <b>crate</b> [generic Postfix daemon options]
+
+<b>DESCRIPTION</b>
+       The  Postfix  <b>crate</b> 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.
+
+<b>PROTOCOL</b>
+       When a connection is established, a  rate  limited  server
+       sends the following request to the <b>crate</b> server:
+
+           <b>request=connect</b>
+           <b>ident=</b><i>string</i>
+
+       This  registers a new connection for the remote client and
+       the rate limited service specified with <i>string</i>. The  <b>crate</b>
+       server answers with the number of simultaneous connections
+       and the number of connections per unit time for that (ser-
+       vice, client) combination:
+
+           <b>status=0</b>
+           <b>count=</b><i>number</i>
+           <b>rate=</b><i>number</i>
+
+       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 <b>crate</b> server:
+
+           <b>request=disconnect</b>
+           <b>ident=</b><i>string</i>
+
+       This  registers  a  disconnect event for the remote client
+       and the rate limited service specified  with  <i>string</i>.  The
+       rate limit management server replies with:
+
+           <b>status=0</b>
+
+<b>SECURITY</b>
+       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.
+
+<b>DIAGNOSTICS</b>
+       Problems and transactions are logged to <b>syslogd</b>(8).
+
+<b>BUGS</b>
+       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.
+
+<b>CONFIGURATION PARAMETERS</b>
+       The  following  <b>main.cf</b> parameters are especially relevant
+       to this program. Use the <b>postfix reload</b>  command  after  a
+       configuration change.
+
+       <b>connection_rate_purge_delay</b>
+              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.
+
+       <b>connection_rate_time_unit</b>
+              The unit of time over which  connection  rates  are
+              calculated.
+
+<b>SEE ALSO</b>
+       <a href="smtpd.8.html">smtpd(8)</a> Postfix SMTP server
+
+<b>LICENSE</b>
+       The  Secure  Mailer  license must be distributed with this
+       software.
+
+<b>AUTHOR(S)</b>
+       Wietse Venema
+       IBM T.J. Watson Research
+       P.O. Box 704
+       Yorktown Heights, NY 10598, USA
+
+                                                         CRATE(8)
+</pre> </body> </html>
index 8a615624fae7850e129b4f9691e102bff15c9c08..ff9a20737bae9605d3a50e89baa4ca59ab7f89b9 100644 (file)
@@ -301,6 +301,20 @@ SMTPD(8)                                                 SMTPD(8)
               receipt of RSET etc.  only if the number of history
               lines exceeds the given threshold.
 
+       <b>smtpd_client_connection_count_limit</b>
+              The maximal number of simultaneous connections that
+              any client is allowed to make to this service.
+
+       <b>smtpd_client_connection_rate_limit</b>
+              The maximal number of  connections  per  unit  time
+              (specified with <b>connection_rate_time_unit</b>) that any
+              client is allowed to make to this service.
+
+       <b>smtpd_client_connection_limit_exceptions</b>
+              Hostnames, .domain names or network address  blocks
+              of  clients that are excluded from connection count
+              or rate limits.
+
 <b>Tarpitting</b>
        <b>smtpd_error_sleep_time</b>
               Time to wait in seconds before sending a 4xx or 5xx
@@ -308,17 +322,17 @@ SMTPD(8)                                                 SMTPD(8)
 
        <b>smtpd_soft_error_limit</b>
               When an SMTP client has made this number of errors,
-              wait  <i>error</i><b>_</b><i>count</i>  seconds before responding to any
+              wait <i>error</i><b>_</b><i>count</i> seconds before responding  to  any
               client request.
 
        <b>smtpd_hard_error_limit</b>
-              Disconnect after a client has made this  number  of
+              Disconnect  after  a client has made this number of
               errors.
 
        <b>smtpd_junk_command_limit</b>
               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.
 
 <b>Delegated policy</b>
@@ -327,17 +341,17 @@ SMTPD(8)                                                 SMTPD(8)
               receiving from a delegated SMTPD policy server.
 
        <b>smtpd_policy_service_max_idle</b>
-              Time  after  which  an  unused SMTPD policy service
+              Time after which an  unused  SMTPD  policy  service
               connection is closed.
 
        <b>smtpd_policy_service_timeout</b>
-              Time after which an  active  SMTPD  policy  service
+              Time  after  which  an  active SMTPD policy service
               connection is closed.
 
 <b>UCE control restrictions</b>
        <b>parent_domain_matches_subdomains</b>
-              List  of  Postfix features that use <i>domain.tld</i> pat-
-              terns  to  match  <i>sub.domain.tld</i>  (as  opposed   to
+              List of Postfix features that use  <i>domain.tld</i>  pat-
+              terns   to  match  <i>sub.domain.tld</i>  (as  opposed  to
               requiring <i>.domain.tld</i> patterns).
 
        <b>smtpd_client_restrictions</b>
@@ -345,19 +359,19 @@ SMTPD(8)                                                 SMTPD(8)
               tem.
 
        <b>smtpd_helo_required</b>
-              Require that clients introduce  themselves  at  the
+              Require  that  clients  introduce themselves at the
               beginning of an SMTP session.
 
        <b>smtpd_helo_restrictions</b>
-              Restrict  what client hostnames are allowed in <b>HELO</b>
+              Restrict what client hostnames are allowed in  <b>HELO</b>
               and <b>EHLO</b> commands.
 
        <b>smtpd_sender_restrictions</b>
-              Restrict what sender addresses are allowed in  <b>MAIL</b>
+              Restrict  what sender addresses are allowed in <b>MAIL</b>
               <b>FROM</b> commands.
 
        <b>smtpd_recipient_restrictions</b>
-              Restrict  what  recipient  addresses are allowed in
+              Restrict what recipient addresses  are  allowed  in
               <b>RCPT TO</b> commands.
 
        <b>smtpd_etrn_restrictions</b>
@@ -365,96 +379,96 @@ SMTPD(8)                                                 SMTPD(8)
               mands, and what clients may issue <b>ETRN</b> commands.
 
        <b>smtpd_data_restrictions</b>
-              Restrictions  on  the  <b>DATA</b> command. Currently, the
-              only  restriction  that   makes   sense   here   is
+              Restrictions on the <b>DATA</b>  command.  Currently,  the
+              only   restriction   that   makes   sense  here  is
               <b>reject_unauth_pipelining</b>.
 
        <b>allow_untrusted_routing</b>
-              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.
 
        <b>smtpd_restriction_classes</b>
-              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.
 
        <b>smtpd_null_access_lookup_key</b>
-              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.
 
        <b>maps_rbl_domains</b> (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
               <b>reject_maps_rbl</b> restriction.
 
        <b>permit_mx_backup_networks</b>
-              Only  domains  whose  primary  MX  hosts  match the
-              listed  networks  are   eligible   for   the   <b>per-</b>
+              Only domains  whose  primary  MX  hosts  match  the
+              listed   networks   are   eligible   for  the  <b>per-</b>
               <b>mit_mx_backup</b> feature.
 
        <b>relay_domains</b>
-              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 <b>relay_transport</b> setting.
 
 <b>Sender/recipient address verification</b>
        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.
 
        <b>address_verify_poll_count</b>
-              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.
 
        <b>address_verify_poll_delay</b>
-              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.
 
 <b>UCE control responses</b>
        <b>access_map_reject_code</b>
-              Response  code  when  a  client  violates an access
+              Response code when  a  client  violates  an  access
               database restriction.
 
        <b>default_rbl_reply</b>
               Default template reply when a request is RBL black-
-              listed.   This template is used by the <b>reject_rbl_*</b>
-              and   <b>reject_rhsbl_*</b>   restrictions.   See    also:
+              listed.  This template is used by the  <b>reject_rbl_*</b>
+              and    <b>reject_rhsbl_*</b>   restrictions.   See   also:
               <b>rbl_reply_maps</b> and <b>smtpd_expansion_filter</b>.
 
        <b>defer_code</b>
-              Response  code when a client request is rejected by
+              Response code when a client request is rejected  by
               the <b>defer</b> restriction.
 
        <b>invalid_hostname_reject_code</b>
-              Response  code   when   a   client   violates   the
+              Response   code   when   a   client   violates  the
               <b>reject_invalid_hostname</b> restriction.
 
        <b>maps_rbl_reject_code</b>
               Response code when a request is RBL blacklisted.
 
        <b>multi_recipient_bounce_reject_code</b>
-              Response  code  when  a  multi-recipient  bounce is
+              Response code  when  a  multi-recipient  bounce  is
               blocked.
 
        <b>rbl_reply_maps</b>
-              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   <b>reject_rbl_*</b>   and
-              <b>reject_rhsbl_*</b>      restrictions.     See     also:
+              <b>reject_rhsbl_*</b>     restrictions.     See      also:
               <b>default_rbl_reply</b> and <b>smtpd_expansion_filter</b>.
 
        <b>reject_code</b>
-              Response code when  the  client  matches  a  <b>reject</b>
+              Response  code  when  the  client  matches a <b>reject</b>
               restriction.
 
        <b>relay_domains_reject_code</b>
@@ -462,7 +476,7 @@ SMTPD(8)                                                 SMTPD(8)
               mail relay policy.
 
        <b>unknown_address_reject_code</b>
-              Response  code   when   a   client   violates   the
+              Response   code   when   a   client   violates  the
               <b>reject_unknown_address</b> restriction.
 
        <b>unknown_client_reject_code</b>
@@ -471,15 +485,15 @@ SMTPD(8)                                                 SMTPD(8)
               tion.
 
        <b>unknown_hostname_reject_code</b>
-              Response   code   when   a   client   violates  the
+              Response  code   when   a   client   violates   the
               <b>reject_unknown_hostname</b> restriction.
 
        <b>unverified_sender_reject_code</b>
-              Response code when a sender address is known to  be
+              Response  code when a sender address is known to be
               undeliverable.
 
        <b>unverified_recipient_reject_code</b>
-              Response  code when a recipient address is known to
+              Response code when a recipient address is known  to
               be undeliverable.
 
 <b>SEE ALSO</b>
@@ -490,7 +504,7 @@ SMTPD(8)                                                 SMTPD(8)
        <a href="verify.8.html">verify(8)</a> address verification service
 
 <b>LICENSE</b>
-       The Secure Mailer license must be  distributed  with  this
+       The  Secure  Mailer  license must be distributed with this
        software.
 
 <b>AUTHOR(S)</b>
index 0531121f61334edbcdee546d27989f46764727fb..0827f00e3c2b8853c875c7af039c2bb1ea4c42bc 100644 (file)
@@ -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
                ;;
index 47656a23153120cebd818ce38c4b10c5e60f4300..1b6f33a24dc3ceecf4fdc6725bb9e93fa9a3cd64 100644 (file)
@@ -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 $? >$@
 
index 637ddc97e125b28a601103de238c8e9f2525b7ac..b4a53c51f64eee0908a4e53a81da906733bb0885 100644 (file)
@@ -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
index 645561c7c594f912b96752c4b2d4f938518e7d88..000cb1f2c7525588b686da295e7cf7fb772aa5f8 100644 (file)
@@ -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 (file)
index 0000000..0481e5d
--- /dev/null
@@ -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
index 585c8c36f430d2ee14c8abd0d2184f1a90c55fde..ecc3b9d2b6f2647bbf38152362104a3c312fad1d 100644 (file)
@@ -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
index 470e0a8b1fa4de9261b25b039856c3795ea92045..253ba3cafa060877bce8911f17a45de7df7cd42e 100644 (file)
@@ -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.
index 533eb0a73b4cd4a5b8e30b2741dae791c37ad07f..9cd99c3afc6eee3a2b0e79098da94ce0db438461 100644 (file)
@@ -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
index 8eb9a8807cacdd5d819242c72340829adc0ea90b..529f1d8883f3aaf19c971b1ce408ab167e43ef53 100644 (file)
@@ -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 (symlink)
index 0000000..5c837ec
--- /dev/null
@@ -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 (file)
index 0000000..66016ed
--- /dev/null
@@ -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 (file)
index 0000000..bb4eba4
--- /dev/null
@@ -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 (file)
index 0000000..496c79f
--- /dev/null
@@ -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 <sys_defs.h>
+#include <sys/time.h>
+#include <limits.h>
+
+/* Utility library. */
+
+#include <msg.h>
+#include <mymalloc.h>
+#include <htable.h>
+#include <binhash.h>
+#include <stringops.h>
+#include <events.h>
+
+/* Global library. */
+
+#include <mail_conf.h>
+#include <mail_params.h>
+#include <mail_proto.h>
+#include <crate_clnt.h>
+
+/* Server skeleton. */
+
+#include <mail_server.h>
+
+/* 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);
+}
index 266254d9103e2693d4a2df69490eb858d13ef157..f4291ab6ea09826f557c4a1401417bf876c83403 100644 (file)
@@ -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
index 4c3761634ed95ce4fef415c47700f69839f7d4f9..5751393973ba3e57abaa4b967c59207b380c7d97 100644 (file)
@@ -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 (file)
index 0000000..c46099f
--- /dev/null
@@ -0,0 +1,254 @@
+/*++
+/* NAME
+/*     crate_clnt 3
+/* SUMMARY
+/*     connection rate client interface
+/* SYNOPSIS
+/*     #include <crate_clnt.h>
+/*
+/*     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 <sys_defs.h>
+
+/* Utility library. */
+
+#include <mymalloc.h>
+#include <msg.h>
+#include <attr_clnt.h>
+#include <stringops.h>
+
+/* Global library. */
+
+#include <mail_proto.h>
+#include <mail_params.h>
+#include <crate_clnt.h>
+
+/* 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 <unistd.h>
+#include <string.h>
+#include <msg_vstream.h>
+#include <mail_conf.h>
+#include <mail_params.h>
+#include <vstring_vstream.h>
+
+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 (file)
index 0000000..bf2dee3
--- /dev/null
@@ -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 <crate_clnt.h>
+/* DESCRIPTION
+/* .nf
+
+ /*
+  * System library.
+  */
+#include <stdarg.h>
+
+ /*
+  * Utility library.
+  */
+#include <attr_clnt.h>
+
+ /*
+  * 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
index aa81791d088b19385363ea1713bf41d9a58973ec..ac43f9ecbcd13baee11c6c0ef896d28e2957eeb8 100644 (file)
@@ -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[] = {
index 81256e3363a335f37c66ef16ca5c58b31de95c31..59f3994b42940a35d9ba2963cd18e3359e107eab 100644 (file)
@@ -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 <crate_clnt.h>
+
+#define VAR_CRATE_SERVICE              "connection_rate_service"
+#define DEF_CRATE_SERVICE              "local:" CRATE_CLASS "/" CRATE_SERVICE
+extern char *var_crate_service;
+
 /* LICENSE
 /* .ad
 /* .fi
index 5c6b6ce10ac4ec114a609de1408b7a80c04d4cec..d9fd981648335544ec94151596403223899f6487 100644 (file)
@@ -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
index 4b86772e8ade2a21bf62f28eb8aa60b81cf1011c..f4780a39fe6a944f59898eb8ed79d2ab5a270b25 100644 (file)
@@ -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
index 038e81edcfddbf4d1ecebc1ef87594978051011f..e1eb4167ca02dcc5c831f52bcf24dd96fdba81a7 100644 (file)
@@ -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
index b4fa86859a6896a154327420b3b9b44c1888ba0d..ad8ebee7a1141eeb6af2b0f5abf715d4ce4f6da2 100644 (file)
@@ -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);
index eeb2ce986dd059f3690fd21ed27b83b768a68d0d..888541a769e3c39c18fbaf28b9de9d5217a10937 100644 (file)
@@ -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
index 068354d5d3d6e777c9183bfc3243d2047bad36d6..4800cbc324e6bd394eaef7f85c5f5b5b0c1dae0f 100644 (file)
@@ -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
index 5e2b487253562de7172f04eef1dec80899c99747..5b27eeff64a605dcf615112f4f9e8da33b5fceca 100644 (file)
 /*     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;
index c5f6254e7e1d24ee6136511944bb93ff7046a3ab..f3a1c84d6e05bc383b9b21d71f83145ba7e66753 100644 (file)
@@ -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
index 44847920d4f8d59279a91aead80aaf3f5f6d9d0e..03a18d11fbb85fc8e5625b0e43bb86e274d8fd49 100644 (file)
@@ -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
index 7f0c13f38e2d4b487269ed6448069d813aa45643..7ded12a6245578f6e1023738920275e3473db4bd 100644 (file)
@@ -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
index acb8e86b9823428541d13bd4a692645e678abac7..3449c6e8da50df7e24d7a2ffd5395f71bddc59b4 100644 (file)
@@ -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
index dca6108806e3c0a6c5375b0ea3290c5043d584f6..056161ed89a383a673dc626b1bf63613fd578eaf 100644 (file)
@@ -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
index 198be229e750908fff0cba8e4d6ff5ace7b3aa8a..3b47fc39228d8f56966e0ed420ce24fb887a5152 100644 (file)
@@ -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
index 846e70fde01f240b6dbe7fcb725cec664560f77e..e0c5172cc43a8fe77fd2dcfbb745d19778c9b529 100644 (file)
@@ -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
index bd1e8f5e30d5aba190f9121547a0ae71687d3985..3a2a86aee9c4e9669e677b2fe8e977fb58059a56 100644 (file)
@@ -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
index ce8b4a4858526b5735f72d03a3f9b9332bbfdda5..99e6b91c4863f70f446667335aa2ae2f153cee22 100644 (file)
@@ -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
index 3e95260c39cfea2cb5594272083dc2f851dfa4c1..c90227647606b300b2f2e589bf14e90522440502 100644 (file)
@@ -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
index 5feba3056cde5a95ec98dca5d6991008759ec1fc..8d7f5ca711f37e53f434676fbef0e47210bcdfe4 100644 (file)
@@ -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
index 5dbb4ccfe3b535485f180a3d1c1b003a04a5c9a8..04376b49c3bdc59e32fcbc49b151e3ae4404b102 100644 (file)
@@ -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
index 29ba1bff45b6a2f2a68abba2632564f09a24dd8a..c919f7da9bbd84682480368e52d10842f84aeaee 100644 (file)
@@ -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
index aacc1841a1b0c7c601ace6ea59f2d14cc1b17969..24884bc4f0747f89f01e0ab1ef8bdc5e44ee84a9 100644 (file)
@@ -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
index 91d20d8384fee5977819fb4a05cd1000e2d7df7d..40022668ea2a58875a6262da6d20b325f7ce6e4e 100644 (file)
@@ -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
index 06ead63742123b3f913d2f7b9d12e355f49d332f..a6d3dea23cc968155253f6a77e2e4111243436f9 100644 (file)
@@ -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
index 2ccd7d449914be0fc608ead27379b09f90208694..3af4be58e44e6e71fe51dace65cd58f8758a1e8a 100644 (file)
@@ -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
index 7fdaae2327ac2d221e28ab6e04efc81e51f40057..85f4bba0fba89fee3fe9d47b063a7d85954a175a 100644 (file)
@@ -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
index 2001e4df340b951ab4036cb77f45f12cd156e64e..4ceb0c058a1ae243303d8d419bc42cc4f8da37b9 100644 (file)
@@ -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
index d510098143accc873b0184cebb78d24d18753afd..0fb65aac0ac3c3155ea1862591e33e1d788471ab 100644 (file)
@@ -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
index b098fceb1229527d07ee94cff21104ed9311fe26..797c5805e02d2d93f30def1e193a6315d621113a 100644 (file)
@@ -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
index add76b4b678e562b1eb8922427dad25c865b5e29..a31f3953dc3570d3b4504ba426510d5dfb9d568c 100644 (file)
 /* .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
 #include <lex_822.h>
 #include <namadr_list.h>
 #include <input_transp.h>
+#include <crate_clnt.h>
 
 /* 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[] = {
index 9b583e1297741e78945291ece5870b81c8442cfe..da755fc8eeb43f7eb4bae9d6d5f232bfa7498ba7 100644 (file)
@@ -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",
index 035e6646789453f62cfef78a3e608f49348dd20a..4b088a8b7a866575ff2081ddbb58ff7da664ce5c 100644 (file)
@@ -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.
 /*     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
index 95fcb3e31251fae012846fe249cfd4a8a6aed9af..1b104bb5c14c9d1f209bed681abcb2c34ac86150 100644 (file)
@@ -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
index 556aaf047de2ceab5055f6a56491384d6b6468f1..fd5725703561ed3171c3bd658757e5ca9ba258f0 100644 (file)
@@ -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
index 5b5eea3288f6b36f182504787034e5960b7b7107..eabf015374f95be7f377d5f6356466bbc3d2a244 100644 (file)
@@ -6,6 +6,9 @@
 /* SYNOPSIS
 /*     #include <attr_clnt.h>
 /*
+/*     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;
 /*
 /*     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.
 /*     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);
+       }
+    }
+}
index 9edb796fdeb4673380b9477fe70f9938c42badb5..5660f1840ed04285dbda7cde78b5c3302bdd26df 100644 (file)
   * 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
index 093d0a95e501b84859906a859abfac06dd36ae65..e78ec1946d937318bb698d9be471311bf5c5cf34 100644 (file)
 /*
 /*     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);
     }
 }
 
index 5813107f6c9c4dee4a102c612d2661de680da3d4..a5f931714b37d84e53b7498aa2be199a1a70c86c 100644 (file)
@@ -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 "
index 5d9e6a5d249d85f0159e4348072b319c93d6f50f..fd77937a3d2e7a809e7077cf0d6bbe4b0bccd139 100644 (file)
@@ -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) {
index db080b1eb3f6a7c8b393c41e629ca7459fc0208e..4ea98c931e9e199431ce74b347b5e8415687dacd 100644 (file)
@@ -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"
index 169affba0d941c40ab169db07bbbcadf17624ea1..4ceb30f6d14320f3031d6bbf1db9adfa33d1d957 100644 (file)
@@ -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
index 7ab0308559461bbce19a1977cb85ab26ebc4831b..8b69c723c2edfc2b6b2356d1ad36dff22b9157eb 100644 (file)
@@ -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