]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.2-20040723
authorWietse Venema <wietse@porcupine.org>
Fri, 23 Jul 2004 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:29:48 +0000 (06:29 +0000)
23 files changed:
postfix/COMPATIBILITY
postfix/HISTORY
postfix/RELEASE_NOTES
postfix/html/postconf.5.html
postfix/html/scache.8.html
postfix/html/smtp.8.html
postfix/man/man5/postconf.5
postfix/man/man8/scache.8
postfix/man/man8/smtp.8
postfix/mantools/postlink
postfix/proto/postconf.proto
postfix/src/global/mail_params.h
postfix/src/global/mail_proto.h
postfix/src/global/mail_version.h
postfix/src/global/scache_clnt.c
postfix/src/scache/Makefile.in
postfix/src/scache/scache.c
postfix/src/smtp/smtp.c
postfix/src/smtp/smtp_connect.c
postfix/src/smtpd/smtpd.c
postfix/src/spawn/spawn.c
postfix/src/util/spawn_command.c
postfix/src/util/sys_defs.h

index 885f08608d2d4a30bdb5b4475d795ac08c6c639a..eb7a5eadf6a8475e89be80aff8e41c092636765f 100644 (file)
@@ -58,6 +58,7 @@ sendmail -qSxxx       no
 sendmail -qtime        ignored
 sendmail -v    yes (sends delivery report via email)
 sendmail.cf    no (uses table-driven address rewriting)
+session caching        yes (SMTP shared multi-session; LMTP non-shared single-session)
 size option    yes, server and client
 smarthost      yes (specify relayhost in main.cf)
 spf            yes (delegated policy script)
index 0b687def3e9c0545ce123912ce27d6094cd84bb8..4f0d372e26e6fac1c5447b9800edd52f1e7ca4c8 100644 (file)
@@ -9574,6 +9574,31 @@ Apologies for any names omitted.
        seconds (default: 600s), as well as upon process exit.
        File:  scache/scache.c.
 
+20040722
+
+       Workaround: LINUX 2.4 has trouble with mixed data and file
+       descriptor traffic on UNIX-domain stream sockets.
+       Specifically, it cannot handle data write (read) followed
+       by file descriptor send (receive): the receiver hangs in
+       recvmsg(). Workaround is to insert an intervening read
+       (write) operation.  Presumably, LINUX 2.4 is confusing the
+       data and file descriptor.  Lucky Ralf Hildebrandt.  Files:
+       util/sys_defs.h, global/scache_clnt,c, scache/scache.c.
+
+20040723
+
+       Bug? Safety? spawn(8) did not reject a user with the -1
+       UID value, so the command was running as root.  Files:
+       util/spawn_command.c, src/util/spawn.c.
+
+       User interface: parameter smtp_connection_cache_domains
+       renamed to smtp_connection_cache_destinations. Destinations
+       listed here must be specified without [] or :port.  File:
+       smtp/smtp_connect.c.
+
+       Bugfix: "421 Timeout exceeded" wasn't guarded by setjmp().
+       Victor Duchovni, Morgan Stanley. File: smtpd/smtpd.c.
+
 Open problems:
 
        Low: update events.c so that 1-second timer requests do
index ddbe6a1233f5e66ea66b389b6df753fb1badefba..0f8acd52cc17cf93aec753092c19d4ec0ca803a5 100644 (file)
@@ -7,13 +7,28 @@ snapshot release).  Patches are issued for the official release
 and change the patchlevel and the release date. Patches are never
 issued for snapshot releases.
 
+Incompatible changes with snapshot Postfix-2.2-20040723
+=======================================================
+
+Session caching is enabled with smtp_session_cache_destinations,
+and requires "bare" domain names without "[]" or TCP port.  This
+eliminates a syntax conflict between host:port and maptype:mapname,
+and simplifies the user interface, at the cost of a minor loss of
+control over what sessions are cached.
+
 Major changes with snapshot Postfix-2.2-20040721
 ================================================
 
 The session cache manager now logs cache hit and miss statistics
 every $session_cache_status_update_time seconds (default: 600s).
 It reports the hit and miss rates for lookups by domain, as well
-as for lookups by network address.
+as for lookups by network address. 
+
+Hit rates for cache lookups by domain will tell you how useful
+session caching is.
+
+Cache lookups by network address will always fail, unless you're
+sending mail to different domains that share the same MX host.
 
 Incompatible changes with snapshot Postfix-2.2-20040720
 =======================================================
@@ -37,13 +52,15 @@ is added to your master.cf file when you upgrade Postfix.
 *** You need to execute "postfix stop" when upgrading from Postfix
 *** version 2.0 or earlier. Execute "postfix start" when done.
 
