From: Wietse Venema Date: Sat, 13 Sep 2003 05:00:00 +0000 (-0500) Subject: postfix-2.0.16 X-Git-Tag: v2.0.16^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20d666f001367bc27710a40d052233fa28b0f041;p=thirdparty%2Fpostfix.git postfix-2.0.16 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 87eef918a..80eaa0dca 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -7872,6 +7872,33 @@ Apologies for any names omitted. util/timed_read.c and as precautionary measure, util/timed_write.c. +20030908 + + The 20030905 workaround triggers too many warnings. TCP + sockets are back to blocking, and keepalives are turned on + to kill off dead sockets, as suggested by Leandro Santi. + Files: master/{single,multi}_server.c, smtpd/smtpd.c, + util/sys_defs.h. + +20030909 + + Bugfix: the LMTP session caching code had problems with + SASL authentication after the first connection, and pipelining + was working poorly. Fix by Viktor Dukhovni, Morgan Stanley. + Files: lmtp/lmtp.c, lmtp/lmtp_proto.c. + +20030912 + + Workaround: besides SMTP server sockets, SMTP client sockets + can also hang on Solaris, as reported by Leandro Santi. In + order to deal with this at the root, all connection management + is now done by sane_accept() and sane_connect(). Both turn + on keepalives on Solaris. + +20030913 + + Safety: set-gid commands don't trust TZ. File: msg_syslog.c. + Open problems: Doc: mention the proxy_interfaces parameter everywhere the diff --git a/postfix/conf/pcre_table b/postfix/conf/pcre_table index 0bb6b453c..e4f73f00b 100644 --- a/postfix/conf/pcre_table +++ b/postfix/conf/pcre_table @@ -40,103 +40,100 @@ # # if /pattern/flags # -# if !/pattern/flags -# # endif Match the search string against the patterns # between if and endif, if and only if the search -# string matches (does not match) pattern. The -# if..endif can nest. +# string matches pattern. The if..endif can nest. # -# Note: do not prepend whitespace to patterns inside +# Note: do not prepend whitespace to patterns inside # if..endif. # # Each pattern is a perl-like regular expression. The -# expression delimiter can be any character, except whites- -# pace or characters that have special meaning (tradition- -# ally the forward slash is used). The regular expression +# expression delimiter can be any character, except whites- +# pace or characters that have special meaning (tradition- +# ally the forward slash is used). The regular expression # can contain whitespace. # # By default, matching is case-insensitive, and newlines are -# not treated as special characters. The behavior is con- -# trolled by flags, which are toggled by appending one or +# not treated as special characters. The behavior is con- +# trolled by flags, which are toggled by appending one or # more of the following characters after the pattern: # # i (default: on) -# Toggles the case sensitivity flag. By default, +# Toggles the case sensitivity flag. By default, # matching is case insensitive. # # m (default: off) -# Toggles the PCRE_MULTILINE flag. When this flag is -# on, the ^ and $ metacharacters match immediately -# after and immediately before a newline character, -# respectively, in addition to matching at the start +# Toggles the PCRE_MULTILINE flag. When this flag is +# on, the ^ and $ metacharacters match immediately +# after and immediately before a newline character, +# respectively, in addition to matching at the start # and end of the subject string. # # s (default: on) # Toggles the PCRE_DOTALL flag. When this flag is on, # the . metacharacter matches the newline character. -# With Postfix versions prior to 20020528, The flag +# With Postfix versions prior to 20020528, The flag # is off by default, which is inconvenient for multi- # line message header matching. # # x (default: off) -# Toggles the pcre extended flag. When this flag is -# on, whitespace in the pattern (other than in a +# Toggles the pcre extended flag. When this flag is +# on, whitespace in the pattern (other than in a # character class) and characters between a # outside -# a character class and the next newline character -# are ignored. An escaping backslash can be used to -# include a whitespace or # character as part of the +# a character class and the next newline character +# are ignored. An escaping backslash can be used to +# include a whitespace or # character as part of the # pattern. # # A (default: off) -# Toggles the PCRE_ANCHORED flag. When this flag is -# on, the pattern is forced to be "anchored", that +# Toggles the PCRE_ANCHORED flag. When this flag is +# on, the pattern is forced to be "anchored", that # is, it is constrained to match only at the start of -# the string which is being searched (the "subject -# string"). This effect can also be achieved by +# the string which is being searched (the "subject +# string"). This effect can also be achieved by # appropriate constructs in the pattern itself. # # E (default: off) -# Toggles the PCRE_DOLLAR_ENDONLY flag. When this -# flag is on, a $ metacharacter in the pattern -# matches only at the end of the subject string. -# Without this flag, a dollar also matches immedi- +# Toggles the PCRE_DOLLAR_ENDONLY flag. When this +# flag is on, a $ metacharacter in the pattern +# matches only at the end of the subject string. +# Without this flag, a dollar also matches immedi- # ately before the final character if it is a newline # character (but not before any other newline charac- -# ters). This flag is ignored if PCRE_MULTILINE flag +# ters). This flag is ignored if PCRE_MULTILINE flag # is set. # # U (default: off) # Toggles the ungreedy matching flag. When this flag -# is on, the pattern matching engine inverts the -# "greediness" of the quantifiers so that they are -# not greedy by default, but become greedy if fol- -# lowed by "?". This flag can also set by a (?U) +# is on, the pattern matching engine inverts the +# "greediness" of the quantifiers so that they are +# not greedy by default, but become greedy if fol- +# lowed by "?". This flag can also set by a (?U) # modifier within the pattern. # # X (default: off) # Toggles the PCRE_EXTRA flag. When this flag is on, -# any backslash in a pattern that is followed by a +# any backslash in a pattern that is followed by a # letter that has no special meaning causes an error, # thus reserving these combinations for future expan- # sion. # -# Each pattern is applied to the entire lookup key string. -# Depending on the application, that string is an entire +# Each pattern is applied to the entire lookup key string. +# Depending on the application, that string is an entire # client hostname, an entire client IP address, or an entire -# mail address. Thus, no parent domain or parent network -# search is done, and user@domain mail addresses are not -# broken up into their user and domain constituent parts, +# mail address. Thus, no parent domain or parent network +# search is done, and user@domain mail addresses are not +# broken up into their user and domain constituent parts, # nor is user+foo broken up into user and foo. # -# 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. # -# Substitution of substrings from the matched expression -# into the result string is possible using the conventional -# perl syntax ($1, $2, etc.). The macros in the result -# string may need to be written as ${n} or $(n) if they +# Substitution of substrings from the matched expression +# into the result string is possible using the conventional +# perl syntax ($1, $2, etc.). The macros in the result +# string may need to be written as ${n} or $(n) if they # aren't followed by whitespace. # # EXAMPLE SMTPD ACCESS MAP diff --git a/postfix/html/pcre_table.5.html b/postfix/html/pcre_table.5.html index 1fd38bc1e..4510145fe 100644 --- a/postfix/html/pcre_table.5.html +++ b/postfix/html/pcre_table.5.html @@ -41,103 +41,100 @@ PCRE_TABLE(5) PCRE_TABLE(5) if /pattern/flags - if !/pattern/flags - endif Match the search string against the patterns between if and endif, if and only if the search - string matches (does not match) pattern. The - if..endif can nest. + string matches pattern. The if..endif can nest. - Note: do not prepend whitespace to patterns inside + Note: do not prepend whitespace to patterns inside if..endif. Each pattern is a perl-like regular expression. The - expression delimiter can be any character, except whites- - pace or characters that have special meaning (tradition- - ally the forward slash is used). The regular expression + expression delimiter can be any character, except whites- + pace or characters that have special meaning (tradition- + ally the forward slash is used). The regular expression can contain whitespace. By default, matching is case-insensitive, and newlines are - not treated as special characters. The behavior is con- - trolled by flags, which are toggled by appending one or + not treated as special characters. The behavior is con- + trolled by flags, which are toggled by appending one or more of the following characters after the pattern: i (default: on) - Toggles the case sensitivity flag. By default, + Toggles the case sensitivity flag. By default, matching is case insensitive. m (default: off) - Toggles the PCRE_MULTILINE flag. When this flag is - on, the ^ and $ metacharacters match immediately - after and immediately before a newline character, - respectively, in addition to matching at the start + Toggles the PCRE_MULTILINE flag. When this flag is + on, the ^ and $ metacharacters match immediately + after and immediately before a newline character, + respectively, in addition to matching at the start and end of the subject string. s (default: on) Toggles the PCRE_DOTALL flag. When this flag is on, the . metacharacter matches the newline character. - With Postfix versions prior to 20020528, The flag + With Postfix versions prior to 20020528, The flag is off by default, which is inconvenient for multi- line message header matching. x (default: off) - Toggles the pcre extended flag. When this flag is - on, whitespace in the pattern (other than in a + Toggles the pcre extended flag. When this flag is + on, whitespace in the pattern (other than in a character class) and characters between a # outside - a character class and the next newline character - are ignored. An escaping backslash can be used to - include a whitespace or # character as part of the + a character class and the next newline character + are ignored. An escaping backslash can be used to + include a whitespace or # character as part of the pattern. A (default: off) - Toggles the PCRE_ANCHORED flag. When this flag is - on, the pattern is forced to be "anchored", that + Toggles the PCRE_ANCHORED flag. When this flag is + on, the pattern is forced to be "anchored", that is, it is constrained to match only at the start of - the string which is being searched (the "subject - string"). This effect can also be achieved by + the string which is being searched (the "subject + string"). This effect can also be achieved by appropriate constructs in the pattern itself. E (default: off) - Toggles the PCRE_DOLLAR_ENDONLY flag. When this - flag is on, a $ metacharacter in the pattern - matches only at the end of the subject string. - Without this flag, a dollar also matches immedi- + Toggles the PCRE_DOLLAR_ENDONLY flag. When this + flag is on, a $ metacharacter in the pattern + matches only at the end of the subject string. + Without this flag, a dollar also matches immedi- ately before the final character if it is a newline character (but not before any other newline charac- - ters). This flag is ignored if PCRE_MULTILINE flag + ters). This flag is ignored if PCRE_MULTILINE flag is set. U (default: off) Toggles the ungreedy matching flag. When this flag - is on, the pattern matching engine inverts the - "greediness" of the quantifiers so that they are - not greedy by default, but become greedy if fol- - lowed by "?". This flag can also set by a (?U) + is on, the pattern matching engine inverts the + "greediness" of the quantifiers so that they are + not greedy by default, but become greedy if fol- + lowed by "?". This flag can also set by a (?U) modifier within the pattern. X (default: off) Toggles the PCRE_EXTRA flag. When this flag is on, - any backslash in a pattern that is followed by a + any backslash in a pattern that is followed by a letter that has no special meaning causes an error, thus reserving these combinations for future expan- sion. - Each pattern is applied to the entire lookup key string. - Depending on the application, that string is an entire + Each pattern is applied to the entire lookup key string. + Depending on the application, that string is an entire client hostname, an entire client IP address, or an entire - mail address. Thus, no parent domain or parent network - search is done, and user@domain mail addresses are not - broken up into their user and domain constituent parts, + mail address. Thus, no parent domain or parent network + search is done, and user@domain mail addresses are not + broken up into their user and domain constituent parts, nor is user+foo broken up into user and foo. - 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. - Substitution of substrings from the matched expression - into the result string is possible using the conventional - perl syntax ($1, $2, etc.). The macros in the result - string may need to be written as ${n} or $(n) if they + Substitution of substrings from the matched expression + into the result string is possible using the conventional + perl syntax ($1, $2, etc.). The macros in the result + string may need to be written as ${n} or $(n) if they aren't followed by whitespace. EXAMPLE SMTPD ACCESS MAP diff --git a/postfix/html/smtpd.8.html b/postfix/html/smtpd.8.html index 350f24942..b58ce5aca 100644 --- a/postfix/html/smtpd.8.html +++ b/postfix/html/smtpd.8.html @@ -62,28 +62,29 @@ SMTPD(8) SMTPD(8) with comments that Sendmail allows. broken_sasl_auth_clients - Support older Microsoft clients that mis-implement - the AUTH protocol, and that expect an EHLO response - of "250 AUTH=list" instead of "250 AUTH list". + Support Microsoft clients that implement an older + version of the AUTH protocol, and that expect an + EHLO response of "250 AUTH=list" instead of "250 + AUTH list". smtpd_noop_commands List of commands that are treated as NOOP (no oper- - ation) commands, without any parameter syntax - checking and without any state change. This list + ation) commands, without any parameter syntax + checking and without any state change. This list overrides built-in command definitions. Content inspection controls content_filter - The name of a mail delivery transport that filters + The name of a mail delivery transport that filters mail and that either bounces mail or re-injects the - result back into Postfix. This parameter uses the - same syntax as the right-hand side of a Postfix + result back into Postfix. This parameter uses the + same syntax as the right-hand side of a Postfix transport table. Authentication controls - enable_sasl_authentication - Enable per-session authentication as per RFC 2554 - (SASL). This functionality is available only when + smtpd_sasl_auth_enable + Enable per-session authentication as per RFC 2554 + (SASL). This functionality is available only when explicitly selected at program build time and explicitly enabled at runtime. @@ -109,14 +110,14 @@ SMTPD(8) SMTPD(8) Disallow anonymous logins. smtpd_sender_login_maps - Maps that specify the SASL login name that owns a - MAIL FROM sender address. Used by the + Maps that specify the SASL login name that owns a + MAIL FROM sender address. Used by the reject_sender_login_mismatch sender anti-spoofing restriction. Miscellaneous always_bcc - Address to send a copy of each message that enters + Address to send a copy of each message that enters the system. authorized_verp_clients @@ -124,23 +125,23 @@ SMTPD(8) SMTPD(8) that are authorized to use the XVERP extension. debug_peer_level - Increment in verbose logging level when a remote + Increment in verbose logging level when a remote host matches a pattern in the debug_peer_list parameter. debug_peer_list - List of domain or network patterns. When a remote - host matches a pattern, increase the verbose log- - ging level by the amount specified in the + List of domain or network patterns. When a remote + host matches a pattern, increase the verbose log- + ging level by the amount specified in the debug_peer_level parameter. default_verp_delimiters The default VERP delimiter characters that are used - when the XVERP command is specified without + when the XVERP command is specified without explicit delimiters. error_notice_recipient - Recipient of protocol/policy/resource/software + Recipient of protocol/policy/resource/software error notices. hopcount_limit @@ -149,18 +150,18 @@ SMTPD(8) SMTPD(8) notify_classes List of error classes. Of special interest are: - policy When a client violates any policy, mail a + policy When a client violates any policy, mail a transcript of the entire SMTP session to the postmaster. protocol - When a client violates the SMTP protocol or + When a client violates the SMTP protocol or issues an unimplemented command, mail a transcript of the entire SMTP session to the postmaster. smtpd_banner - Text that follows the 220 status code in the SMTP + Text that follows the 220 status code in the SMTP greeting banner. smtpd_expansion_filter @@ -168,57 +169,57 @@ SMTPD(8) SMTPD(8) expansion of rbl template responses and other text. smtpd_recipient_limit - Restrict the number of recipients that the SMTP + Restrict the number of recipients that the SMTP server accepts per message delivery. smtpd_timeout - Limit the time to send a server response and to + Limit the time to send a server response and to receive a client request. soft_bounce - Change hard (5xx) reject responses into soft (4xx) - reject responses. This can be useful for testing + Change hard (5xx) reject responses into soft (4xx) + reject responses. This can be useful for testing purposes. verp_delimiter_filter - The characters that Postfix accepts as VERP delim- + The characters that Postfix accepts as VERP delim- iter characters. Known versus unknown recipients show_user_unknown_table_name - Whether or not to reveal the table name in the - "User unknown" responses. The extra detail makes - trouble shooting easier but also reveals informa- + Whether or not to reveal the table name in the + "User unknown" responses. The extra detail makes + trouble shooting easier but also reveals informa- tion that is nobody elses business. unknown_local_recipient_reject_code The response code when a client specifies a recipi- - ent whose domain matches $mydestination or + ent whose domain matches $mydestination or $inet_interfaces, while $local_recipient_maps is - non-empty and does not list the recipient address + non-empty and does not list the recipient address or address local-part. unknown_relay_recipient_reject_code The response code when a client specifies a recipi- ent whose domain matches $relay_domains, while - $relay_recipient_maps is non-empty and does not + $relay_recipient_maps is non-empty and does not list the recipient address. unknown_virtual_alias_reject_code The response code when a client specifies a recipi- - ent whose domain matches $virtual_alias_domains, - while the recipient is not listed in $vir- + ent whose domain matches $virtual_alias_domains, + while the recipient is not listed in $vir- tual_alias_maps. unknown_virtual_mailbox_reject_code The response code when a client specifies a recipi- - ent whose domain matches $virtual_mailbox_domains, + ent whose domain matches $virtual_mailbox_domains, while the recipient is not listed in $virtual_mail- box_maps. Resource controls line_length_limit - Limit the amount of memory in bytes used for the + Limit the amount of memory in bytes used for the handling of partial input lines. message_size_limit @@ -226,8 +227,8 @@ SMTPD(8) SMTPD(8) ing on-disk storage for envelope information. queue_minfree - Minimal amount of free space in bytes in the queue - file system for the SMTP server to accept any mail + Minimal amount of free space in bytes in the queue + file system for the SMTP server to accept any mail at all. smtpd_history_flush_threshold @@ -242,23 +243,23 @@ SMTPD(8) SMTPD(8) smtpd_soft_error_limit When an SMTP client has made this number of errors, - wait error_count seconds before responding to any + wait error_count seconds before responding to any client request. smtpd_hard_error_limit - Disconnect after a client has made this number of + Disconnect after a client has made this number of errors. smtpd_junk_command_limit Limit the number of times a client can issue a junk - command such as NOOP, VRFY, ETRN or RSET in one - SMTP session before it is penalized with tarpit + command such as NOOP, VRFY, ETRN or RSET in one + SMTP session before it is penalized with tarpit delays. UCE control restrictions parent_domain_matches_subdomains - List of Postfix features that use domain.tld pat- - terns to match sub.domain.tld (as opposed to + List of Postfix features that use domain.tld pat- + terns to match sub.domain.tld (as opposed to requiring .domain.tld patterns). smtpd_client_restrictions @@ -266,19 +267,19 @@ SMTPD(8) SMTPD(8) tem. smtpd_helo_required - Require that clients introduce themselves at the + Require that clients introduce themselves at the beginning of an SMTP session. smtpd_helo_restrictions - Restrict what client hostnames are allowed in HELO + Restrict what client hostnames are allowed in HELO and EHLO commands. smtpd_sender_restrictions - Restrict what sender addresses are allowed in MAIL + Restrict what sender addresses are allowed in MAIL FROM commands. smtpd_recipient_restrictions - Restrict what recipient addresses are allowed in + Restrict what recipient addresses are allowed in RCPT TO commands. smtpd_etrn_restrictions @@ -286,73 +287,73 @@ SMTPD(8) SMTPD(8) mands, and what clients may issue ETRN commands. smtpd_data_restrictions - Restrictions on the DATA command. Currently, the - only restriction that makes sense here is + Restrictions on the DATA command. Currently, the + only restriction that makes sense here is reject_unauth_pipelining. allow_untrusted_routing - Allow untrusted clients to specify addresses with - sender-specified routing. Enabling this opens up - nasty relay loopholes involving trusted backup MX + Allow untrusted clients to specify addresses with + sender-specified routing. Enabling this opens up + nasty relay loopholes involving trusted backup MX hosts. smtpd_restriction_classes - Declares the name of zero or more parameters that - contain a list of UCE restrictions. The names of - these parameters can then be used instead of the + Declares the name of zero or more parameters that + contain a list of UCE restrictions. The names of + these parameters can then be used instead of the restriction lists that they represent. smtpd_null_access_lookup_key - The lookup key to be used in SMTPD access tables - instead of the null sender address. A null sender + The lookup key to be used in SMTPD access tables + instead of the null sender address. A null sender address cannot be looked up. maps_rbl_domains (deprecated) - List of DNS domains that publish the addresses of + List of DNS domains that publish the addresses of blacklisted hosts. This is used with the deprecated reject_maps_rbl restriction. permit_mx_backup_networks - Only domains whose primary MX hosts match the - listed networks are eligible for the per- + Only domains whose primary MX hosts match the + listed networks are eligible for the per- mit_mx_backup feature. relay_domains - Restrict what domains this mail system will relay - mail to. The domains are routed to the delivery + Restrict what domains this mail system will relay + mail to. The domains are routed to the delivery agent specified with the relay_transport setting. UCE control responses access_map_reject_code - Response code when a client violates an access + Response code when a client violates an access database restriction. default_rbl_reply Default template reply when a request is RBL black- - listed. This template is used by the reject_rbl_* - and reject_rhsbl_* restrictions. See also: + listed. This template is used by the reject_rbl_* + and reject_rhsbl_* restrictions. See also: rbl_reply_maps and smtpd_expansion_filter. defer_code - Response code when a client request is rejected by + Response code when a client request is rejected by the defer restriction. invalid_hostname_reject_code - Response code when a client violates the + Response code when a client violates the reject_invalid_hostname restriction. maps_rbl_reject_code Response code when a request is RBL blacklisted. rbl_reply_maps - Table with template responses for RBL blacklisted - requests, indexed by RBL domain name. These tem- + Table with template responses for RBL blacklisted + requests, indexed by RBL domain name. These tem- plates are used by the reject_rbl_* and - reject_rhsbl_* restrictions. See also: + reject_rhsbl_* restrictions. See also: default_rbl_reply and smtpd_expansion_filter. reject_code - Response code when the client matches a reject + Response code when the client matches a reject restriction. relay_domains_reject_code @@ -360,7 +361,7 @@ SMTPD(8) SMTPD(8) mail relay policy. unknown_address_reject_code - Response code when a client violates the + Response code when a client violates the reject_unknown_address restriction. unknown_client_reject_code @@ -369,7 +370,7 @@ SMTPD(8) SMTPD(8) tion. unknown_hostname_reject_code - Response code when a client violates the + Response code when a client violates the reject_unknown_hostname restriction. SEE ALSO @@ -379,7 +380,7 @@ SMTPD(8) SMTPD(8) syslogd(8) system logging LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/man/man5/pcre_table.5 b/postfix/man/man5/pcre_table.5 index de4fde8aa..83d44d96c 100644 --- a/postfix/man/man5/pcre_table.5 +++ b/postfix/man/man5/pcre_table.5 @@ -38,11 +38,10 @@ are lines whose first non-whitespace character is a `#'. A logical line starts with non-whitespace text. A line that starts with whitespace continues a logical line. .IP "\fBif /\fIpattern\fB/\fIflags\fR" -.IP "\fBif !/\fIpattern\fB/\fIflags\fR" .IP "\fBendif\fR" Match the search string against the patterns between \fBif\fR -and \fBendif\fR, if and only if the search string matches (does -not match) \fIpattern\fR. The \fBif\fR..\fBendif\fR can nest. +and \fBendif\fR, if and only if the search string matches +\fIpattern\fR. The \fBif\fR..\fBendif\fR can nest. .sp Note: do not prepend whitespace to patterns inside \fBif\fR..\fBendif\fR. diff --git a/postfix/man/man8/smtpd.8 b/postfix/man/man8/smtpd.8 index e15f7919c..f3aec5ca2 100644 --- a/postfix/man/man8/smtpd.8 +++ b/postfix/man/man8/smtpd.8 @@ -73,7 +73,7 @@ a configuration change. Disallow non-RFC 821 style addresses in SMTP commands. For example, the RFC822-style address forms with comments that Sendmail allows. .IP \fBbroken_sasl_auth_clients\fR -Support older Microsoft clients that mis-implement the AUTH +Support Microsoft clients that implement an older version of the AUTH protocol, and that expect an EHLO response of "250 AUTH=list" instead of "250 AUTH list". .IP \fBsmtpd_noop_commands\fR @@ -87,7 +87,7 @@ either bounces mail or re-injects the result back into Postfix. This parameter uses the same syntax as the right-hand side of a Postfix transport table. .SH "Authentication controls" -.IP \fBenable_sasl_authentication\fR +.IP \fBsmtpd_sasl_auth_enable\fR Enable per-session authentication as per RFC 2554 (SASL). This functionality is available only when explicitly selected at program build time and explicitly enabled at runtime. diff --git a/postfix/proto/pcre_table b/postfix/proto/pcre_table index 01a3b7b81..9120cd4a9 100644 --- a/postfix/proto/pcre_table +++ b/postfix/proto/pcre_table @@ -32,11 +32,10 @@ # A logical line starts with non-whitespace text. A line that # starts with whitespace continues a logical line. # .IP "\fBif /\fIpattern\fB/\fIflags\fR" -# .IP "\fBif !/\fIpattern\fB/\fIflags\fR" # .IP "\fBendif\fR" # Match the search string against the patterns between \fBif\fR -# and \fBendif\fR, if and only if the search string matches (does -# not match) \fIpattern\fR. The \fBif\fR..\fBendif\fR can nest. +# and \fBendif\fR, if and only if the search string matches +# \fIpattern\fR. The \fBif\fR..\fBendif\fR can nest. # .sp # Note: do not prepend whitespace to patterns inside # \fBif\fR..\fBendif\fR. diff --git a/postfix/src/bounce/Makefile.in b/postfix/src/bounce/Makefile.in index bd8451ea5..e7439d018 100644 --- a/postfix/src/bounce/Makefile.in +++ b/postfix/src/bounce/Makefile.in @@ -126,6 +126,7 @@ bounce_notify_util.o: ../../include/vstring.h bounce_notify_util.o: ../../include/vbuf.h 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/mail_queue.h bounce_notify_util.o: ../../include/quote_822_local.h bounce_notify_util.o: ../../include/quote_flags.h diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index e98fbe4b3..50982e690 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,10 +20,10 @@ * 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 "20030905" +#define MAIL_RELEASE_DATE "20030913" #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "2.0.15" +#define DEF_MAIL_VERSION "2.0.16" extern char *var_mail_version; /* diff --git a/postfix/src/lmtp/Makefile.in b/postfix/src/lmtp/Makefile.in index 41303b3bc..4b86772e8 100644 --- a/postfix/src/lmtp/Makefile.in +++ b/postfix/src/lmtp/Makefile.in @@ -130,6 +130,7 @@ lmtp_connect.o: ../../include/iostuff.h lmtp_connect.o: ../../include/timed_connect.h 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/attr.h diff --git a/postfix/src/lmtp/lmtp.c b/postfix/src/lmtp/lmtp.c index c17cc2123..9b1198f7a 100644 --- a/postfix/src/lmtp/lmtp.c +++ b/postfix/src/lmtp/lmtp.c @@ -337,6 +337,10 @@ static int deliver_message(DELIVER_REQUEST *request, char **unused_argv) lmtp_quit(state); lmtp_chat_reset(state); state->session = lmtp_session_free(state->session); +#ifdef USE_SASL_AUTH + if (var_lmtp_sasl_enable) + lmtp_sasl_cleanup(state); +#endif } /* @@ -346,6 +350,10 @@ static int deliver_message(DELIVER_REQUEST *request, char **unused_argv) else if (lmtp_rset(state) != 0) { lmtp_chat_reset(state); state->session = lmtp_session_free(state->session); +#ifdef USE_SASL_AUTH + if (var_lmtp_sasl_enable) + lmtp_sasl_cleanup(state); +#endif } /* @@ -380,6 +388,10 @@ static int deliver_message(DELIVER_REQUEST *request, char **unused_argv) */ else if (lmtp_lhlo(state) != 0) { state->session = lmtp_session_free(state->session); +#ifdef USE_SASL_AUTH + if (var_lmtp_sasl_enable) + lmtp_sasl_cleanup(state); +#endif } /* diff --git a/postfix/src/lmtp/lmtp.h b/postfix/src/lmtp/lmtp.h index 419cb38d5..2f9643970 100644 --- a/postfix/src/lmtp/lmtp.h +++ b/postfix/src/lmtp/lmtp.h @@ -53,7 +53,6 @@ typedef struct LMTP_STATE { sasl_callback_t *sasl_callbacks; /* stateful callbacks */ #endif int sndbufsize; /* total window size */ - int sndbuffree; /* remaining window */ int reuse; /* connection being reused */ } LMTP_STATE; diff --git a/postfix/src/lmtp/lmtp_connect.c b/postfix/src/lmtp/lmtp_connect.c index 63321e496..36c19246c 100644 --- a/postfix/src/lmtp/lmtp_connect.c +++ b/postfix/src/lmtp/lmtp_connect.c @@ -93,6 +93,7 @@ #include #include #include +#include /* Global library. */ @@ -221,7 +222,7 @@ static LMTP_SESSION *lmtp_connect_sock(int sock, struct sockaddr * sa, int len, non_blocking(sock, BLOCKING); errno = saved_errno; } else { - conn_stat = connect(sock, sa, len); + conn_stat = sane_connect(sock, sa, len); } if (conn_stat < 0) { vstring_sprintf(why, "connect to %s[%s]: %m", diff --git a/postfix/src/lmtp/lmtp_proto.c b/postfix/src/lmtp/lmtp_proto.c index 7f2b455ab..81f0e07ac 100644 --- a/postfix/src/lmtp/lmtp_proto.c +++ b/postfix/src/lmtp/lmtp_proto.c @@ -245,11 +245,6 @@ int lmtp_lhlo(LMTP_STATE *state) if (msg_verbose) msg_info("server features: 0x%x", state->features); -#ifdef USE_SASL_AUTH - if (var_lmtp_sasl_enable && (state->features & LMTP_FEATURE_AUTH)) - return (lmtp_sasl_helo_login(state)); -#endif - /* * We use LMTP command pipelining if the server said it supported it. * Since we use blocking I/O, RFC 2197 says that we should inspect the @@ -275,6 +270,11 @@ int lmtp_lhlo(LMTP_STATE *state) } else state->sndbufsize = 0; +#ifdef USE_SASL_AUTH + if (var_lmtp_sasl_enable && (state->features & LMTP_FEATURE_AUTH)) + return (lmtp_sasl_helo_login(state)); +#endif + return (0); } @@ -704,8 +704,8 @@ static int lmtp_loop(LMTP_STATE *state, int send_state, int recv_state) /* * Copy the next command to the buffer and update the sender state. */ - if (state->sndbuffree > 0) - state->sndbuffree -= VSTRING_LEN(next_command) + 2; + if (sndbuffree > 0) + sndbuffree -= VSTRING_LEN(next_command) + 2; lmtp_chat_cmd(state, "%s", vstring_str(next_command)); send_state = next_state; send_rcpt = next_rcpt; diff --git a/postfix/src/lmtp/lmtp_sasl_glue.c b/postfix/src/lmtp/lmtp_sasl_glue.c index 60e622fca..db4a778cf 100644 --- a/postfix/src/lmtp/lmtp_sasl_glue.c +++ b/postfix/src/lmtp/lmtp_sasl_glue.c @@ -36,7 +36,7 @@ /* authentication. /* /* lmtp_sasl_passwd_lookup() looks up the username/password -/* for the current SMTP server. The result is zero in case +/* for the current LMTP server. The result is zero in case /* of failure. /* /* lmtp_sasl_authenticate() implements the SASL authentication @@ -47,7 +47,7 @@ /* suceeds. /* /* lmtp_sasl_cleanup() cleans up. It must be called at the -/* end of every SMTP session that uses SASL authentication. +/* end of every LMTP session that uses SASL authentication. /* This routine is a noop for non-SASL sessions. /* /* Arguments: diff --git a/postfix/src/lmtp/lmtp_state.c b/postfix/src/lmtp/lmtp_state.c index 9f25f8149..f3cadc0b3 100644 --- a/postfix/src/lmtp/lmtp_state.c +++ b/postfix/src/lmtp/lmtp_state.c @@ -80,7 +80,6 @@ LMTP_STATE *lmtp_state_alloc(void) lmtp_sasl_connect(state); #endif state->sndbufsize = 0; - state->sndbuffree = 0; state->reuse = 0; return (state); } diff --git a/postfix/src/smtp/Makefile.in b/postfix/src/smtp/Makefile.in index 205767d76..d51009814 100644 --- a/postfix/src/smtp/Makefile.in +++ b/postfix/src/smtp/Makefile.in @@ -137,6 +137,7 @@ smtp_connect.o: ../../include/iostuff.h smtp_connect.o: ../../include/timed_connect.h 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/own_inet_addr.h smtp_connect.o: ../../include/dns.h diff --git a/postfix/src/smtp/smtp_connect.c b/postfix/src/smtp/smtp_connect.c index 35e9a5247..2fe78eec1 100644 --- a/postfix/src/smtp/smtp_connect.c +++ b/postfix/src/smtp/smtp_connect.c @@ -112,6 +112,7 @@ #include #include #include +#include /* Global library. */ @@ -208,7 +209,7 @@ static SMTP_SESSION *smtp_connect_addr(DNS_RR *addr, unsigned port, non_blocking(sock, BLOCKING); errno = saved_errno; } else { - conn_stat = connect(sock, (struct sockaddr *) & sin, sizeof(sin)); + conn_stat = sane_connect(sock, (struct sockaddr *) & sin, sizeof(sin)); } if (conn_stat < 0) { vstring_sprintf(why, "connect to %s[%s]: %m", diff --git a/postfix/src/smtpd/smtpd.c b/postfix/src/smtpd/smtpd.c index e1ff57398..4fd119471 100644 --- a/postfix/src/smtpd/smtpd.c +++ b/postfix/src/smtpd/smtpd.c @@ -59,7 +59,7 @@ /* Disallow non-RFC 821 style addresses in SMTP commands. For example, /* the RFC822-style address forms with comments that Sendmail allows. /* .IP \fBbroken_sasl_auth_clients\fR -/* Support older Microsoft clients that mis-implement the AUTH +/* Support Microsoft clients that implement an older version of the AUTH /* protocol, and that expect an EHLO response of "250 AUTH=list" /* instead of "250 AUTH list". /* .IP \fBsmtpd_noop_commands\fR @@ -73,7 +73,7 @@ /* This parameter uses the same syntax as the right-hand side of /* a Postfix transport table. /* .SH "Authentication controls" -/* .IP \fBenable_sasl_authentication\fR +/* .IP \fBsmtpd_sasl_auth_enable\fR /* Enable per-session authentication as per RFC 2554 (SASL). /* This functionality is available only when explicitly selected /* at program build time and explicitly enabled at runtime. @@ -1586,13 +1586,6 @@ static void smtpd_service(VSTREAM *stream, char *unused_service, char **argv) smtpd_state_init(&state, stream); msg_info("connect from %s[%s]", state.name, state.addr); - /* - * XXX non_blocking() aborts upon error. - */ -#ifdef BROKEN_READ_SELECT_ON_BLOCKING_SOCKET - non_blocking(vstream_fileno(stream), NON_BLOCKING); -#endif - /* * See if we need to turn on verbose logging for this client. */ diff --git a/postfix/src/smtpstone/Makefile.in b/postfix/src/smtpstone/Makefile.in index 186538bb6..c541cdbaa 100644 --- a/postfix/src/smtpstone/Makefile.in +++ b/postfix/src/smtpstone/Makefile.in @@ -103,6 +103,7 @@ qmqp-source.o: ../../include/mymalloc.h qmqp-source.o: ../../include/events.h qmqp-source.o: ../../include/find_inet.h qmqp-source.o: ../../include/netstring.h +qmqp-source.o: ../../include/sane_connect.h qmqp-source.o: ../../include/mail_date.h qmqp-source.o: ../../include/qmqp_proto.h smtp-sink.o: smtp-sink.c @@ -119,6 +120,7 @@ smtp-sink.o: ../../include/events.h smtp-sink.o: ../../include/mymalloc.h smtp-sink.o: ../../include/msg_vstream.h smtp-sink.o: ../../include/stringops.h +smtp-sink.o: ../../include/sane_accept.h smtp-sink.o: ../../include/smtp_stream.h smtp-source.o: smtp-source.c smtp-source.o: ../../include/sys_defs.h @@ -135,5 +137,6 @@ smtp-source.o: ../../include/iostuff.h smtp-source.o: ../../include/mymalloc.h smtp-source.o: ../../include/events.h smtp-source.o: ../../include/find_inet.h +smtp-source.o: ../../include/sane_connect.h smtp-source.o: ../../include/smtp_stream.h smtp-source.o: ../../include/mail_date.h diff --git a/postfix/src/smtpstone/qmqp-source.c b/postfix/src/smtpstone/qmqp-source.c index 66fd33854..3b7a572c2 100644 --- a/postfix/src/smtpstone/qmqp-source.c +++ b/postfix/src/smtpstone/qmqp-source.c @@ -83,6 +83,7 @@ #include #include #include +#include /* Global library. */ @@ -306,7 +307,7 @@ static void start_connect(SESSION *session) session->stream = vstream_fdopen(fd, O_RDWR); event_enable_write(fd, connect_done, (char *) session); netstring_setup(session->stream, var_timeout); - if (connect(fd, sa, sa_length) < 0 && errno != EINPROGRESS) + if (sane_connect(fd, sa, sa_length) < 0 && errno != EINPROGRESS) fail_connect(session); } diff --git a/postfix/src/smtpstone/smtp-sink.c b/postfix/src/smtpstone/smtp-sink.c index ac3fac7f5..552c40edd 100644 --- a/postfix/src/smtpstone/smtp-sink.c +++ b/postfix/src/smtpstone/smtp-sink.c @@ -98,6 +98,7 @@ #include #include #include +#include /* Global library. */ @@ -496,7 +497,7 @@ static void connect_event(int unused_event, char *context) SINK_STATE *state; int fd; - if ((fd = accept(sock, &sa, &len)) >= 0) { + if ((fd = sane_accept(sock, &sa, &len)) >= 0) { if (msg_verbose) msg_info("connect (%s)", #ifdef AF_LOCAL diff --git a/postfix/src/smtpstone/smtp-source.c b/postfix/src/smtpstone/smtp-source.c index 9eafa9a18..959c99337 100644 --- a/postfix/src/smtpstone/smtp-source.c +++ b/postfix/src/smtpstone/smtp-source.c @@ -103,6 +103,7 @@ #include #include #include +#include /* Global library. */ @@ -411,7 +412,7 @@ static void start_connect(SESSION *session) session->stream = vstream_fdopen(fd, O_RDWR); event_enable_write(fd, connect_done, (char *) session); smtp_timeout_setup(session->stream, var_timeout); - if (connect(fd, sa, sa_length) < 0 && errno != EINPROGRESS) + if (sane_connect(fd, sa, sa_length) < 0 && errno != EINPROGRESS) fail_connect(session); } diff --git a/postfix/src/util/Makefile.in b/postfix/src/util/Makefile.in index 98c0cf2d2..d1d841bb5 100644 --- a/postfix/src/util/Makefile.in +++ b/postfix/src/util/Makefile.in @@ -26,7 +26,7 @@ SRCS = alldig.c argv.c argv_split.c attr_print0.c attr_print64.c \ unix_connect.c unix_listen.c unix_trigger.c unsafe.c username.c \ valid_hostname.c vbuf.c vbuf_print.c vstream.c vstream_popen.c \ vstring.c vstring_vstream.c watchdog.c writable.c write_buf.c \ - write_wait.c strcasecmp.c nvtable.c host_port.c + write_wait.c strcasecmp.c nvtable.c host_port.c sane_connect.c OBJS = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \ attr_scan0.o attr_scan64.o base64_code.o basename.o binhash.o \ chroot_uid.o clean_env.o close_on_exec.o concatenate.o ctable.o \ @@ -54,7 +54,7 @@ OBJS = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \ unix_connect.o unix_listen.o unix_trigger.o unsafe.o username.o \ valid_hostname.o vbuf.o vbuf_print.o vstream.o vstream_popen.o \ vstring.o vstring_vstream.o watchdog.o writable.o write_buf.o \ - write_wait.o nvtable.o $(STRCASE) host_port.o + write_wait.o nvtable.o host_port.o sane_connect.o $(STRCASE) HDRS = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \ connect.h ctable.h dict.h dict_db.h dict_dbm.h dict_env.h \ dict_ht.h dict_ldap.h dict_mysql.h dict_ni.h dict_nis.h \ @@ -72,7 +72,7 @@ HDRS = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \ split_at.h stat_as.h stringops.h sys_defs.h timed_connect.h \ timed_wait.h trigger.h username.h valid_hostname.h vbuf.h \ vbuf_print.h vstream.h vstring.h vstring_vstream.h watchdog.h \ - nvtable.h host_port.h + nvtable.h host_port.h sane_connect.h TESTSRC = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \ stream_test.c dup2_pass_on_exec.c WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ @@ -808,6 +808,7 @@ inet_connect.o: msg.h inet_connect.o: find_inet.h inet_connect.o: inet_util.h inet_connect.o: iostuff.h +inet_connect.o: sane_connect.h inet_connect.o: connect.h inet_connect.o: timed_connect.h inet_listen.o: inet_listen.c @@ -919,6 +920,7 @@ msg_syslog.o: stringops.h msg_syslog.o: msg.h msg_syslog.o: msg_output.h msg_syslog.o: msg_syslog.h +msg_syslog.o: safe.h msg_vstream.o: msg_vstream.c msg_vstream.o: sys_defs.h msg_vstream.o: vstream.h @@ -1039,6 +1041,10 @@ sane_accept.o: sane_accept.c sane_accept.o: sys_defs.h sane_accept.o: msg.h sane_accept.o: sane_accept.h +sane_connect.o: sane_connect.c +sane_connect.o: sys_defs.h +sane_connect.o: msg.h +sane_connect.o: sane_connect.h sane_link.o: sane_link.c sane_link.o: sys_defs.h sane_link.o: msg.h @@ -1146,9 +1152,11 @@ timed_connect.o: timed_connect.c timed_connect.o: sys_defs.h timed_connect.o: msg.h timed_connect.o: iostuff.h +timed_connect.o: sane_connect.h timed_connect.o: timed_connect.h timed_read.o: timed_read.c timed_read.o: sys_defs.h +timed_read.o: msg.h timed_read.o: iostuff.h timed_wait.o: timed_wait.c timed_wait.o: sys_defs.h @@ -1157,6 +1165,7 @@ timed_wait.o: posix_signals.h timed_wait.o: timed_wait.h timed_write.o: timed_write.c timed_write.o: sys_defs.h +timed_write.o: msg.h timed_write.o: iostuff.h translit.o: translit.c translit.o: sys_defs.h @@ -1177,6 +1186,7 @@ unix_connect.o: unix_connect.c unix_connect.o: sys_defs.h unix_connect.o: msg.h unix_connect.o: iostuff.h +unix_connect.o: sane_connect.h unix_connect.o: connect.h unix_connect.o: timed_connect.h unix_listen.o: unix_listen.c diff --git a/postfix/src/util/inet_connect.c b/postfix/src/util/inet_connect.c index 152e49846..3c76734cd 100644 --- a/postfix/src/util/inet_connect.c +++ b/postfix/src/util/inet_connect.c @@ -63,6 +63,7 @@ #include "find_inet.h" #include "inet_util.h" #include "iostuff.h" +#include "sane_connect.h" #include "connect.h" #include "timed_connect.h" @@ -114,7 +115,7 @@ int inet_connect(const char *addr, int block_mode, int timeout) */ else { non_blocking(sock, block_mode); - if (connect(sock, (struct sockaddr *) & sin, sizeof(sin)) < 0 + if (sane_connect(sock, (struct sockaddr *) & sin, sizeof(sin)) < 0 && errno != EINPROGRESS) { close(sock); return (-1); diff --git a/postfix/src/util/inet_listen.c b/postfix/src/util/inet_listen.c index 91347c95a..2a846b39b 100644 --- a/postfix/src/util/inet_listen.c +++ b/postfix/src/util/inet_listen.c @@ -116,5 +116,8 @@ int inet_listen(const char *addr, int backlog, int block_mode) int inet_accept(int fd) { - return (sane_accept(fd, (struct sockaddr *) 0, (SOCKADDR_SIZE *) 0)); + struct sockaddr_in sin; + SOCKADDR_SIZE len = sizeof(sin); + + return (sane_accept(fd, (struct sockaddr *) & sin, &len)); } diff --git a/postfix/src/util/msg_syslog.c b/postfix/src/util/msg_syslog.c index fb9301457..5af7cb950 100644 --- a/postfix/src/util/msg_syslog.c +++ b/postfix/src/util/msg_syslog.c @@ -49,6 +49,7 @@ #include #include #include +#include /* Application-specific. */ @@ -57,6 +58,7 @@ #include "msg.h" #include "msg_output.h" #include "msg_syslog.h" +#include "safe.h" /* * Stay a little below the 2048-byte limit of older syslog() @@ -167,6 +169,13 @@ void msg_syslog_init(const char *name, int logopt, int facility) { static int first_call = 1; + /* + * XXX If this program is set-gid, then TZ must not be trusted. + * This scrubbing code is in the wrong place. + */ + if (unsafe()) + putenv("TZ="); + tzset(); openlog(name, LOG_NDELAY | logopt, facility); if (first_call) { first_call = 0; diff --git a/postfix/src/util/sane_accept.c b/postfix/src/util/sane_accept.c index a28e5bf93..30a3d8533 100644 --- a/postfix/src/util/sane_accept.c +++ b/postfix/src/util/sane_accept.c @@ -13,6 +13,9 @@ /* DESCRIPTION /* sane_accept() implements the accept(2) socket call, and maps /* known harmless error results to EAGAIN. +/* +/* If the buf and len arguments are not null, then additional +/* workarounds may be enabled that depend on the socket type. /* BUGS /* Bizarre systems may have other harmless error results. Such /* systems encourage programers to ignore error results, and @@ -89,5 +92,21 @@ int sane_accept(int sock, struct sockaddr * sa, SOCKADDR_SIZE *len) } } } + + /* + * XXX Solaris select() produces false read events, so that read() blocks + * forever on a blocking socket, and fails with EAGAIN on a non-blocking + * socket. Turning on keepalives will fix a blocking socket provided that + * the kernel's keepalive timer expires before the Postfix watchdog + * timer. + */ +#if defined(BROKEN_READ_SELECT_ON_TCP_SOCKET) && defined(SO_KEEPALIVE) + else if (sa != 0 && sa->sa_family == AF_INET) { + int on = 1; + + (void) setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, + (char *) &on, sizeof(on)); + } +#endif return (fd); } diff --git a/postfix/src/util/sane_connect.c b/postfix/src/util/sane_connect.c new file mode 100644 index 000000000..cdb2874bc --- /dev/null +++ b/postfix/src/util/sane_connect.c @@ -0,0 +1,63 @@ +/*++ +/* NAME +/* sane_connect 3 +/* SUMMARY +/* sanitize connect() results +/* SYNOPSIS +/* #include +/* +/* int sane_connect(sock, buf, len) +/* int sock; +/* struct sockaddr *buf; +/* SOCKADDR_SIZE *len; +/* DESCRIPTION +/* sane_connect() implements the accept(2) socket call, and maps +/* known harmless error results to EAGAIN. +/* BUGS +/* Bizarre systems may have other harmless error results. Such +/* systems encourage programers to ignore error results, and +/* penalizes programmers who code defensively. +/* 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 +#include + +/* Utility library. */ + +#include "msg.h" +#include "sane_connect.h" + +/* sane_connect - sanitize connect() results */ + +int sane_connect(int sock, struct sockaddr * sa, SOCKADDR_SIZE len) +{ + + /* + * XXX Solaris select() produces false read events, so that read() blocks + * forever on a blocking socket, and fails with EAGAIN on a non-blocking + * socket. Turning on keepalives will fix a blocking socket provided that + * the kernel's keepalive timer expires before the Postfix watchdog + * timer. + */ +#if defined(BROKEN_READ_SELECT_ON_TCP_SOCKET) && defined(SO_KEEPALIVE) + if (sa->sa_family == AF_INET) { + int on = 1; + + (void) setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, + (char *) &on, sizeof(on)); + } +#endif + return (connect(sock, sa, len)); +} diff --git a/postfix/src/util/sane_connect.h b/postfix/src/util/sane_connect.h new file mode 100644 index 000000000..1f023b0e6 --- /dev/null +++ b/postfix/src/util/sane_connect.h @@ -0,0 +1,29 @@ +#ifndef _SANE_CONNECT_H_ +#define _SANE_CONNECT_H_ + +/*++ +/* NAME +/* sane_connect 3h +/* SUMMARY +/* sanitize connect() results +/* SYNOPSIS +/* #include +/* DESCRIPTION +/* .nf + + /* External interface. */ + +extern int sane_connect(int, struct sockaddr *, SOCKADDR_SIZE); + +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +#endif diff --git a/postfix/src/util/sys_defs.h b/postfix/src/util/sys_defs.h index 739818adf..ea568a132 100644 --- a/postfix/src/util/sys_defs.h +++ b/postfix/src/util/sys_defs.h @@ -261,7 +261,7 @@ extern int opterr; #define LOCAL_CONNECT stream_connect #define LOCAL_TRIGGER stream_trigger #define HAS_VOLATILE_LOCKS -#define BROKEN_READ_SELECT_ON_BLOCKING_SOCKET +#define BROKEN_READ_SELECT_ON_TCP_SOCKET /* * Allow build environment to override paths. */ diff --git a/postfix/src/util/timed_connect.c b/postfix/src/util/timed_connect.c index c40fe3e63..ee4e150b1 100644 --- a/postfix/src/util/timed_connect.c +++ b/postfix/src/util/timed_connect.c @@ -59,6 +59,7 @@ #include "msg.h" #include "iostuff.h" +#include "sane_connect.h" #include "timed_connect.h" /* timed_connect - connect with deadline */ @@ -78,7 +79,7 @@ int timed_connect(int sock, struct sockaddr * sa, int len, int timeout) /* * Start the connection, and handle all possible results. */ - if (connect(sock, sa, len) == 0) + if (sane_connect(sock, sa, len) == 0) return (0); if (errno != EINPROGRESS) return (-1); diff --git a/postfix/src/util/unix_connect.c b/postfix/src/util/unix_connect.c index 0890f7e1c..5ae452543 100644 --- a/postfix/src/util/unix_connect.c +++ b/postfix/src/util/unix_connect.c @@ -50,6 +50,7 @@ #include "msg.h" #include "iostuff.h" +#include "sane_connect.h" #include "connect.h" #include "timed_connect.h" @@ -99,7 +100,7 @@ int unix_connect(const char *addr, int block_mode, int timeout) */ else { non_blocking(sock, block_mode); - if (connect(sock, (struct sockaddr *) & sun, sizeof(sun)) < 0 + if (sane_connect(sock, (struct sockaddr *) & sun, sizeof(sun)) < 0 && errno != EINPROGRESS) { close(sock); return (-1);