-Session caching is enabled with the new smtp_connection_cache_domains
+Session caching is enabled with the new smtp_connection_cache_destinations
 parameter. Specify a list of destinations or lookup tables:
 
-- a domain name (the right-hand side of an email address),
+- if mail is sent without relay host: a domain (the right-hand side
+of an email address),
 
-- a relay host (including optional [] and/or non-default TCP port),
-using the exact same spelling as in main.cf or in the transport map,
+- if mail is sent via a relay host, the relay host (without [],
+and without non-default TCP port) that is specified in main.cf or
+in the transport map,
 
 - a /file/name with domains and/or relay hosts,
 
@@ -53,11 +70,11 @@ side; the right-hand side result from type:table lookups is ignored.
 The following optimizes deliveries to hosts that your machine relays
 mail to:
 
-    smtp_connection_cache_domains = $relay_domains $relayhost
+    smtp_connection_cache_destinations = $relay_domains $relayhost
 
 A setting that tries to optimize deliveries to problem sites:
 
-    smtp_connection_cache_domains = hotmail.com...
+    smtp_connection_cache_destinations = hotmail.com...
 
 Cached SMTP sessions are allowed to remain unused for only a limited
 amount of time (smtp_connection_cache_time_limit, default:  2
index cee28fee259f4e689476ca2e64c1faf982589337..235e3d1a3b881dfaf9c5dfb8f02ac7431774165c 100644 (file)
@@ -5166,7 +5166,7 @@ The default time unit is s (seconds).
 
 </DD>
 
-<DT><b><a name="smtp_connection_cache_domains">smtp_connection_cache_domains</a>
+<DT><b><a name="smtp_connection_cache_destinations">smtp_connection_cache_destinations</a>
 (default: empty)</b></DT><DD>
 
 <p> The SMTP destinations for which SMTP connection caching is
@@ -5182,11 +5182,12 @@ or pseudo-destinations:
 
 <ul>
 
-<li> a domain name (the right-hand side of an email address),
+<li> if mail is sent without a relay host: a domain name (the
+right-hand side of an email address, without the optional []),
 
-<li> a relay host (including optional [] and/or non-default TCP
-port), using the exact same spelling as in main.cf or in the
-transport map,
+<li> if mail is sent via a relay host: a relay host (without the
+optional [] or non-default TCP port), as specified in main.cf or
+in the transport map,
 
 <li> a /file/name with domains and/or relay hosts,
 
index f03376e4c21e572700342040f9e3a681cb07ce19..92d73f05136ed85c1b237b5844f2cb0c5c2157a4 100644 (file)
@@ -13,9 +13,9 @@ SCACHE(8)                                               SCACHE(8)
        <b>scache</b> [generic Postfix daemon options]
 
 <b>DESCRIPTION</b>
-       The  scache  server  maintains  the Postfix session cache.
-       This information can be used by, for example, the  Postfix
-       SMTP client.
+       The  <b>scache</b> server maintains a shared multi-session cache.
+       This information can be used by, for example, Postfix SMTP
+       clients or other Postfix delivery agents.
 
        The  session  cache  is organized into logical destination
        names, physical endpoint names, and sessions.
@@ -47,33 +47,32 @@ SCACHE(8)                                               SCACHE(8)
               Save the  specified  file  descriptor  and  session
               property  data  under  the specified endpoint name.
               The endpoint properties are used by the  client  to
-              re-activate  a passivated session object.  queue ID
-              is queued for the specified destination.
+              re-activate a passivated session object.
 
        <b>find_endp</b> <i>endpoint</i>
-              Look  up  cached  properties  and  a  cached   file
+              Look   up  cached  properties  and  a  cached  file
               descriptor for the specified endpoint.
 
        <b>save_dest</b> <i>ttl destination destination</i><b>_</b><i>properties endpoint</i>
-              Save  the binding between a logical destination and
-              an endpoint under the  destination  name,  together
-              with  destination  specific session properties. The
-              destination properties are used by  the  client  to
+              Save the binding between a logical destination  and
+              an  endpoint  under  the destination name, together
+              with destination specific session  properties.  The
+              destination  properties  are  used by the client to
               re-activate a passivated session object.
 
        <b>find_dest</b> <i>destination</i>
-              Look  up cached destination properties, cached end-
-              point properties, and a cached file descriptor  for
+              Look up cached destination properties, cached  end-
+              point  properties, and a cached file descriptor for
               the specified logical destination.
 
 <b>SECURITY</b>
-       The  session  cache  server  is not security-sensitive. It
-       does not talk to the network, and  it  does  not  talk  to
-       local  users.  The scache server can run chrooted at fixed
+       The session cache server  is  not  security-sensitive.  It
+       does  not  talk  to  the  network, and it does not talk to
+       local users.  The scache server can run chrooted at  fixed
        low privilege.
 
        The session cache server is not a trusted process. It must
-       not  be  used to store information that is security sensi-
+       not be used to store information that is  security  sensi-
        tive.
 
 <b>DIAGNOSTICS</b>
@@ -86,32 +85,32 @@ SCACHE(8)                                               SCACHE(8)
        protocol specific handshake.
 
 <b>CONFIGURATION PARAMETERS</b>
-       Changes   to   <b>main.cf</b>  are  picked  up  automatically  as
+       Changes  to  <b>main.cf</b>  are  picked  up   automatically   as
        <a href="scache.8.html">scache(8)</a> processes run for only a limited amount of time.
        Use the command "<b>postfix reload</b>" to speed up a change.
 
-       The  text  below  provides  only  a parameter summary. See
+       The text below provides  only  a  parameter  summary.  See
        <a href="postconf.5.html">postconf(5)</a> for more details including examples.
 
 <b>RESOURCE CONTROLS</b>
        <b><a href="postconf.5.html#session_cache_ttl_limit">session_cache_ttl_limit</a> (2s)</b>
-              The maximal time-to-live  value  that  the  session
+              The  maximal  time-to-live  value  that the session
               cache server allows.
 
        <b>session_cache_status_update_time (600s)</b>
-              How  frequently  the  <a href="scache.8.html">scache(8)</a>  server  logs usage
-              statistics with session cache hit  and  miss  rates
-              for  logical  destinations  and  for  physical end-
+              How frequently  the  <a href="scache.8.html">scache(8)</a>  server  logs  usage
+              statistics  with  session  cache hit and miss rates
+              for logical  destinations  and  for  physical  end-
               points.
 
 <b>MISCELLANEOUS CONTROLS</b>
        <b><a href="postconf.5.html#config_directory">config_directory</a> (see 'postconf -d' output)</b>
-              The default location of  the  Postfix  main.cf  and
+              The  default  location  of  the Postfix main.cf and
               master.cf configuration files.
 
        <b><a href="postconf.5.html#daemon_timeout">daemon_timeout</a> (18000s)</b>
-              How  much time a Postfix daemon process may take to
-              handle a request  before  it  is  terminated  by  a
+              How much time a Postfix daemon process may take  to
+              handle  a  request  before  it  is  terminated by a
               built-in watchdog timer.
 
        <b><a href="postconf.5.html#ipc_timeout">ipc_timeout</a> (3600s)</b>
@@ -119,23 +118,23 @@ SCACHE(8)                                               SCACHE(8)
               over an internal communication channel.
 
        <b><a href="postconf.5.html#max_idle">max_idle</a> (100s)</b>
-              The maximum amount of time  that  an  idle  Postfix
-              daemon  process  waits for the next service request
+              The  maximum  amount  of  time that an idle Postfix
+              daemon process waits for the next  service  request
               before exiting.
 
        <b><a href="postconf.5.html#process_id">process_id</a> (read-only)</b>
-              The process ID of a Postfix command or daemon  pro-
+              The  process ID of a Postfix command or daemon pro-
               cess.
 
        <b><a href="postconf.5.html#process_name">process_name</a> (read-only)</b>
-              The  process  name  of  a Postfix command or daemon
+              The process name of a  Postfix  command  or  daemon
               process.
 
        <b><a href="postconf.5.html#syslog_facility">syslog_facility</a> (mail)</b>
               The syslog facility of Postfix logging.
 
        <b><a href="postconf.5.html#syslog_name">syslog_name</a> (postfix)</b>
-              The mail system name that is prepended to the  pro-
+              The  mail system name that is prepended to the pro-
               cess  name  in  syslog  records,  so  that  "smtpd"
               becomes, for example, "postfix/smtpd".
 
@@ -146,7 +145,7 @@ SCACHE(8)                                               SCACHE(8)
        syslogd(8), system logging
 
 <b>LICENSE</b>
-       The Secure Mailer license must be  distributed  with  this
+       The  Secure  Mailer  license must be distributed with this
        software.
 
 <b>HISTORY</b>
index 6ff646a3746f99f61b94064d0ac3e8ee7cd67f47..8fd7b06a968c3befeb18aa1d8201e6fff02b9d93 100644 (file)
@@ -236,7 +236,7 @@ SMTP(8)                                                   SMTP(8)
 
        Available in Postfix version 2.2 and later:
 
-       <b><a href="postconf.5.html#smtp_connection_cache_domains">smtp_connection_cache_domains</a> (empty)</b>
+       <b><a href="postconf.5.html#smtp_connection_cache_destinations">smtp_connection_cache_destinations</a> (empty)</b>
               The SMTP destinations  for  which  SMTP  connection
               caching is enabled.
 
index 9b634befef5c5df36bac0c4d41e485ad60311915..f520c1710f32d8c367fc5a820d042838030b7b04 100644 (file)
@@ -2697,7 +2697,7 @@ the operating system).
 .PP
 Time units: s (seconds), m (minutes), h (hours), d (days), w (weeks).
 The default time unit is s (seconds).
-.SH smtp_connection_cache_domains (default: empty)
+.SH smtp_connection_cache_destinations (default: empty)
 The SMTP destinations for which SMTP connection caching is
 enabled.  With SMTP connection caching, a connection is not closed
 immediately after completion of a mail transaction.  Instead, the
@@ -2708,11 +2708,12 @@ and can improve mail delivery performance.
 Specify a comma or white space separated list of destinations
 or pseudo-destinations:
 .IP \(bu
-a domain name (the right-hand side of an email address),
+if mail is sent without a relay host: a domain name (the
+right-hand side of an email address, without the optional []),
 .IP \(bu
-a relay host (including optional [] and/or non-default TCP
-port), using the exact same spelling as in main.cf or in the
-transport map,
+if mail is sent via a relay host: a relay host (without the
+optional [] or non-default TCP port), as specified in main.cf or
+in the transport map,
 .IP \(bu
 a /file/name with domains and/or relay hosts,
 .IP \(bu
index 09de34baa27c79892ee07fdd92a438e8b6d50fb1..fdd0fe0024afbb20f6d93ef5fef4091ab12ecf01 100644 (file)
@@ -12,8 +12,9 @@ Postfix session cache server
 .SH DESCRIPTION
 .ad
 .fi
-The scache server maintains the Postfix session cache. This
-information can be used by, for example, the Postfix SMTP client.
+The \fBscache\fR server maintains a shared multi-session
+cache. This information can be used by, for example, Postfix
+SMTP clients or other Postfix delivery agents.
 
 The session cache is organized into logical destination
 names, physical endpoint names, and sessions.
@@ -46,7 +47,6 @@ Save the specified file descriptor and session property data
 under the specified endpoint name. The endpoint properties
 are used by the client to re-activate a passivated session
 object.
-queue ID is queued for the specified destination.
 .IP "\fBfind_endp\fI endpoint\fR"
 Look up cached properties and a cached file descriptor for the
 specified endpoint.
index a63cf55ecf851541f45a3b2ce531c96d7413808c..cc98f8252b53d9b4be80ccf6d7ee156619094be6 100644 (file)
@@ -209,7 +209,7 @@ The SMTP client time limit for sending the RSET command, and
 for receiving the server response.
 .PP
 Available in Postfix version 2.2 and later:
-.IP "\fBsmtp_connection_cache_domains (empty)\fR"
+.IP "\fBsmtp_connection_cache_destinations (empty)\fR"
 The SMTP destinations for which SMTP connection caching is
 enabled.
 .IP "\fBsmtp_connection_cache_reuse_limit (10)\fR"
index 8b854afa63701705d90e0ed25bfacdb2af508359..9ed72b58fc1af6226e9c54bdd91df9d3b759f570 100755 (executable)
@@ -305,7 +305,7 @@ while (<>) {
 
     s;\bsmtp_connection_cache_reuse_limit\b;<a href="postconf.5.html#smtp_connection_cache_reuse_limit">$&</a>;g;
     s;\bsmtp_connection_cache_time_limit\b;<a href="postconf.5.html#smtp_connection_cache_time_limit">$&</a>;g;
-    s;\bsmtp_connection_cache_domains\b;<a href="postconf.5.html#smtp_connection_cache_domains">$&</a>;g;
+    s;\bsmtp_connection_cache_destinations\b;<a href="postconf.5.html#smtp_connection_cache_destinations">$&</a>;g;
 
     s;\bsmtp_data_done_timeout\b;<a href="postconf.5.html#smtp_data_done_timeout">$&</a>;g;
     s;\bsmtp_data_init_timeout\b;<a href="postconf.5.html#smtp_data_init_timeout">$&</a>;g;
index c8812327ed8b0c1a1f224bbd9afe64c6192a677b..6cee85a30b94e2e0f6841374b036dd55a47d08f0 100644 (file)
@@ -3185,7 +3185,7 @@ not specify larger values without permission from the remote sites.
 an SMTP session is reused before it is closed. 
 </p>
 
-%PARAM smtp_connection_cache_domains
+%PARAM smtp_connection_cache_destinations
 
 <p> The SMTP destinations for which SMTP connection caching is
 enabled.  With SMTP connection caching, a connection is not closed
@@ -3200,11 +3200,12 @@ or pseudo-destinations:
 
 <ul>
 
-<li> a domain name (the right-hand side of an email address),
+<li> if mail is sent without a relay host: a domain name (the
+right-hand side of an email address, without the optional []),
 
-<li> a relay host (including optional [] and/or non-default TCP
-port), using the exact same spelling as in main.cf or in the
-transport map,
+<li> if mail is sent via a relay host: a relay host (without the
+optional [] or non-default TCP port), as specified in main.cf or
+in the transport map,
 
 <li> a /file/name with domains and/or relay hosts,
 
index 5a9f693c254a39d8c730333a8c1830e08cb4b55c..9bdd34cefa5253ea4118b4bb35d623285a70fcd0 100644 (file)
@@ -777,7 +777,7 @@ extern int var_smtp_cache_conn;
 #define DEF_SMTP_REUSE_LIMIT   10
 extern int var_smtp_reuse_limit;
 
-#define VAR_SMTP_CACHE_DEST    "smtp_connection_cache_domains"
+#define VAR_SMTP_CACHE_DEST    "smtp_connection_cache_destinations"
 #define DEF_SMTP_CACHE_DEST    ""
 extern char *var_smtp_cache_dest;
 
index 4d9082a7bd6b40cfcf77abba643f68b9cec675cb..baa5aa54f3fa5bad44d9a7811280ab91036533b5 100644 (file)
@@ -121,6 +121,7 @@ extern char *mail_pathname(const char *, const char *);
 #define MAIL_ATTR_SASL_METHOD  "sasl_method"
 #define MAIL_ATTR_SASL_USERNAME        "sasl_username"
 #define MAIL_ATTR_SASL_SENDER  "sasl_sender"
+#define MAIL_ATTR_DUMMY                "dummy"
 
 #define MAIL_ATTR_TTL          "ttl"
 #define MAIL_ATTR_LABEL                "label"
index d463b3fb5e00f09b2e59adb4bcddb7056413a595..477479d4d2c6a4dff43131be0bf31c720a377298 100644 (file)
@@ -20,7 +20,7 @@
   * Patches change the patchlevel and the release date. Snapshots change the
   * release date only.
   */
-#define MAIL_RELEASE_DATE      "20040721"
+#define MAIL_RELEASE_DATE      "20040723"
 #define MAIL_VERSION_NUMBER    "2.2"
 
 #define VAR_MAIL_VERSION       "mail_version"
index 38aabb025e70dda4b0c08e1b0ec26664586e7cd0..6bb233daa39bcf9167ce84fdcf2a8fbad03ba428 100644 (file)
@@ -66,6 +66,9 @@
 typedef struct {
     SCACHE  scache[1];                 /* super-class */
     CLNT_STREAM *clnt_stream;          /* client endpoint */
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+    VSTRING *dummy;                    /* dummy buffer */
+#endif
 } SCACHE_CLNT;
 
 #define STR(x) vstring_str(x)
@@ -106,6 +109,11 @@ static void scache_clnt_save_endp(SCACHE *scache, int endp_ttl,
                       ATTR_TYPE_STR, MAIL_ATTR_PROP, endp_prop,
                       ATTR_TYPE_END) != 0
            || vstream_fflush(stream)
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+           || attr_scan(stream, ATTR_FLAG_STRICT,
+                        ATTR_TYPE_STR, MAIL_ATTR_DUMMY, sp->dummy,
+                        ATTR_TYPE_END) != 1
+#endif
            || LOCAL_SEND_FD(vstream_fileno(stream), fd) < 0
            || attr_scan(stream, ATTR_FLAG_STRICT,
                         ATTR_TYPE_NUM, MAIL_ATTR_STATUS, &status,
@@ -152,7 +160,16 @@ static int scache_clnt_find_endp(SCACHE *scache, const char *endp_label,
                         ATTR_TYPE_STR, MAIL_ATTR_PROP, endp_prop,
                         ATTR_TYPE_END) != 2
            || (status == 0
-               && (fd = LOCAL_RECV_FD(vstream_fileno(stream))) < 0)) {
+               && (
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+                   attr_print(stream, ATTR_FLAG_NONE,
+                              ATTR_TYPE_STR, MAIL_ATTR_DUMMY, "",
+                              ATTR_TYPE_END) != 0
+                   || vstream_fflush(stream) != 0
+                   || read_wait(vstream_fileno(stream),
+                                stream->timeout) < 0 ||        /* XXX */
+#endif
+                   (fd = LOCAL_RECV_FD(vstream_fileno(stream))) < 0))) {
            if (msg_verbose || (errno != EPIPE && errno != ENOENT))
                msg_warn("problem talking to service %s: %m",
                         VSTREAM_PATH(stream));
@@ -257,7 +274,16 @@ static int scache_clnt_find_dest(SCACHE *scache, const char *dest_label,
                         ATTR_TYPE_STR, MAIL_ATTR_PROP, endp_prop,
                         ATTR_TYPE_END) != 3
            || (status == 0
-               && (fd = LOCAL_RECV_FD(vstream_fileno(stream))) < 0)) {
+               && (
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+                   attr_print(stream, ATTR_FLAG_NONE,
+                              ATTR_TYPE_STR, MAIL_ATTR_DUMMY, "",
+                              ATTR_TYPE_END) != 0
+                   || vstream_fflush(stream) != 0
+                   || read_wait(vstream_fileno(stream),
+                                stream->timeout) < 0 ||        /* XXX */
+#endif
+                   (fd = LOCAL_RECV_FD(vstream_fileno(stream))) < 0))) {
            if (msg_verbose || (errno != EPIPE && errno != ENOENT))
                msg_warn("problem talking to service %s: %m",
                         VSTREAM_PATH(stream));
@@ -287,6 +313,9 @@ static void scache_clnt_free(SCACHE *scache)
     SCACHE_CLNT *sp = (SCACHE_CLNT *) scache;
 
     clnt_stream_free(sp->clnt_stream);
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+    vstring_free(sp->dummy);
+#endif
     myfree((char *) sp);
 }
 
@@ -304,6 +333,9 @@ SCACHE *scache_clnt_create(const char *server, int idle_limit, int ttl_limit)
 
     sp->clnt_stream = clnt_stream_create(MAIL_CLASS_PRIVATE, server,
                                         idle_limit, ttl_limit);
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+    sp->dummy = vstring_alloc(1);
+#endif
 
     return (sp->scache);
 }
index 092a93b8916a0bc7700ff7f8a5026f61de2e45e6..1fc319818f7e5dca89c4d6b1474ac07343a42d80 100644 (file)
@@ -58,6 +58,7 @@ scache.o: ../../include/msg.h
 scache.o: ../../include/iostuff.h
 scache.o: ../../include/htable.h
 scache.o: ../../include/ring.h
+scache.o: ../../include/events.h
 scache.o: ../../include/mail_params.h
 scache.o: ../../include/mail_proto.h
 scache.o: ../../include/vstream.h
index b3b2c95a227e1db7e9e00bb3bcc4620f5b2ad0aa..8ca7858eaeccb56ce8e72d86355212663d504cd1 100644 (file)
@@ -6,8 +6,9 @@
 /* SYNOPSIS
 /*     \fBscache\fR [generic Postfix daemon options]
 /* DESCRIPTION
-/*     The scache server maintains the Postfix session cache. This
-/*     information can be used by, for example, the Postfix SMTP client.
+/*     The \fBscache\fR server maintains a shared multi-session
+/*     cache. This information can be used by, for example, Postfix
+/*     SMTP clients or other Postfix delivery agents.
 /*
 /*     The session cache is organized into logical destination
 /*     names, physical endpoint names, and sessions.
@@ -40,7 +41,6 @@
 /*     under the specified endpoint name. The endpoint properties
 /*     are used by the client to re-activate a passivated session
 /*     object.
-/*     queue ID is queued for the specified destination.
 /* .IP "\fBfind_endp\fI endpoint\fR"
 /*     Look up cached properties and a cached file descriptor for the
 /*     specified endpoint.
@@ -171,6 +171,11 @@ static VSTRING *scache_dest_prop;
 static VSTRING *scache_endp_label;
 static VSTRING *scache_endp_prop;
 
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+static VSTRING *scache_dummy;
+
+#endif
+
  /*
   * Session cache instance.
   */
@@ -211,7 +216,17 @@ static void scache_save_endp_service(VSTREAM *client_stream)
                   ATTR_TYPE_NUM, MAIL_ATTR_STATUS, SCACHE_STAT_BAD,
                   ATTR_TYPE_END);
        return;
-    } else if ((fd = LOCAL_RECV_FD(vstream_fileno(client_stream))) < 0) {
+    } else if (
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+              attr_print(client_stream, ATTR_FLAG_NONE,
+                         ATTR_TYPE_STR, MAIL_ATTR_DUMMY, "",
+                         ATTR_TYPE_END) != 0
+              || vstream_fflush(client_stream) != 0
+              || read_wait(vstream_fileno(client_stream),
+                           client_stream->timeout) < 0 /* XXX */
+              ||
+#endif
+              (fd = LOCAL_RECV_FD(vstream_fileno(client_stream))) < 0) {
        msg_warn("%s: unable to receive file descriptor", myname);
        attr_print(client_stream, ATTR_FLAG_NONE,
                   ATTR_TYPE_NUM, MAIL_ATTR_STATUS, SCACHE_STAT_FAIL,
@@ -259,6 +274,11 @@ static void scache_find_endp_service(VSTREAM *client_stream)
                   ATTR_TYPE_STR, MAIL_ATTR_PROP, STR(scache_endp_prop),
                   ATTR_TYPE_END);
        if (vstream_fflush(client_stream) != 0
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+           || attr_scan(client_stream, ATTR_FLAG_STRICT,
+                        ATTR_TYPE_STR, MAIL_ATTR_DUMMY, scache_dummy,
+                        ATTR_TYPE_END) != 1
+#endif
            || LOCAL_SEND_FD(vstream_fileno(client_stream), fd) < 0)
            msg_warn("%s: cannot send file descriptor: %m", myname);
        if (close(fd) < 0)
@@ -335,6 +355,11 @@ static void scache_find_dest_service(VSTREAM *client_stream)
                   ATTR_TYPE_STR, MAIL_ATTR_PROP, STR(scache_endp_prop),
                   ATTR_TYPE_END);
        if (vstream_fflush(client_stream) != 0
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+           || attr_scan(client_stream, ATTR_FLAG_STRICT,
+                        ATTR_TYPE_STR, MAIL_ATTR_DUMMY, scache_dummy,
+                        ATTR_TYPE_END) != 1
+#endif
            || LOCAL_SEND_FD(vstream_fileno(client_stream), fd) < 0)
            msg_warn("%s: cannot send file descriptor: %m", myname);
        if (close(fd) < 0)
@@ -436,6 +461,9 @@ static void post_jail_init(char *unused_name, char **unused_argv)
     scache_dest_prop = vstring_alloc(10);
     scache_endp_label = vstring_alloc(10);
     scache_endp_prop = vstring_alloc(10);
+#ifdef CANT_WRITE_BEFORE_SENDING_FD
+    scache_dummy = vstring_alloc(10);
+#endif
 
     /*
      * Disable the max_use limit. We still terminate when no client is
index 60043c945b221cc4ac00c8107c93f3fce5ed0e5a..095d00c1846753f3fde5493204799f1e14321c5b 100644 (file)
 /*     for receiving the server response.
 /* .PP
 /*     Available in Postfix version 2.2 and later:
-/* .IP "\fBsmtp_connection_cache_domains (empty)\fR"
+/* .IP "\fBsmtp_connection_cache_destinations (empty)\fR"
 /*     The SMTP destinations for which SMTP connection caching is
 /*     enabled.
 /* .IP "\fBsmtp_connection_cache_reuse_limit (10)\fR"
index 2e401af1cce9fe7354e890e7548afd4dc11e33b8..600b6fa5d2cb06d56c86a1564dc5e05d5cd270d7 100644 (file)
@@ -449,7 +449,7 @@ int     smtp_connect(SMTP_STATE *state)
     SMTP_SESSION *session;
     int     lookup_mx;
     unsigned domain_best_pref;
-    int     sess_flags;
+    int     sess_flags = SMTP_SESS_FLAG_NONE;
 
     /*
      * First try to deliver to the indicated destination, then try to deliver
@@ -464,16 +464,6 @@ int     smtp_connect(SMTP_STATE *state)
        msg_panic("null destination: \"%s\"", request->nexthop);
     argv_split_append(sites, var_fallback_relay, ", \t\r\n");
 
-    /*
-     * Enable session caching by next-hop destination.
-     */
-    if (sites->argv[0]
-       && smtp_cache_dest
-       && string_list_match(smtp_cache_dest, sites->argv[0]))
-       sess_flags = SMTP_SESS_FLAG_CACHE;
-    else
-       sess_flags = SMTP_SESS_FLAG_NONE;
-
     /*
      * Don't give up after a hard host lookup error until we have tried the
      * fallback relay servers.
@@ -526,9 +516,18 @@ int     smtp_connect(SMTP_STATE *state)
         * XXX Replace sites->argv by (lookup_mx, domain, port) triples so we
         * don't have to make clumsy ad-hoc copies and keep track of who
         * free()s the memory.
+        * 
+        * XXX smtp_session_cache_destinations specifies domain names without
+        * :port, because : is already used for maptype:mapname. Because of
+        * this limitation we use the bare domain without the optional [] or
+        * non-default TCP port.
         */
-       if (cpp == sites->argv && (sess_flags & SMTP_SESS_FLAG_CACHE) != 0)
+       if (cpp == sites->argv
+           && smtp_cache_dest
+           && string_list_match(smtp_cache_dest, domain)) {
+           sess_flags |= SMTP_SESS_FLAG_CACHE;
            SET_NEXTHOP_STATE(state, lookup_mx, domain, port);
+       }
 
        /*
         * Don't try any backup host if mail loops to myself. That would just
@@ -576,6 +575,10 @@ int     smtp_connect(SMTP_STATE *state)
         * 
         * Cache the first good session under the next-hop destination name.
         * Cache all good sessions under their physical endpoint.
+        * 
+        * Don't query the session cache for primary MX hosts. We already did
+        * that in smtp_reuse_session(), and if any were found in the cache,
+        * they were already deleted from the address list.
         */
        for (addr = addr_list; SMTP_RCPT_LEFT(state) > 0 && addr; addr = next) {
            next = addr->next;
index 2f41f29dd8557576be12c42abb082b76e021ce82..1b5acd3e0a6384c1108e20d78d387395d047d890 100644 (file)
@@ -2393,8 +2393,9 @@ static void smtpd_proto(SMTPD_STATE *state, const char *service)
 
     case SMTP_ERR_TIME:
        state->reason = "timeout";
-       smtpd_chat_reply(state, "421 %s Error: timeout exceeded",
-                        var_myhostname);
+       if (vstream_setjmp(state->client) == 0)
+           smtpd_chat_reply(state, "421 %s Error: timeout exceeded",
+                            var_myhostname);
        break;
 
     case SMTP_ERR_EOF:
index ae0a501aba64b06193f965dafbf970e4d0ce87ce..09b6bb877ea3973effaa16955cc932ac5c504167 100644 (file)
@@ -247,6 +247,10 @@ static void get_service_attr(SPAWN_ATTR *attr, char *service, char **argv)
        msg_fatal("request to use privileged group id %ld", (long) attr->gid);
     if (attr->gid == var_owner_gid)
        msg_fatal("request to use mail system owner group id %ld", (long) attr->gid);
+    if (attr->uid == (uid_t) (-1))
+       msg_fatal("user must not have user ID -1");
+    if (attr->gid == (gid_t) (-1))
+       msg_fatal("user must not have group ID -1");
 
     /*
      * Give the poor tester a clue of what is going on.
index 595dddbdc72fa2a51ac0407dcd8abdc838dc60e1..ff9a123640a81a2baa4d7197a08fc5992cb0f1ff 100644 (file)
 /*     Each of these specifies I/O redirection of one of the standard file
 /*     descriptors for the command.
 /* .IP "SPAWN_CMD_UID (int)"
-/*     The user ID to execute the command as.
+/*     The user ID to execute the command as. The value -1 is reserved
+/*     and cannot be specified.
 /* .IP "SPAWN_CMD_GID (int)"
-/*     The group ID to execute the command as.
+/*     The group ID to execute the command as. The value -1 is reserved
+/*     and cannot be specified.
 /* .IP "SPAWN_CMD_TIME_LIMIT (int)"
 /*     The amount of time in seconds the command is allowed to run before
 /*     it is terminated with SIGKILL. The default is no time limit.
@@ -162,10 +164,14 @@ static void get_spawn_args(struct spawn_args * args, int init_key, va_list ap)
            args->stderr_fd = va_arg(ap, int);
            break;
        case SPAWN_CMD_UID:
-           args->uid = va_arg(ap, int);        /* in case uid_t is short */
+           args->uid = va_arg(ap, uid_t);
+           if (args->uid == (uid_t) (-1))
+               msg_panic("spawn_command: request with reserved user ID: -1");
            break;
        case SPAWN_CMD_GID:
-           args->gid = va_arg(ap, int);        /* in case gid_t is short */
+           args->gid = va_arg(ap, gid_t);
+           if (args->gid == (gid_t) (-1))
+               msg_panic("spawn_command: request with reserved group ID: -1");
            break;
        case SPAWN_CMD_TIME_LIMIT:
            args->time_limit = va_arg(ap, int);
index 8841e2202a772079f1f4e858980fef50c422d5cd..a9904d3f30983c78f91a21fc4d3495878c1275b7 100644 (file)
@@ -560,6 +560,7 @@ extern int initgroups(const char *, int);
 #define SOCKADDR_SIZE  socklen_t
 #define SOCKOPT_SIZE   socklen_t
 #endif
+#define CANT_WRITE_BEFORE_SENDING_FD
 #endif
 
 #ifdef LINUX1