Postfix 2.2 patch 09 hardens the TLS implementation and eliminates some anomalies from the TLS per-site policy engine. See the TLS_README document for tips on how to avoid DNS-based attacks that can change the server hostname that Postfix uses for logging, for TLS per-site policies, and for server certificate verification. The patch also adds a workaround that prevents Postfix from repeatedly trying to deliver mail to domains with a malformed MX record (for example, a null MX hostname). Such mail now bounces immediately. This material is basically a lot of back-ported fixes from the Postfix 2.3 development branch. diff -cr /var/tmp/postfix-2.2.8/src/global/mail_version.h ./src/global/mail_version.h *** /var/tmp/postfix-2.2.8/src/global/mail_version.h Tue Jan 3 16:42:48 2006 --- ./src/global/mail_version.h Tue Feb 21 14:27:49 2006 *************** *** 20,27 **** * Patches change the patchlevel and the release date. Snapshots change the * release date only. */ ! #define MAIL_RELEASE_DATE "20060103" ! #define MAIL_VERSION_NUMBER "2.2.8" #define VAR_MAIL_VERSION "mail_version" #ifdef SNAPSHOT --- 20,27 ---- * Patches change the patchlevel and the release date. Snapshots change the * release date only. */ ! #define MAIL_RELEASE_DATE "20060221" ! #define MAIL_VERSION_NUMBER "2.2.9" #define VAR_MAIL_VERSION "mail_version" #ifdef SNAPSHOT diff -cr /var/tmp/postfix-2.2.8/HISTORY ./HISTORY *** /var/tmp/postfix-2.2.8/HISTORY Tue Jan 3 21:20:04 2006 --- ./HISTORY Tue Feb 21 16:24:32 2006 *************** *** 10794,10796 **** --- 10794,10874 ---- Portability: FreeBSD 6 is a supported platform. Files: util/sys_defs.h, makedefs. + + 20010604 + + Safety: new "smtp_cname_overrides_servername" parameter. + The default value ("yes") is backwards compatible. + + With a value of "no", the Postfix SMTP client no longer + allows CNAME expansion to override the hostname that is + used for logging, SASL password lookup, TLS policy decisions, + or TLS certificate verification. Instead it uses the name + of the recipient domain, the host or domain name specified + in Postfix configuration files, or the hostnames obtained + with MX lookups. To prevent cheating with hostnames in MX + lookup results, you will have to suppress MX lookups with + explicit [hostname] entries in transport maps. Files: + dns/dns_lookup.c, dns/dns_rr.c, proto/postconf.proto. + + 20060108 + + Bugfix: mailbox_command_maps was not subject to $name + expansion. File: local/local.c. + + 20060115 + + Bugfix: don't ignore the per-site policy when SSL library + initialization fails. Introduced after adopting the TLS + patch. File: smtp/smtp_session.c. + + 20060121 + + Bugfix: a TLS per-site MUST_NOPEERMATCH policy could not + override a stronger main.cf policy, while a per-site NONE + policy could. Fixed with a clean re-implementation from + Postfix 2.3. File: smtp/smtp_session.c. + + Bugfix: a combined TLS per-site (host, recipient) policy + of (NONE, MAY) changed a global MUST policy into NONE, and + a global MUST_NOPEERMATCH into MAY. The result is now NONE. + Problem found by exhaustive simulation. Fixed with a clean + re-implementation from Postfix 2.3. File: smtp/smtp_session.c. + + 20060130 + + Bugfix: an empty remote_header_rewrite_domain value caused + trivial-rewrite to dereference a null pointer, but only in + regression tests, not in production. Postfix rewrites + addresses in the remote rewriting context only when the + remote_header_rewrite_domain parameter value is non-empty. + File: trivial-rewrite/rewrite.c. + + 20060202 + + Workaround: a malformed domain name lookup result (such as + null MX record) is now treated as a hard error, so that + Postfix will no longer repeatedly try to deliver mail until + the message expires in the queue. However, this will not + reject mail with reject_unknown_sender/recipient_domain. + That would require too much change for a stable release. + File: dns/dns_lookup.c. + + 20060203 + + Bugfix: smtpd core dump when SASL is compiled in, turned + off (smtpd_sasl_auth_enable = no) and permit_sasl_authenticated + is specified in local_header_rewrite_clients. Victor Duchovni. + File: smtpd/smtpd_check.c. + + 20060204 + + Bugfix: disable the content_filter feature for user-requested + "sendmail -bv" probes, just like it is disabled for probes + generated by Postfix itself. File: *qmgr/qmgr_message.c. + + 20060212 + + Workaround: don't consume in_flow tokens when incoming mail + is placed on hold. Back-ported from Postfix 2.3. File: + cleanup/cleanup_api.c. diff -cr /var/tmp/postfix-2.2.8/README_FILES/SCHEDULER_README ./README_FILES/SCHEDULER_README *** /var/tmp/postfix-2.2.8/README_FILES/SCHEDULER_README Thu Apr 15 10:41:47 2004 --- ./README_FILES/SCHEDULER_README Thu Feb 16 11:44:25 2006 *************** *** 43,49 **** know that oqmgr(8) uses round-robin by destination while qmgr(8) uses simple FIFO, except for some preemptive magic. The postconf(5) manual documents all the knobs the user can use to control this preemptive magic - there is nothing ! else to the preemption than the quite simple conditions described below. As for programmer-level documentation, this will have to be extracted from all those emails we have exchanged with Wietse [rats! I hoped that Patrik would do --- 43,49 ---- know that oqmgr(8) uses round-robin by destination while qmgr(8) uses simple FIFO, except for some preemptive magic. The postconf(5) manual documents all the knobs the user can use to control this preemptive magic - there is nothing ! else to the preemption than the quite simple conditions described in there. As for programmer-level documentation, this will have to be extracted from all those emails we have exchanged with Wietse [rats! I hoped that Patrik would do diff -cr /var/tmp/postfix-2.2.8/README_FILES/TLS_README ./README_FILES/TLS_README *** /var/tmp/postfix-2.2.8/README_FILES/TLS_README Sat Oct 29 18:34:25 2005 --- ./README_FILES/TLS_README Fri Feb 17 15:11:48 2006 *************** *** 68,73 **** --- 68,78 ---- with the necessary definitions. This is done by invoking the command "make makefiles" in the Postfix top-level directory and with arguments as shown next. + NNOOTTEE:: DDoo nnoott uussee GGnnuu TTLLSS.. IItt wwiillll ssppoonnttaanneeoouussllyy tteerrmmiinnaattee aa PPoossttffiixx ddaaeemmoonn + pprroocceessss wwiitthh eexxiitt ssttaattuuss ccooddee 22,, iinnsstteeaadd ooff aalllloowwiinngg PPoossttffiixx ttoo 11)) rreeppoorrtt tthhee + eerrrroorr ttoo tthhee mmaaiilllloogg ffiillee,, aanndd ttoo 22)) pprroovviiddee ppllaaiinntteexxtt sseerrvviiccee wwhheerree tthhiiss iiss + aapppprroopprriiaattee.. + * If the OpenSSL include files (such as ssl.h) are in directory /usr/include/ openssl, and the OpenSSL libraries (such as libssl.so and libcrypto.so) are in directory /usr/lib: *************** *** 364,370 **** You can specify any database type that can store objects of several kbytes and that supports the sequence operator. DBM databases are not suitable because they can only store small objects. The cache is maintained by the tlsmgr(8) ! process, so there is no problem with concurrent access. Example: --- 369,377 ---- You can specify any database type that can store objects of several kbytes and that supports the sequence operator. DBM databases are not suitable because they can only store small objects. The cache is maintained by the tlsmgr(8) ! process, so there is no problem with concurrent access. Session caching is ! highly recommended, because the cost of repeatedly negotiating TLS session keys ! is high. Example: *************** *** 420,426 **** ... The Postfix list manipulation routines give special treatment to whitespace and ! some other characters, making the use of certificate names unpractical. Instead we use the certificate fingerprints as they are difficult to fake but easy to use for lookup. Postfix lookup tables are in the form of (key, value) pairs. Since we only need the key, the value can be chosen freely, e.g. the name of --- 427,433 ---- ... The Postfix list manipulation routines give special treatment to whitespace and ! some other characters, making the use of certificate names impractical. Instead we use the certificate fingerprints as they are difficult to fake but easy to use for lookup. Postfix lookup tables are in the form of (key, value) pairs. Since we only need the key, the value can be chosen freely, e.g. the name of *************** *** 485,491 **** * Client-side TLS activity logging * Client-side TLS session cache * Enabling TLS in the Postfix SMTP client ! * Server certificate verification * Client-side cipher controls * Miscellaneous client controls --- 492,503 ---- * Client-side TLS activity logging * Client-side TLS session cache * Enabling TLS in the Postfix SMTP client ! * Requiring TLS encryption ! * Disabling server certificate verification ! * Per-site TLS policies ! * Closing a DNS loophole with per-site TLS policies ! * Discovering servers that support TLS ! * Server certificate verification depth * Client-side cipher controls * Miscellaneous client controls *************** *** 530,541 **** issued by these CAs, append the root certificate to $smtp_tls_CAfile or install it in the $smtp_tls_CApath directory. When you configure trust in a root CA, it is not necessary to explicitly trust intermediary CAs signed by the root CA, ! unless $smtp_tls_verify_depth is less than the number of CAs in the certificate ! chain for the servers of interest. With a verify depth of 1 you can only verify ! certificates directly signed by a trusted CA, and all trusted intermediary CAs ! need to be configured explicitly. With a verify depth of 2 you can verify ! servers signed by a root CA or a direct intermediary CA (so long as the server ! is correctly configured to supply its intermediate CA certificate). RSA key and certificate examples: --- 542,553 ---- issued by these CAs, append the root certificate to $smtp_tls_CAfile or install it in the $smtp_tls_CApath directory. When you configure trust in a root CA, it is not necessary to explicitly trust intermediary CAs signed by the root CA, ! unless $smtp_tls_scert_verifydepth is less than the number of CAs in the ! certificate chain for the servers of interest. With a verify depth of 1 you can ! only verify certificates directly signed by a trusted CA, and all trusted ! intermediary CAs need to be configured explicitly. With a verify depth of 2 you ! can verify servers signed by a root CA or a direct intermediary CA (so long as ! the server is correctly configured to supply its intermediate CA certificate). RSA key and certificate examples: *************** *** 608,614 **** can specify any database type that can store objects of several kbytes and that supports the sequence operator. DBM databases are not suitable because they can only store small objects. The cache is maintained by the tlsmgr(8) process, so ! there is no problem with concurrent access. Example: --- 620,629 ---- can specify any database type that can store objects of several kbytes and that supports the sequence operator. DBM databases are not suitable because they can only store small objects. The cache is maintained by the tlsmgr(8) process, so ! there is no problem with concurrent access. Session caching is highly ! recommended, because the cost of repeatedly negotiating TLS session keys is ! high. Future Postfix SMTP servers may limit the number of sessions that a ! client is allowed to negotiate per unit time. Example: *************** *** 630,649 **** plain Postfix is visible. If you enable TLS, the Postfix SMTP client will send STARTTLS when TLS support is announced by the remote SMTP server. ! WARNING: MS Exchange servers will announce STARTTLS support even when the ! service is not configured, so that the TLS handshake will fail. It may be wise ! to not use this option on your central mail hub, as you don't know in advance ! whether you are going to connect to such a host. Instead, use the ! smtp_tls_per_site recipient/site specific options that are described below. ! ! When the TLS handshake fails and no other server is available, the Postfix SMTP ! client defers the delivery attempt, and the mail stays in the queue. Example: /etc/postfix/main.cf: smtp_use_tls = yes You can ENFORCE the use of TLS, so that the Postfix SMTP client will not deliver mail over unencrypted connections. In this mode, the remote SMTP server hostname must match the information in the remote server certificate, and the --- 645,663 ---- plain Postfix is visible. If you enable TLS, the Postfix SMTP client will send STARTTLS when TLS support is announced by the remote SMTP server. ! When the server accepts the STARTTLS command, but the subsequent TLS handshake ! fails, and no other server is available, the Postfix SMTP client defers the ! delivery attempt, and the mail stays in the queue. After a handshake failure, ! the communications channel is in an indeterminate state and cannot be used for ! non-TLS deliveries. Example: /etc/postfix/main.cf: smtp_use_tls = yes + RReeqquuiirriinngg TTLLSS eennccrryyppttiioonn + You can ENFORCE the use of TLS, so that the Postfix SMTP client will not deliver mail over unencrypted connections. In this mode, the remote SMTP server hostname must match the information in the remote server certificate, and the *************** *** 652,672 **** server hostname doesn't match, and no other server is available, the delivery attempt is deferred and the mail stays in the queue. ! The remote SMTP server hostname used in the check is beyond question, as it ! must be the principal hostname (no CNAME allowed here). Checks are performed ! against all names provided as dNSNames in the SubjectAlternativeName. If no ! dNSNames are specified, the CommonName is checked. The behavior may be changed ! with the smtp_tls_enforce_peername option which is discussed below. ! ! This option is useful only if you know that you will only connect to servers ! that support RFC 2487 _and_ that present server certificates that meet the ! above requirements. An example would be a client only sends email to one specific mailhub that offers the necessary STARTTLS support. Example: /etc/postfix/main.cf: ! smtp_enforce_tls = no As of RFC 2487 the requirements for hostname checking for MTA clients are not set. When TLS is required (smtp_enforce_tls = yes), the option --- 666,687 ---- server hostname doesn't match, and no other server is available, the delivery attempt is deferred and the mail stays in the queue. ! The remote SMTP server hostname is verified against all names provided as ! dNSNames in the SubjectAlternativeName. If no dNSNames are specified, the ! CommonName is checked. Verification may be turned off with the ! smtp_tls_enforce_peername option which is discussed below. ! ! Enforcing the use of TLS is useful if you know that you will only connect to ! servers that support RFC 2487 _and_ that present server certificates that meet ! the above requirements. An example would be a client only sends email to one specific mailhub that offers the necessary STARTTLS support. Example: /etc/postfix/main.cf: ! smtp_enforce_tls = yes ! ! DDiissaabblliinngg sseerrvveerr cceerrttiiffiiccaattee vveerriiffiiccaattiioonn As of RFC 2487 the requirements for hostname checking for MTA clients are not set. When TLS is required (smtp_enforce_tls = yes), the option *************** *** 674,752 **** server hostname checking. In this case, the mail delivery will proceed regardless of the CommonName etc. listed in the certificate. ! Note: the smtp_tls_enforce_peername setting has no effect on sessions that are ! controlled via the smtp_tls_per_site table. ! ! Disabling the remote SMTP server hostname verification can make sense in closed ! environment where special CAs are created. If not used carefully, this option ! opens the danger of a "man-in-the-middle" attack (the CommonName of this ! possible attacker is logged). Example: /etc/postfix/main.cf: ! smtp_tls_enforce_peername = yes ! ! Generally, trying TLS can be a bad idea, as some servers offer STARTTLS but the ! negotiation will fail leading to unexplainable failures. Instead, it may be a ! good idea to choose the TLS usage policy based on the recipient or the mailhub ! to which you are connecting. ! ! Deciding the TLS usage policy per recipient may be difficult, since a single ! email delivery attempt can involve several recipients. Instead, use of TLS is ! controlled by the Postfix next-hop destination domain name and by the remote ! SMTP server hostname. If either of these matches an entry in the ! smtp_tls_per_site table, appropriate action is taken. ! ! The remote SMTP server hostname is simply the DNS name of the server that the ! Postfix SMTP client connects to. The next-hop destination is Postfix specific. ! By default, this is the domain name in the recipient address, but this ! information can be overruled by the transport(5) table or by the relayhost ! parameter setting. In these cases the relayhost etc. must be listed in the ! smtp_tls_per_site table, instead of the recipient domain name. ! ! Format of the table: domain or host names are specified on the left-hand side; ! no wildcards are allowed. On the right hand side specify one of the following ! keywords: NONE ! Don't use TLS at all. MAY ! Try to use STARTTLS if offered, otherwise use the unencrypted ! connection. MUST ! Require usage of STARTTLS, require that the remote SMTP server hostname matches the information in the remote SMTP server certificate, and require that the remote SMTP server certificate was issued by a trusted ! CA. ! MUST_NOPEERMATCH ! Require usage of STARTTLS, but do not require that the remote SMTP ! server hostname matches the information in the remote SMTP server ! certificate, or that the server certificate was issued by a trusted CA. ! ! The actual TLS usage policy depends not only on whether the next-hop ! destination or remote SMTP server hostname are found in the smtp_tls_per_site ! table, but also on the smtp_enforce_tls setting: ! ! * If no match was found, the policy is applied as specified with ! smtp_enforce_tls. ! ! * If a match was found, and the smtp_enforce_tls policy is "enforce", NONE ! explicitly switches it off; otherwise the "enforce" mode is used even for ! entries that specify MAY. ! ! Special hint for TLS enforcement mode: since no secure DNS lookup mechanism is ! available, mail can be delivered to the wrong remote SMTP server. This is not ! prevented by specifying MUST for the next-hop domain name. The recommended ! setup is: specify local transport(5) table entries for sensitive domains with ! explicit smtp:[mailhost] destinations (since you can assure security of this ! table unlike DNS), then specify MUST for these mail hosts in the ! smtp_tls_per_site table. Example: /etc/postfix/main.cf: smtp_tls_per_site = hash:/etc/postfix/tls_per_site As we decide on a "per site" basis whether or not to use TLS, it would be good to have a list of sites that offered "STARTTLS". We can collect it ourselves --- 689,828 ---- server hostname checking. In this case, the mail delivery will proceed regardless of the CommonName etc. listed in the certificate. ! Despite the potential for eliminating "man-in-the-middle" and other attacks, ! mandatory certificate/peername verification is not viable as a default Internet ! mail delivery policy at this time. A significant fraction of TLS enabled MTAs ! uses self-signed certificates, or certificates that are signed by a private ! certificate authority. On a machine that delivers mail to the Internet, if you ! set smtp_enforce_tls = yes, you should probably also set ! smtp_tls_enforce_peername = no. You can use the per-site TLS policies (see ! below) to enable full peer verification for specific destinations that are ! known to have verifiable TLS server certificates. Example: /etc/postfix/main.cf: ! smtp_enforce_tls = yes ! smtp_tls_enforce_peername = no ! ! PPeerr--ssiittee TTLLSS ppoolliicciieess ! ! A small fraction of servers offer STARTTLS but the negotiation consistently ! fails, leading to mail aging out of the queue and bouncing back to the sender. ! In such cases, you can use the per-site policies to disable TLS for the problem ! sites. Alternatively, you can enable TLS for just a few specific sites and not ! enable it for all sites. ! ! The smtp_tls_per_site table is searched for a policy that matches the following ! information: ! ! remote SMTP server hostname ! This is simply the DNS name of the server that the Postfix SMTP client ! connects to; this name may be obtained from other DNS lookups, such as ! MX lookups or CNAME lookups. ! next-hop destination ! This is normally the domain portion of the recipient address, but it ! may be overruled by information from the transport(5) table, from the ! relayhost parameter setting, or from the relay_transport setting. When ! it's not the recipient domain, the next-hop destination can have the ! Postfix-specific form "[name]", [name]:port", "name" or "name:port". ! ! When both the hostname lookup and the next-hop lookup succeed, the host policy ! does not automatically override the next-hop policy. Instead, precedence is ! given to either the more specific or the more secure per-site policy as ! described below. ! ! The smtp_tls_per_site table uses a simple "name whitespace value" format. ! Specify host names or next-hop destinations on the left-hand side; no wildcards ! are allowed. On the right hand side specify one of the following keywords: NONE ! Don't use TLS at all. This overrides a less specific MMAAYY lookup result ! from the alternate host or next-hop lookup key, and overrides the ! global smtp_use_tls, smtp_enforce_tls, and smtp_tls_enforce_peername ! settings. MAY ! Try to use TLS if the server announces support, otherwise use the ! unencrypted connection. This has less precedence than a more specific ! result (including NNOONNEE) from the alternate host or next-hop lookup key, ! and has less precedence than the more specific global "smtp_enforce_tls ! = yes" or "smtp_tls_enforce_peername = yes". ! MUST_NOPEERMATCH ! Require TLS encryption, but do not require that the remote SMTP server ! hostname matches the information in the remote SMTP server certificate, ! or that the server certificate was issued by a trusted CA. This ! overrides a less secure NNOONNEE or a less specific MMAAYY lookup result from ! the alternate host or next-hop lookup key, and overrides the global ! smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername settings. MUST ! Require TLS encryption, require that the remote SMTP server hostname matches the information in the remote SMTP server certificate, and require that the remote SMTP server certificate was issued by a trusted ! CA. This overrides a less secure NNOONNEE and MMUUSSTT__NNOOPPEEEERRMMAATTCCHH or a less ! specific MMAAYY lookup result from the alternate host or next-hop lookup ! key, and overrides the global smtp_use_tls, smtp_enforce_tls and ! smtp_tls_enforce_peername settings. ! ! The precedences between global (main.cf) and per-site TLS policies can be ! summarized as follows: ! ! * When neither the remote SMTP server hostname nor the next-hop destination ! are found in the smtp_tls_per_site table, the policy is based on ! smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername. Note: ! "smtp_enforce_tls = yes" and "smtp_tls_enforce_peername = yes" imply ! "smtp_use_tls = yes". ! ! * When both hostname and next-hop destination lookups produce a result, the ! more specific per-site policy (NONE, MUST, etc) overrides the less specific ! one (MAY), and the more secure per-site policy (MUST, etc) overrides the ! less secure one (NONE). ! ! * After the per-site policy lookups are combined, the result generally ! overrides the global policy. The exception is the less specific MMAAYY per- ! site policy, which is overruled by the more specific global ! "smtp_enforce_tls = yes" with server certificate verification as specified ! with the smtp_tls_enforce_peername parameter. ! ! CClloossiinngg aa DDNNSS lloooopphhoollee wwiitthh ppeerr--ssiittee TTLLSS ppoolliicciieess ! ! As long as no secure DNS lookup mechanism is available, false hostnames in MX ! or CNAME responses can change the server hostname that Postfix uses for TLS ! policy lookup and server certificate verification. Even with a perfect match ! between the server hostname and the server certificate, there is no guarantee ! that Postfix is connected to the right server. To avoid this loophole take the ! following steps: ! ! * Eliminate MX lookups. Specify local transport(5) table entries for ! sensitive domains with explicit smtp:[mailhost] or smtp:[mailhost]:port ! destinations (you can assure security of this table unlike DNS); in the ! smtp_tls_per_site table specify the value MMUUSSTT for the key [mailhost] or ! smtp:[mailhost]:port. This prevents false hostname information in DNS MX ! records from changing the server hostname that Postfix uses for TLS policy ! lookup and server certificate verification. ! ! * Disallow CNAME hostname overrides. In main.cf specify ! "smtp_cname_overrides_servername = no". This prevents false hostname ! information in DNS CNAME records from changing the server hostname that ! Postfix uses for TLS policy lookup and server certificate verification. ! This feature requires Postfix 2.2.9 or later. Example: /etc/postfix/main.cf: smtp_tls_per_site = hash:/etc/postfix/tls_per_site + relayhost = [msa.example.net]:587 + + /etc/postfix/tls_per_site: + # relayhost exact nexthop match + [msa.example.net]:587 MUST + + # TLS should not be used with the example.org MX hosts. + example.org NONE + + # TLS should not be used with the host smtp.example.com. + smtp.example.com NONE + + DDiissccoovveerriinngg sseerrvveerrss tthhaatt ssuuppppoorrtt TTLLSS As we decide on a "per site" basis whether or not to use TLS, it would be good to have a list of sites that offered "STARTTLS". We can collect it ourselves *************** *** 763,769 **** /etc/postfix/main.cf: smtp_tls_note_starttls_offer = yes ! SSeerrvveerr cceerrttiiffiiccaattee vveerriiffiiccaattiioonn When verifying a remote SMTP server certificate, a verification depth of 1 is sufficient if the certificate is directly issued by a CA specified with --- 839,845 ---- /etc/postfix/main.cf: smtp_tls_note_starttls_offer = yes ! SSeerrvveerr cceerrttiiffiiccaattee vveerriiffiiccaattiioonn ddeepptthh When verifying a remote SMTP server certificate, a verification depth of 1 is sufficient if the certificate is directly issued by a CA specified with *************** *** 1012,1021 **** --- 1088,1112 ---- and in order to access the TLS session cache databases. Such a protocol cannot be run across fifos. + * smtp_tls_per_site: the MUST_NOPEERMATCH per-site policy cannot override the + global "smtp_tls_enforce_peername = yes" setting. + + * smtp_tls_per_site: a combined (NONE + MAY) lookup result for (hostname and + next-hop destination) produces counter-intuitive results for different + main.cf settings. TLS is enabled with "smtp_tls_enforce_peername = no", but + it is disabled when both "smtp_enforce_tls = yes" and + "smtp_tls_enforce_peername = yes". + + The smtp_tls_per_site limitations were removed by the end of the Postfix 2.2 + support cycle. + CCrreeddiittss * TLS support for Postfix was originally developed by Lutz Jänicke at Cottbus Technical University. * Wietse Venema adopted the code, did some restructuring, and compiled this part of the documentation from Lutz's documents. + * Victor Duchovni was instrumental with the re-implementation of the + smtp_tls_per_site code in terms of enforcement levels, which simplified the + implementation greatly. diff -cr /var/tmp/postfix-2.2.8/html/SCHEDULER_README.html ./html/SCHEDULER_README.html *** /var/tmp/postfix-2.2.8/html/SCHEDULER_README.html Tue Feb 22 09:05:37 2005 --- ./html/SCHEDULER_README.html Thu Feb 16 11:44:24 2006 *************** *** 68,74 **** while qmgr(8) uses simple FIFO, except for some preemptive magic. The postconf(5) manual documents all the knobs the user can use to control this preemptive magic - there is nothing else ! to the preemption than the quite simple conditions described below.

As for programmer-level documentation, this will have to be --- 68,74 ---- while qmgr(8) uses simple FIFO, except for some preemptive magic. The postconf(5) manual documents all the knobs the user can use to control this preemptive magic - there is nothing else ! to the preemption than the quite simple conditions described in there.

As for programmer-level documentation, this will have to be diff -cr /var/tmp/postfix-2.2.8/html/TLS_README.html ./html/TLS_README.html *** /var/tmp/postfix-2.2.8/html/TLS_README.html Sat Oct 29 18:34:25 2005 --- ./html/TLS_README.html Fri Feb 17 15:11:48 2006 *************** *** 129,134 **** --- 129,139 ---- done by invoking the command "make makefiles" in the Postfix top-level directory and with arguments as shown next.

+

NOTE: Do not use Gnu TLS. It will spontaneously terminate + a Postfix daemon process with exit status code 2, instead of allowing + Postfix to 1) report the error to the maillog file, and to 2) provide + plaintext service where this is appropriate.

+ +

The smtp_tls_per_site limitations were removed by the end of + the Postfix 2.2 support cycle.

+

Credits

diff -cr /var/tmp/postfix-2.2.8/html/postconf.5.html ./html/postconf.5.html *** /var/tmp/postfix-2.2.8/html/postconf.5.html Tue Jul 19 12:53:07 2005 --- ./html/postconf.5.html Mon Jan 30 20:09:38 2006 *************** *** 3352,3358 ****

Examples:

!

The Postfix < 2.2 backwards compatible setting: always rewrite message headers, and always append my own domain to incomplete header addresses.

--- 3352,3358 ----

Examples:

!

The Postfix < 2.2 backwards compatible setting: always rewrite message headers, and always append my own domain to incomplete header addresses.

*************** *** 5767,5772 **** --- 5767,5787 ---- +
smtp_cname_overrides_servername + (default: yes)
+ +

Allow DNS CNAME records to override the servername that the + Postfix SMTP client uses for logging, SASL password lookup, TLS + policy decisions, or TLS certificate verification. The default value + (yes) is backwards compatible. Specify "no" to harden Postfix 2.2 + smtp_tls_per_site hostname-based policies against false hostname + information in DNS CNAME records.

+ +

This feature is available in Postfix 2.2.9 and later.

+ + +
+
smtp_connect_timeout (default: 30s)
*************** *** 6736,6773 **** (default: empty)

Optional lookup tables with the Postfix SMTP client TLS usage ! policy by next-hop domain name and by remote SMTP server hostname. !

! !

Table format: domain names or server hostnames are specified ! on the left-hand side; no wildcards are allowed. On the right hand ! side specify one of the following keywords:

!
NONE
Don't use TLS at all.
!
MAY
Try to use STARTTLS if offered, otherwise use ! the unencrypted connection.
!
MUST
Require usage of STARTTLS, require that the ! remote SMTP server hostname matches the information in the remote ! SMTP server certificate, and require that the remote SMTP server ! certificate was issued by a trusted CA.
! !
MUST_NOPEERMATCH
Require usage of STARTTLS, but do ! not require that the remote SMTP server hostname matches the ! information in the remote SMTP server certificate, or that the ! server certificate was issued by a trusted CA.
!
!

Special hint for enforcement mode: since no secure DNS lookup ! mechanism is available, the recommended setup is: specify local ! transport(5) table entries for sensitive domains with explicit ! smtp:[mailhost] destinations (since you can assure security of this ! table unlike DNS), then specify MUST for these mail hosts in the ! smtp_tls_per_site table.

--- 6751,6829 ---- (default: empty)

Optional lookup tables with the Postfix SMTP client TLS usage ! policy by next-hop destination and by remote SMTP server hostname. ! When both lookups succeed, the more specific per-site policy (NONE, ! MUST, etc) overrides the less specific one (MAY), and the more ! secure per-site policy (MUST, etc) overrides the less secure one ! (NONE).

! !

Specify a next-hop destination or server hostname on the left-hand ! side; no wildcards are allowed. The next-hop destination is either ! the recipient domain, or the destination specified with a transport(5) ! table, the relayhost parameter, or the relay_transport parameter. ! On the right hand side specify one of the following keywords:

!
NONE
Don't use TLS at all. This overrides a less ! specific MAY lookup result from the alternate host or next-hop ! lookup key, and overrides the global smtp_use_tls, smtp_enforce_tls, ! and smtp_tls_enforce_peername settings.
! !
MAY
Try to use TLS if the server announces support, ! otherwise use the unencrypted connection. This has less precedence ! than a more specific result (including NONE) from the alternate ! host or next-hop lookup key, and has less precedence than the more ! specific global "smtp_enforce_tls = yes" or "smtp_tls_enforce_peername ! = yes".
! !
MUST_NOPEERMATCH
Require TLS encryption, but do not ! require that the remote SMTP server hostname matches the information ! in the remote SMTP server certificate, or that the server certificate ! was issued by a trusted CA. This overrides a less secure NONE ! or a less specific MAY lookup result from the alternate host ! or next-hop lookup key, and overrides the global smtp_use_tls, ! smtp_enforce_tls and smtp_tls_enforce_peername settings.
! !
MUST
Require TLS encryption, require that the remote ! SMTP server hostname matches the information in the remote SMTP ! server certificate, and require that the remote SMTP server certificate ! was issued by a trusted CA. This overrides a less secure NONE ! and MUST_NOPEERMATCH or a less specific MAY lookup ! result from the alternate host or next-hop lookup key, and overrides ! the global smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername ! settings.
!
!

As long as no secure DNS lookup mechanism is available, false ! hostnames in MX or CNAME responses can change the server hostname ! that Postfix uses for TLS policy lookup and server certificate ! verification. Even with a perfect match between the server hostname ! and the server certificate, there is no guarantee that Postfix is ! connected to the right server. To avoid this loophole take the ! following steps:

! !

diff -cr /var/tmp/postfix-2.2.8/html/smtp.8.html ./html/smtp.8.html *** /var/tmp/postfix-2.2.8/html/smtp.8.html Tue Feb 22 09:05:41 2005 --- ./html/smtp.8.html Wed Jan 4 20:34:07 2006 *************** *** 99,106 **** smtp_never_send_ehlo (no) Never send EHLO at the start of an SMTP session. smtp_defer_if_no_mx_address_found (no) ! Defer mail delivery when no MX record resolves to an IP address. smtp_line_length_limit (990) --- 99,112 ---- smtp_never_send_ehlo (no) Never send EHLO at the start of an SMTP session. + smtp_cname_overrides_servername (yes) + Allow DNS CNAME records to override the servername + that the Postfix SMTP client uses for logging, SASL + password lookup, TLS policy decisions, or TLS cer- + tificate verification. + smtp_defer_if_no_mx_address_found (no) ! Defer mail delivery when no MX record resolves to an IP address. smtp_line_length_limit (990) *************** *** 108,124 **** that Postfix will send via SMTP. smtp_pix_workaround_delay_time (10s) ! How long the Postfix SMTP client pauses before sending ".<CR><LF>" in order to work around the PIX firewall "<CR><LF>.<CR><LF>" bug. smtp_pix_workaround_threshold_time (500s) ! How long a message must be queued before the PIX ! firewall "<CR><LF>.<CR><LF>" bug workaround is turned on. smtp_quote_rfc821_envelope (yes) ! Quote addresses in SMTP MAIL FROM and RCPT TO com- mands as required by RFC 821. smtp_skip_5xx_greeting (yes) --- 114,130 ---- that Postfix will send via SMTP. smtp_pix_workaround_delay_time (10s) ! How long the Postfix SMTP client pauses before sending ".<CR><LF>" in order to work around the PIX firewall "<CR><LF>.<CR><LF>" bug. smtp_pix_workaround_threshold_time (500s) ! How long a message must be queued before the PIX ! firewall "<CR><LF>.<CR><LF>" bug workaround is turned on. smtp_quote_rfc821_envelope (yes) ! Quote addresses in SMTP MAIL FROM and RCPT TO com- mands as required by RFC 821. smtp_skip_5xx_greeting (yes) *************** *** 126,132 **** (go away, do not try again later). smtp_skip_quit_response (yes) ! Do not wait for the response to the SMTP QUIT com- mand. Available in Postfix version 2.0 and earlier: --- 132,138 ---- (go away, do not try again later). smtp_skip_quit_response (yes) ! Do not wait for the response to the SMTP QUIT com- mand. Available in Postfix version 2.0 and earlier: *************** *** 138,158 **** Available in Postfix version 2.2 and later: smtp_discard_ehlo_keyword_address_maps (empty) ! Lookup tables, indexed by the remote SMTP server ! address, with case insensitive lists of EHLO key- ! words (pipelining, starttls, auth, etc.) that the SMTP client will ignore in the EHLO response from a remote SMTP server. smtp_discard_ehlo_keywords (empty) ! A case insensitive list of EHLO keywords (pipelin- ! ing, starttls, auth, etc.) that the SMTP client will ignore in the EHLO response from a remote SMTP server. smtp_generic_maps (empty) Optional lookup tables that perform address rewrit- ! ing in the SMTP client, typically to transform a locally valid address into a globally valid address when sending mail across the Internet. --- 144,164 ---- Available in Postfix version 2.2 and later: smtp_discard_ehlo_keyword_address_maps (empty) ! Lookup tables, indexed by the remote SMTP server ! address, with case insensitive lists of EHLO key- ! words (pipelining, starttls, auth, etc.) that the SMTP client will ignore in the EHLO response from a remote SMTP server. smtp_discard_ehlo_keywords (empty) ! A case insensitive list of EHLO keywords (pipelin- ! ing, starttls, auth, etc.) that the SMTP client will ignore in the EHLO response from a remote SMTP server. smtp_generic_maps (empty) Optional lookup tables that perform address rewrit- ! ing in the SMTP client, typically to transform a locally valid address into a globally valid address when sending mail across the Internet. *************** *** 160,166 **** Available in Postfix version 2.0 and later: disable_mime_output_conversion (no) ! Disable the conversion of 8BITMIME format to 7BIT format. mime_boundary_length_limit (2048) --- 166,172 ---- Available in Postfix version 2.0 and later: disable_mime_output_conversion (no) ! Disable the conversion of 8BITMIME format to 7BIT format. mime_boundary_length_limit (2048) *************** *** 175,284 **** Available in Postfix version 2.1 and later: smtp_send_xforward_command (no) ! Send the non-standard XFORWARD command when the ! Postfix SMTP server EHLO response announces XFOR- WARD support. SASL AUTHENTICATION CONTROLS smtp_sasl_auth_enable (no) ! Enable SASL authentication in the Postfix SMTP client. smtp_sasl_password_maps (empty) ! Optional SMTP client lookup tables with one user- ! name:password entry per remote hostname or domain. smtp_sasl_security_options (noplaintext, noanonymous) ! What authentication mechanisms the Postfix SMTP client is allowed to use. Available in Postfix version 2.2 and later: smtp_sasl_mechanism_filter (empty) ! If non-empty, a Postfix SMTP client filter for the ! remote SMTP server's list of offered SASL mecha- nisms. STARTTLS SUPPORT CONTROLS ! Detailed information about STARTTLS configuration may be found in the TLS_README document. smtp_use_tls (no) ! Opportunistic mode: use TLS when a remote SMTP ! server announces STARTTLS support, otherwise send the mail in the clear. smtp_enforce_tls (no) ! Enforcement mode: require that remote SMTP servers ! use TLS encryption, and never send mail in the clear. smtp_sasl_tls_security_options ($smtp_sasl_secu- rity_options) ! The SASL authentication security options that the ! Postfix SMTP client uses for TLS encrypted SMTP sessions. smtp_starttls_timeout (300s) ! Time limit for Postfix SMTP client write and read ! operations during TLS startup and shutdown hand- shake procedures. smtp_tls_CAfile (empty) ! The file with the certificate of the certification ! authority (CA) that issued the Postfix SMTP client certificate. smtp_tls_CApath (empty) ! Directory with PEM format certificate authority ! certificates that the Postfix SMTP client uses to verify a remote SMTP server certificate. smtp_tls_cert_file (empty) ! File with the Postfix SMTP client RSA certificate in PEM format. smtp_tls_cipherlist (empty) ! Controls the Postfix SMTP client TLS cipher selec- tion scheme. smtp_tls_dcert_file (empty) ! File with the Postfix SMTP client DSA certificate in PEM format. smtp_tls_dkey_file ($smtp_tls_dcert_file) ! File with the Postfix SMTP client DSA private key in PEM format. smtp_tls_enforce_peername (yes) ! When TLS encryption is enforced, require that the remote SMTP server hostname matches the information in the remote SMTP server certificate. smtp_tls_key_file ($smtp_tls_cert_file) ! File with the Postfix SMTP client RSA private key in PEM format. smtp_tls_loglevel (0) ! Enable additional Postfix SMTP client logging of TLS activity. smtp_tls_note_starttls_offer (no) ! Log the hostname of a remote SMTP server that ! offers STARTTLS, when TLS is not already enabled for that server. smtp_tls_per_site (empty) Optional lookup tables with the Postfix SMTP client ! TLS usage policy by next-hop domain name and by remote SMTP server hostname. smtp_tls_scert_verifydepth (5) ! The verification depth for remote SMTP server cer- tificates. smtp_tls_session_cache_database (empty) ! Name of the file containing the optional Postfix SMTP client TLS session cache. smtp_tls_session_cache_timeout (3600s) --- 181,290 ---- Available in Postfix version 2.1 and later: smtp_send_xforward_command (no) ! Send the non-standard XFORWARD command when the ! Postfix SMTP server EHLO response announces XFOR- WARD support. SASL AUTHENTICATION CONTROLS smtp_sasl_auth_enable (no) ! Enable SASL authentication in the Postfix SMTP client. smtp_sasl_password_maps (empty) ! Optional SMTP client lookup tables with one user- ! name:password entry per remote hostname or domain. smtp_sasl_security_options (noplaintext, noanonymous) ! What authentication mechanisms the Postfix SMTP client is allowed to use. Available in Postfix version 2.2 and later: smtp_sasl_mechanism_filter (empty) ! If non-empty, a Postfix SMTP client filter for the ! remote SMTP server's list of offered SASL mecha- nisms. STARTTLS SUPPORT CONTROLS ! Detailed information about STARTTLS configuration may be found in the TLS_README document. smtp_use_tls (no) ! Opportunistic mode: use TLS when a remote SMTP ! server announces STARTTLS support, otherwise send the mail in the clear. smtp_enforce_tls (no) ! Enforcement mode: require that remote SMTP servers ! use TLS encryption, and never send mail in the clear. smtp_sasl_tls_security_options ($smtp_sasl_secu- rity_options) ! The SASL authentication security options that the ! Postfix SMTP client uses for TLS encrypted SMTP sessions. smtp_starttls_timeout (300s) ! Time limit for Postfix SMTP client write and read ! operations during TLS startup and shutdown hand- shake procedures. smtp_tls_CAfile (empty) ! The file with the certificate of the certification ! authority (CA) that issued the Postfix SMTP client certificate. smtp_tls_CApath (empty) ! Directory with PEM format certificate authority ! certificates that the Postfix SMTP client uses to verify a remote SMTP server certificate. smtp_tls_cert_file (empty) ! File with the Postfix SMTP client RSA certificate in PEM format. smtp_tls_cipherlist (empty) ! Controls the Postfix SMTP client TLS cipher selec- tion scheme. smtp_tls_dcert_file (empty) ! File with the Postfix SMTP client DSA certificate in PEM format. smtp_tls_dkey_file ($smtp_tls_dcert_file) ! File with the Postfix SMTP client DSA private key in PEM format. smtp_tls_enforce_peername (yes) ! When TLS encryption is enforced, require that the remote SMTP server hostname matches the information in the remote SMTP server certificate. smtp_tls_key_file ($smtp_tls_cert_file) ! File with the Postfix SMTP client RSA private key in PEM format. smtp_tls_loglevel (0) ! Enable additional Postfix SMTP client logging of TLS activity. smtp_tls_note_starttls_offer (no) ! Log the hostname of a remote SMTP server that ! offers STARTTLS, when TLS is not already enabled for that server. smtp_tls_per_site (empty) Optional lookup tables with the Postfix SMTP client ! TLS usage policy by next-hop domain name and by remote SMTP server hostname. smtp_tls_scert_verifydepth (5) ! The verification depth for remote SMTP server cer- tificates. smtp_tls_session_cache_database (empty) ! Name of the file containing the optional Postfix SMTP client TLS session cache. smtp_tls_session_cache_timeout (3600s) *************** *** 286,316 **** sion cache information. tls_daemon_random_bytes (32) ! The number of pseudo-random bytes that an smtp(8) ! or smtpd(8) process requests from the tlsmgr(8) ! server in order to seed its internal pseudo random number generator (PRNG). RESOURCE AND RATE CONTROLS smtp_destination_concurrency_limit ($default_destina- tion_concurrency_limit) ! The maximal number of parallel deliveries to the ! same destination via the smtp message delivery transport. smtp_destination_recipient_limit ($default_destina- tion_recipient_limit) ! The maximal number of recipients per delivery via the smtp message delivery transport. smtp_connect_timeout (30s) ! The SMTP client time limit for completing a TCP connection, or zero (use the operating system built-in time limit). smtp_helo_timeout (300s) ! The SMTP client time limit for sending the HELO or ! EHLO command, and for receiving the initial server response. smtp_xforward_timeout (300s) --- 292,322 ---- sion cache information. tls_daemon_random_bytes (32) ! The number of pseudo-random bytes that an smtp(8) ! or smtpd(8) process requests from the tlsmgr(8) ! server in order to seed its internal pseudo random number generator (PRNG). RESOURCE AND RATE CONTROLS smtp_destination_concurrency_limit ($default_destina- tion_concurrency_limit) ! The maximal number of parallel deliveries to the ! same destination via the smtp message delivery transport. smtp_destination_recipient_limit ($default_destina- tion_recipient_limit) ! The maximal number of recipients per delivery via the smtp message delivery transport. smtp_connect_timeout (30s) ! The SMTP client time limit for completing a TCP connection, or zero (use the operating system built-in time limit). smtp_helo_timeout (300s) ! The SMTP client time limit for sending the HELO or ! EHLO command, and for receiving the initial server response. smtp_xforward_timeout (300s) *************** *** 318,347 **** command, and for receiving the server response. smtp_mail_timeout (300s) ! The SMTP client time limit for sending the MAIL ! FROM command, and for receiving the server response. smtp_rcpt_timeout (300s) ! The SMTP client time limit for sending the SMTP ! RCPT TO command, and for receiving the server response. smtp_data_init_timeout (120s) ! The SMTP client time limit for sending the SMTP ! DATA command, and for receiving the server response. smtp_data_xfer_timeout (180s) ! The SMTP client time limit for sending the SMTP message content. smtp_data_done_timeout (600s) ! The SMTP client time limit for sending the SMTP ".", and for receiving the server response. smtp_quit_timeout (300s) ! The SMTP client time limit for sending the QUIT command, and for receiving the server response. Available in Postfix version 2.1 and later: --- 324,353 ---- command, and for receiving the server response. smtp_mail_timeout (300s) ! The SMTP client time limit for sending the MAIL ! FROM command, and for receiving the server response. smtp_rcpt_timeout (300s) ! The SMTP client time limit for sending the SMTP ! RCPT TO command, and for receiving the server response. smtp_data_init_timeout (120s) ! The SMTP client time limit for sending the SMTP ! DATA command, and for receiving the server response. smtp_data_xfer_timeout (180s) ! The SMTP client time limit for sending the SMTP message content. smtp_data_done_timeout (600s) ! The SMTP client time limit for sending the SMTP ".", and for receiving the server response. smtp_quit_timeout (300s) ! The SMTP client time limit for sending the QUIT command, and for receiving the server response. Available in Postfix version 2.1 and later: *************** *** 352,428 **** lookups, or zero (no limit). smtp_mx_session_limit (2) ! The maximal number of SMTP sessions per delivery ! request before giving up or delivering to a fall- back relay host, or zero (no limit). smtp_rset_timeout (20s) ! The SMTP client time limit for sending the RSET command, and for receiving the server response. Available in Postfix version 2.2 and later: smtp_connection_cache_destinations (empty) ! Permanently enable SMTP connection caching for the specified destinations. smtp_connection_cache_on_demand (yes) ! Temporarily enable SMTP connection caching while a destination has a high volume of mail in the active queue. smtp_connection_cache_reuse_limit (10) When SMTP connection caching is enabled, the number ! of times that an SMTP session is reused before it is closed. smtp_connection_cache_time_limit (2s) When SMTP connection caching is enabled, the amount ! of time that an unused SMTP client socket is kept open before it is closed. TROUBLE SHOOTING CONTROLS debug_peer_level (2) ! The increment in verbose logging level when a ! remote client or server matches a pattern in the debug_peer_list parameter. debug_peer_list (empty) ! Optional list of remote client or server hostname ! or network address patterns that cause the verbose ! logging level to increase by the amount specified in $debug_peer_level. error_notice_recipient (postmaster) ! The recipient of postmaster notifications about ! mail delivery problems that are caused by policy, resource, software or protocol errors. notify_classes (resource, software) ! The list of error classes that are reported to the postmaster. MISCELLANEOUS CONTROLS best_mx_transport (empty) ! Where the Postfix SMTP client should deliver mail when it detects a "mail loops back to myself" error condition. config_directory (see 'postconf -d' output) ! The default location of the Postfix main.cf and master.cf configuration files. daemon_timeout (18000s) ! How much time a Postfix daemon process may take to ! handle a request before it is terminated by a built-in watchdog timer. disable_dns_lookups (no) ! Disable DNS lookups in the Postfix SMTP and LMTP clients. fallback_relay (empty) ! Optional list of relay hosts for SMTP destinations that can't be found or that are unreachable. inet_interfaces (all) --- 358,434 ---- lookups, or zero (no limit). smtp_mx_session_limit (2) ! The maximal number of SMTP sessions per delivery ! request before giving up or delivering to a fall- back relay host, or zero (no limit). smtp_rset_timeout (20s) ! The SMTP client time limit for sending the RSET command, and for receiving the server response. Available in Postfix version 2.2 and later: smtp_connection_cache_destinations (empty) ! Permanently enable SMTP connection caching for the specified destinations. smtp_connection_cache_on_demand (yes) ! Temporarily enable SMTP connection caching while a destination has a high volume of mail in the active queue. smtp_connection_cache_reuse_limit (10) When SMTP connection caching is enabled, the number ! of times that an SMTP session is reused before it is closed. smtp_connection_cache_time_limit (2s) When SMTP connection caching is enabled, the amount ! of time that an unused SMTP client socket is kept open before it is closed. TROUBLE SHOOTING CONTROLS debug_peer_level (2) ! The increment in verbose logging level when a ! remote client or server matches a pattern in the debug_peer_list parameter. debug_peer_list (empty) ! Optional list of remote client or server hostname ! or network address patterns that cause the verbose ! logging level to increase by the amount specified in $debug_peer_level. error_notice_recipient (postmaster) ! The recipient of postmaster notifications about ! mail delivery problems that are caused by policy, resource, software or protocol errors. notify_classes (resource, software) ! The list of error classes that are reported to the postmaster. MISCELLANEOUS CONTROLS best_mx_transport (empty) ! Where the Postfix SMTP client should deliver mail when it detects a "mail loops back to myself" error condition. config_directory (see 'postconf -d' output) ! The default location of the Postfix main.cf and master.cf configuration files. daemon_timeout (18000s) ! How much time a Postfix daemon process may take to ! handle a request before it is terminated by a built-in watchdog timer. disable_dns_lookups (no) ! Disable DNS lookups in the Postfix SMTP and LMTP clients. fallback_relay (empty) ! Optional list of relay hosts for SMTP destinations that can't be found or that are unreachable. inet_interfaces (all) *************** *** 430,436 **** tem receives mail on. inet_protocols (ipv4) ! The Internet protocols Postfix will attempt to use when making or accepting connections. ipc_timeout (3600s) --- 436,442 ---- tem receives mail on. inet_protocols (ipv4) ! The Internet protocols Postfix will attempt to use when making or accepting connections. ipc_timeout (3600s) *************** *** 438,492 **** over an internal communication channel. max_idle (100s) ! The maximum amount of time that an idle Postfix ! daemon process waits for the next service request before exiting. max_use (100) ! The maximal number of connection requests before a Postfix daemon process terminates. process_id (read-only) ! The process ID of a Postfix command or daemon process. process_name (read-only) ! The process name of a Postfix command or daemon process. proxy_interfaces (empty) The network interface addresses that this mail sys- ! tem receives mail on by way of a proxy or network address translation unit. smtp_bind_address (empty) An optional numerical network address that the SMTP ! client should bind to when making an IPv4 connec- tion. smtp_bind_address6 (empty) An optional numerical network address that the SMTP ! client should bind to when making an IPv6 connec- tion. smtp_helo_name ($myhostname) ! The hostname to send in the SMTP EHLO or HELO com- mand. smtp_host_lookup (dns) ! What mechanisms when the SMTP client uses to look up a host's IP address. smtp_randomize_addresses (yes) ! Randomize the order of equal-preference MX host addresses. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) ! The mail system name that is prepended to the ! process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO --- 444,498 ---- over an internal communication channel. max_idle (100s) ! The maximum amount of time that an idle Postfix ! daemon process waits for the next service request before exiting. max_use (100) ! The maximal number of connection requests before a Postfix daemon process terminates. process_id (read-only) ! The process ID of a Postfix command or daemon process. process_name (read-only) ! The process name of a Postfix command or daemon process. proxy_interfaces (empty) The network interface addresses that this mail sys- ! tem receives mail on by way of a proxy or network address translation unit. smtp_bind_address (empty) An optional numerical network address that the SMTP ! client should bind to when making an IPv4 connec- tion. smtp_bind_address6 (empty) An optional numerical network address that the SMTP ! client should bind to when making an IPv6 connec- tion. smtp_helo_name ($myhostname) ! The hostname to send in the SMTP EHLO or HELO com- mand. smtp_host_lookup (dns) ! What mechanisms when the SMTP client uses to look up a host's IP address. smtp_randomize_addresses (yes) ! Randomize the order of equal-preference MX host addresses. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) ! The mail system name that is prepended to the ! process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO *************** *** 504,510 **** TLS_README, Postfix STARTTLS howto LICENSE ! The Secure Mailer license must be distributed with this software. AUTHOR(S) --- 510,516 ---- TLS_README, Postfix STARTTLS howto LICENSE ! The Secure Mailer license must be distributed with this software. AUTHOR(S) diff -cr /var/tmp/postfix-2.2.8/man/man5/postconf.5 ./man/man5/postconf.5 *** /var/tmp/postfix-2.2.8/man/man5/postconf.5 Tue Jul 19 12:53:07 2005 --- ./man/man5/postconf.5 Mon Jan 30 20:09:38 2006 *************** *** 3195,3200 **** --- 3195,3209 ---- .PP Note 2: address information may be enclosed inside [], but this form is not recommended here. + .SH smtp_cname_overrides_servername (default: yes) + Allow DNS CNAME records to override the servername that the + Postfix SMTP client uses for logging, SASL password lookup, TLS + policy decisions, or TLS certificate verification. The default value + (yes) is backwards compatible. Specify "no" to harden Postfix 2.2 + smtp_tls_per_site hostname-based policies against false hostname + information in DNS CNAME records. + .PP + This feature is available in Postfix 2.2.9 and later. .SH smtp_connect_timeout (default: 30s) The SMTP client time limit for completing a TCP connection, or zero (use the operating system built-in time limit). *************** *** 3748,3780 **** .ft R .SH smtp_tls_per_site (default: empty) Optional lookup tables with the Postfix SMTP client TLS usage ! policy by next-hop domain name and by remote SMTP server hostname. ! .PP ! Table format: domain names or server hostnames are specified ! on the left-hand side; no wildcards are allowed. On the right hand ! side specify one of the following keywords: .IP "NONE" ! Don't use TLS at all. .IP "MAY" ! Try to use STARTTLS if offered, otherwise use ! the unencrypted connection. ! .IP "MUST" ! Require usage of STARTTLS, require that the ! remote SMTP server hostname matches the information in the remote ! SMTP server certificate, and require that the remote SMTP server ! certificate was issued by a trusted CA. .IP "MUST_NOPEERMATCH" ! Require usage of STARTTLS, but do ! not require that the remote SMTP server hostname matches the ! information in the remote SMTP server certificate, or that the ! server certificate was issued by a trusted CA. ! .PP ! Special hint for enforcement mode: since no secure DNS lookup ! mechanism is available, the recommended setup is: specify local ! \fBtransport\fR(5) table entries for sensitive domains with explicit ! smtp:[mailhost] destinations (since you can assure security of this ! table unlike DNS), then specify MUST for these mail hosts in the ! smtp_tls_per_site table. .SH smtp_tls_scert_verifydepth (default: 5) The verification depth for remote SMTP server certificates. A depth of 1 is sufficient, if the certificate is directly issued by --- 3757,3826 ---- .ft R .SH smtp_tls_per_site (default: empty) Optional lookup tables with the Postfix SMTP client TLS usage ! policy by next-hop destination and by remote SMTP server hostname. ! When both lookups succeed, the more specific per-site policy (NONE, ! MUST, etc) overrides the less specific one (MAY), and the more ! secure per-site policy (MUST, etc) overrides the less secure one ! (NONE). ! .PP ! Specify a next-hop destination or server hostname on the left-hand ! side; no wildcards are allowed. The next-hop destination is either ! the recipient domain, or the destination specified with a \fBtransport\fR(5) ! table, the relayhost parameter, or the relay_transport parameter. ! On the right hand side specify one of the following keywords: .IP "NONE" ! Don't use TLS at all. This overrides a less ! specific \fBMAY\fR lookup result from the alternate host or next-hop ! lookup key, and overrides the global smtp_use_tls, smtp_enforce_tls, ! and smtp_tls_enforce_peername settings. .IP "MAY" ! Try to use TLS if the server announces support, ! otherwise use the unencrypted connection. This has less precedence ! than a more specific result (including \fBNONE\fR) from the alternate ! host or next-hop lookup key, and has less precedence than the more ! specific global "smtp_enforce_tls = yes" or "smtp_tls_enforce_peername ! = yes". .IP "MUST_NOPEERMATCH" ! Require TLS encryption, but do not ! require that the remote SMTP server hostname matches the information ! in the remote SMTP server certificate, or that the server certificate ! was issued by a trusted CA. This overrides a less secure \fBNONE\fR ! or a less specific \fBMAY\fR lookup result from the alternate host ! or next-hop lookup key, and overrides the global smtp_use_tls, ! smtp_enforce_tls and smtp_tls_enforce_peername settings. ! .IP "MUST" ! Require TLS encryption, require that the remote ! SMTP server hostname matches the information in the remote SMTP ! server certificate, and require that the remote SMTP server certificate ! was issued by a trusted CA. This overrides a less secure \fBNONE\fR ! and \fBMUST_NOPEERMATCH\fR or a less specific \fBMAY\fR lookup ! result from the alternate host or next-hop lookup key, and overrides ! the global smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername ! settings. ! .PP ! As long as no secure DNS lookup mechanism is available, false ! hostnames in MX or CNAME responses can change the server hostname ! that Postfix uses for TLS policy lookup and server certificate ! verification. Even with a perfect match between the server hostname ! and the server certificate, there is no guarantee that Postfix is ! connected to the right server. To avoid this loophole take the ! following steps: ! .IP \(bu ! Disallow CNAME hostname overrides. In main.cf specify ! "smtp_cname_overrides_servername = no". This prevents false hostname ! information in DNS CNAME records from changing the server hostname ! that Postfix uses for TLS policy lookup and server certificate ! verification. This feature requires Postfix 2.2.9 or later. ! .IP \(bu ! Eliminate MX lookups. Specify local \fBtransport\fR(5) table entries ! for sensitive domains with explicit smtp:[mailhost] or smtp:[mailhost]:port ! destinations. This prevents false hostname information in DNS MX ! records from changing the server hostname that Postfix uses for TLS ! policy lookup and server certificate verification. ! .IP \(bu ! Specify MUST for these mail hosts (including [ ] and port) in ! the smtp_tls_per_site table. ! .PP .SH smtp_tls_scert_verifydepth (default: 5) The verification depth for remote SMTP server certificates. A depth of 1 is sufficient, if the certificate is directly issued by diff -cr /var/tmp/postfix-2.2.8/man/man8/smtp.8 ./man/man8/smtp.8 *** /var/tmp/postfix-2.2.8/man/man8/smtp.8 Fri Feb 11 19:16:04 2005 --- ./man/man8/smtp.8 Wed Jan 4 20:34:07 2006 *************** *** 103,108 **** --- 103,112 ---- Always send EHLO at the start of an SMTP session. .IP "\fBsmtp_never_send_ehlo (no)\fR" Never send EHLO at the start of an SMTP session. + .IP "\fBsmtp_cname_overrides_servername (yes)\fR" + Allow DNS CNAME records to override the servername that the + Postfix SMTP client uses for logging, SASL password lookup, TLS + policy decisions, or TLS certificate verification. .IP "\fBsmtp_defer_if_no_mx_address_found (no)\fR" Defer mail delivery when no MX record resolves to an IP address. .IP "\fBsmtp_line_length_limit (990)\fR" diff -cr /var/tmp/postfix-2.2.8/mantools/postlink ./mantools/postlink *** /var/tmp/postfix-2.2.8/mantools/postlink Sun Feb 27 10:05:07 2005 --- ./mantools/postlink Wed Jan 4 20:27:36 2006 *************** *** 313,318 **** --- 313,319 ---- s;\bsmtp_always_send_ehlo\b;$&;g; s;\bsmtp_bind_address\b;$&;g; s;\bsmtp_bind_address6\b;$&;g; + s;\bsmtp_cname_overrides_servername\b;$&;g; s;\bsmtp_connect_timeout\b;$&;g; s;\bsmtp_connection_cache_on_demand\b;$&;g; diff -cr /var/tmp/postfix-2.2.8/proto/SCHEDULER_README.html ./proto/SCHEDULER_README.html *** /var/tmp/postfix-2.2.8/proto/SCHEDULER_README.html Thu Apr 15 10:41:45 2004 --- ./proto/SCHEDULER_README.html Thu Feb 16 11:44:13 2006 *************** *** 68,74 **** while qmgr(8) uses simple FIFO, except for some preemptive magic. The postconf(5) manual documents all the knobs the user can use to control this preemptive magic - there is nothing else ! to the preemption than the quite simple conditions described below.

As for programmer-level documentation, this will have to be --- 68,74 ---- while qmgr(8) uses simple FIFO, except for some preemptive magic. The postconf(5) manual documents all the knobs the user can use to control this preemptive magic - there is nothing else ! to the preemption than the quite simple conditions described in there.

As for programmer-level documentation, this will have to be diff -cr /var/tmp/postfix-2.2.8/proto/TLS_README.html ./proto/TLS_README.html *** /var/tmp/postfix-2.2.8/proto/TLS_README.html Sat Oct 29 18:34:16 2005 --- ./proto/TLS_README.html Fri Feb 17 14:55:04 2006 *************** *** 129,134 **** --- 129,139 ---- done by invoking the command "make makefiles" in the Postfix top-level directory and with arguments as shown next.

+

NOTE: Do not use Gnu TLS. It will spontaneously terminate + a Postfix daemon process with exit status code 2, instead of allowing + Postfix to 1) report the error to the maillog file, and to 2) provide + plaintext service where this is appropriate.

+ +

The smtp_tls_per_site limitations were removed by the end of + the Postfix 2.2 support cycle.

+

Credits

diff -cr /var/tmp/postfix-2.2.8/proto/postconf.proto ./proto/postconf.proto *** /var/tmp/postfix-2.2.8/proto/postconf.proto Tue Jul 19 12:53:04 2005 --- ./proto/postconf.proto Mon Jan 30 20:09:29 2006 *************** *** 7750,7756 ****

Examples:

!

The Postfix < 2.2 backwards compatible setting: always rewrite message headers, and always append my own domain to incomplete header addresses.

--- 7750,7756 ----

Examples:

!

The Postfix < 2.2 backwards compatible setting: always rewrite message headers, and always append my own domain to incomplete header addresses.

*************** *** 8251,8288 **** %PARAM smtp_tls_per_site

Optional lookup tables with the Postfix SMTP client TLS usage ! policy by next-hop domain name and by remote SMTP server hostname. !

! !

Table format: domain names or server hostnames are specified ! on the left-hand side; no wildcards are allowed. On the right hand ! side specify one of the following keywords:

!
NONE
Don't use TLS at all.
!
MAY
Try to use STARTTLS if offered, otherwise use ! the unencrypted connection.
!
MUST
Require usage of STARTTLS, require that the ! remote SMTP server hostname matches the information in the remote ! SMTP server certificate, and require that the remote SMTP server ! certificate was issued by a trusted CA.
! !
MUST_NOPEERMATCH
Require usage of STARTTLS, but do ! not require that the remote SMTP server hostname matches the ! information in the remote SMTP server certificate, or that the ! server certificate was issued by a trusted CA.
!
!

Special hint for enforcement mode: since no secure DNS lookup ! mechanism is available, the recommended setup is: specify local ! transport(5) table entries for sensitive domains with explicit ! smtp:[mailhost] destinations (since you can assure security of this ! table unlike DNS), then specify MUST for these mail hosts in the ! smtp_tls_per_site table.

%PARAM smtp_tls_scert_verifydepth 5 --- 8251,8329 ---- %PARAM smtp_tls_per_site

Optional lookup tables with the Postfix SMTP client TLS usage ! policy by next-hop destination and by remote SMTP server hostname. ! When both lookups succeed, the more specific per-site policy (NONE, ! MUST, etc) overrides the less specific one (MAY), and the more ! secure per-site policy (MUST, etc) overrides the less secure one ! (NONE).

! !

Specify a next-hop destination or server hostname on the left-hand ! side; no wildcards are allowed. The next-hop destination is either ! the recipient domain, or the destination specified with a transport(5) ! table, the relayhost parameter, or the relay_transport parameter. ! On the right hand side specify one of the following keywords:

!
NONE
Don't use TLS at all. This overrides a less ! specific MAY lookup result from the alternate host or next-hop ! lookup key, and overrides the global smtp_use_tls, smtp_enforce_tls, ! and smtp_tls_enforce_peername settings.
! !
MAY
Try to use TLS if the server announces support, ! otherwise use the unencrypted connection. This has less precedence ! than a more specific result (including NONE) from the alternate ! host or next-hop lookup key, and has less precedence than the more ! specific global "smtp_enforce_tls = yes" or "smtp_tls_enforce_peername ! = yes".
! !
MUST_NOPEERMATCH
Require TLS encryption, but do not ! require that the remote SMTP server hostname matches the information ! in the remote SMTP server certificate, or that the server certificate ! was issued by a trusted CA. This overrides a less secure NONE ! or a less specific MAY lookup result from the alternate host ! or next-hop lookup key, and overrides the global smtp_use_tls, ! smtp_enforce_tls and smtp_tls_enforce_peername settings.
! !
MUST
Require TLS encryption, require that the remote ! SMTP server hostname matches the information in the remote SMTP ! server certificate, and require that the remote SMTP server certificate ! was issued by a trusted CA. This overrides a less secure NONE ! and MUST_NOPEERMATCH or a less specific MAY lookup ! result from the alternate host or next-hop lookup key, and overrides ! the global smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername ! settings.
!
!

As long as no secure DNS lookup mechanism is available, false ! hostnames in MX or CNAME responses can change the server hostname ! that Postfix uses for TLS policy lookup and server certificate ! verification. Even with a perfect match between the server hostname ! and the server certificate, there is no guarantee that Postfix is ! connected to the right server. To avoid this loophole take the ! following steps:

! ! ! !

%PARAM smtp_tls_scert_verifydepth 5 *************** *** 8412,8414 **** --- 8453,8466 ---- STANDARD_CONFIGURATION_README documents.

This feature is available in Postfix 2.2 and later.

+ + %PARAM smtp_cname_overrides_servername yes + +

Allow DNS CNAME records to override the servername that the + Postfix SMTP client uses for logging, SASL password lookup, TLS + policy decisions, or TLS certificate verification. The default value + (yes) is backwards compatible. Specify "no" to harden Postfix 2.2 + smtp_tls_per_site hostname-based policies against false hostname + information in DNS CNAME records.

+ +

This feature is available in Postfix 2.2.9 and later.

diff -cr /var/tmp/postfix-2.2.8/src/cleanup/cleanup_api.c ./src/cleanup/cleanup_api.c *** /var/tmp/postfix-2.2.8/src/cleanup/cleanup_api.c Tue Dec 2 20:38:57 2003 --- ./src/cleanup/cleanup_api.c Sun Feb 12 09:42:35 2006 *************** *** 224,229 **** --- 224,237 ---- vstream_control(state->handle->stream, VSTREAM_CTL_PATH, cleanup_path, VSTREAM_CTL_END); + + /* + * XXX: When delivering to a non-incoming queue, do not consume + * in_flow tokens. Unfortunately we can't move the code that + * consumes tokens until after the mail is received, because that + * would increase the risk of duplicate deliveries (RFC 1047). + */ + (void) mail_flow_put(1); } state->errs = mail_stream_finish(state->handle, (VSTRING *) 0); } else { diff -cr /var/tmp/postfix-2.2.8/src/dns/dns.h ./src/dns/dns.h *** /var/tmp/postfix-2.2.8/src/dns/dns.h Tue Nov 15 09:46:27 2005 --- ./src/dns/dns.h Wed Jan 4 14:52:05 2006 *************** *** 80,86 **** * named after the things one can expect to find in a DNS resource record. */ typedef struct DNS_RR { ! char *name; /* name, mystrdup()ed */ unsigned short type; /* T_A, T_CNAME, etc. */ unsigned short class; /* C_IN, etc. */ unsigned int ttl; /* always */ --- 80,87 ---- * named after the things one can expect to find in a DNS resource record. */ typedef struct DNS_RR { ! char *qname; /* query name, mystrdup()ed */ ! char *rname; /* reply name, mystrdup()ed */ unsigned short type; /* T_A, T_CNAME, etc. */ unsigned short class; /* C_IN, etc. */ unsigned int ttl; /* always */ *************** *** 104,110 **** /* * dns_rr.c */ ! extern DNS_RR *dns_rr_create(const char *, ushort, ushort, unsigned, unsigned, const char *, unsigned); extern void dns_rr_free(DNS_RR *); --- 105,112 ---- /* * dns_rr.c */ ! extern DNS_RR *dns_rr_create(const char *, const char *, ! ushort, ushort, unsigned, unsigned, const char *, unsigned); extern void dns_rr_free(DNS_RR *); diff -cr /var/tmp/postfix-2.2.8/src/dns/dns_lookup.c ./src/dns/dns_lookup.c *** /var/tmp/postfix-2.2.8/src/dns/dns_lookup.c Tue Jan 18 20:22:01 2005 --- ./src/dns/dns_lookup.c Thu Feb 2 14:59:23 2006 *************** *** 97,102 **** --- 97,107 ---- /* The query failed; the problem is transient. /* .IP DNS_FAIL /* The query failed. + /* + /* As a workaround, this result value is also returned when + /* the DNS query succeeded, but the result could not be parsed, + /* or the result domain name did not pass the valid_hostname() + /* syntax test (e.g., a null MX hostname). /* BUGS /* dns_lookup() implements a subset of all possible resource types: /* CNAME, MX, A, and some records with similar formatting requirements. *************** *** 324,330 **** /* dns_get_rr - extract resource record from name server reply */ ! static DNS_RR *dns_get_rr(DNS_REPLY *reply, unsigned char *pos, char *rr_name, DNS_FIXED *fixed) { char temp[DNS_NAME_LEN]; --- 329,335 ---- /* dns_get_rr - extract resource record from name server reply */ ! static DNS_RR *dns_get_rr(const char *name, DNS_REPLY *reply, unsigned char *pos, char *rr_name, DNS_FIXED *fixed) { char temp[DNS_NAME_LEN]; *************** *** 397,403 **** *dst = 0; break; } ! return (dns_rr_create(rr_name, fixed->type, fixed->class, fixed->ttl, pref, temp, data_len)); } --- 402,408 ---- *dst = 0; break; } ! return (dns_rr_create(name, rr_name, fixed->type, fixed->class, fixed->ttl, pref, temp, data_len)); } *************** *** 417,423 **** /* dns_get_answer - extract answers from name server reply */ ! static int dns_get_answer(DNS_REPLY *reply, int type, DNS_RR **rrlist, VSTRING *fqdn, char *cname, int c_len) { char rr_name[DNS_NAME_LEN]; --- 422,428 ---- /* dns_get_answer - extract answers from name server reply */ ! static int dns_get_answer(const char *name, DNS_REPLY *reply, int type, DNS_RR **rrlist, VSTRING *fqdn, char *cname, int c_len) { char rr_name[DNS_NAME_LEN]; *************** *** 490,500 **** CORRUPT; if (type == fixed.type || type == T_ANY) { /* requested type */ if (rrlist) { ! if ((rr = dns_get_rr(reply, pos, rr_name, &fixed)) != 0) { resource_found++; *rrlist = dns_rr_append(*rrlist, rr); ! } else ! not_found_status = DNS_RETRY; } else resource_found++; } else if (fixed.type == T_CNAME) { /* cname resource */ --- 495,505 ---- CORRUPT; if (type == fixed.type || type == T_ANY) { /* requested type */ if (rrlist) { ! if ((rr = dns_get_rr(name, reply, pos, rr_name, &fixed)) != 0) { resource_found++; *rrlist = dns_rr_append(*rrlist, rr); ! } else if (not_found_status != DNS_RETRY) ! not_found_status = DNS_FAIL; /* XXX */ } else resource_found++; } else if (fixed.type == T_CNAME) { /* cname resource */ *************** *** 528,533 **** --- 533,539 ---- DNS_REPLY reply; int count; int status; + const char *saved_name = name; /* * DJBDNS produces a bogus A record when given a numerical hostname. *************** *** 569,575 **** * Extract resource records of the requested type. Pick up CNAME * information just in case the requested data is not found. */ ! status = dns_get_answer(&reply, type, rrlist, fqdn, cname, c_len); switch (status) { default: if (why) --- 575,582 ---- * Extract resource records of the requested type. Pick up CNAME * information just in case the requested data is not found. */ ! status = dns_get_answer(saved_name, &reply, type, rrlist, fqdn, ! cname, c_len); switch (status) { default: if (why) diff -cr /var/tmp/postfix-2.2.8/src/dns/dns_rr.c ./src/dns/dns_rr.c *** /var/tmp/postfix-2.2.8/src/dns/dns_rr.c Tue Jan 18 20:22:01 2005 --- ./src/dns/dns_rr.c Wed Jan 4 15:20:56 2006 *************** *** 6,14 **** /* SYNOPSIS /* #include /* ! /* DNS_RR *dns_rr_create(name, type, class, ttl, preference, /* data, data_len) ! /* const char *name; /* unsigned short type; /* unsigned short class; /* unsigned int ttl; --- 6,15 ---- /* SYNOPSIS /* #include /* ! /* DNS_RR *dns_rr_create(qname, rname, type, class, ttl, preference, /* data, data_len) ! /* const char *qname; ! /* const char *rname; /* unsigned short type; /* unsigned short class; /* unsigned int ttl; *************** *** 41,47 **** /* information, and maintain lists of DNS resource records. /* /* dns_rr_create() creates and initializes one resource record. ! /* The \fIname\fR record specifies the record name. /* \fIpreference\fR is used for MX records; \fIdata\fR is a null /* pointer or specifies optional resource-specific data; /* \fIdata_len\fR is the amount of resource-specific data. --- 42,49 ---- /* information, and maintain lists of DNS resource records. /* /* dns_rr_create() creates and initializes one resource record. ! /* The \fIqname\fR field specifies the query name. ! /* The \fIrname\fR field specifies the reply name. /* \fIpreference\fR is used for MX records; \fIdata\fR is a null /* pointer or specifies optional resource-specific data; /* \fIdata_len\fR is the amount of resource-specific data. *************** *** 91,104 **** /* dns_rr_create - fill in resource record structure */ ! DNS_RR *dns_rr_create(const char *name, ushort type, ushort class, unsigned int ttl, unsigned pref, const char *data, unsigned data_len) { DNS_RR *rr; rr = (DNS_RR *) mymalloc(sizeof(*rr) + data_len - 1); ! rr->name = mystrdup(name); rr->type = type; rr->class = class; rr->ttl = ttl; --- 93,108 ---- /* dns_rr_create - fill in resource record structure */ ! DNS_RR *dns_rr_create(const char *qname, const char *rname, ! ushort type, ushort class, unsigned int ttl, unsigned pref, const char *data, unsigned data_len) { DNS_RR *rr; rr = (DNS_RR *) mymalloc(sizeof(*rr) + data_len - 1); ! rr->qname = mystrdup(qname); ! rr->rname = mystrdup(rname); rr->type = type; rr->class = class; rr->ttl = ttl; *************** *** 117,123 **** if (rr) { if (rr->next) dns_rr_free(rr->next); ! myfree(rr->name); myfree((char *) rr); } } --- 121,128 ---- if (rr) { if (rr->next) dns_rr_free(rr->next); ! myfree(rr->qname); ! myfree(rr->rname); myfree((char *) rr); } } *************** *** 134,140 **** */ dst = (DNS_RR *) mymalloc(len); memcpy((char *) dst, (char *) src, len); ! dst->name = mystrdup(src->name); dst->next = 0; return (dst); } --- 139,146 ---- */ dst = (DNS_RR *) mymalloc(len); memcpy((char *) dst, (char *) src, len); ! dst->qname = mystrdup(src->qname); ! dst->rname = mystrdup(src->rname); dst->next = 0; return (dst); } diff -cr /var/tmp/postfix-2.2.8/src/dns/dns_sa_to_rr.c ./src/dns/dns_sa_to_rr.c *** /var/tmp/postfix-2.2.8/src/dns/dns_sa_to_rr.c Tue Jan 18 20:22:01 2005 --- ./src/dns/dns_sa_to_rr.c Wed Jan 4 11:00:44 2006 *************** *** 54,65 **** #define DUMMY_TTL 0 if (sa->sa_family == AF_INET) { ! return (dns_rr_create(hostname, T_A, C_IN, DUMMY_TTL, pref, (char *) &SOCK_ADDR_IN_ADDR(sa), sizeof(SOCK_ADDR_IN_ADDR(sa)))); #ifdef HAS_IPV6 } else if (sa->sa_family == AF_INET6) { ! return (dns_rr_create(hostname, T_AAAA, C_IN, DUMMY_TTL, pref, (char *) &SOCK_ADDR_IN6_ADDR(sa), sizeof(SOCK_ADDR_IN6_ADDR(sa)))); #endif --- 54,65 ---- #define DUMMY_TTL 0 if (sa->sa_family == AF_INET) { ! return (dns_rr_create(hostname, hostname, T_A, C_IN, DUMMY_TTL, pref, (char *) &SOCK_ADDR_IN_ADDR(sa), sizeof(SOCK_ADDR_IN_ADDR(sa)))); #ifdef HAS_IPV6 } else if (sa->sa_family == AF_INET6) { ! return (dns_rr_create(hostname, hostname, T_AAAA, C_IN, DUMMY_TTL, pref, (char *) &SOCK_ADDR_IN6_ADDR(sa), sizeof(SOCK_ADDR_IN6_ADDR(sa)))); #endif diff -cr /var/tmp/postfix-2.2.8/src/dns/test_dns_lookup.c ./src/dns/test_dns_lookup.c *** /var/tmp/postfix-2.2.8/src/dns/test_dns_lookup.c Mon Jan 31 19:55:12 2005 --- ./src/dns/test_dns_lookup.c Wed Jan 4 11:00:44 2006 *************** *** 45,51 **** MAI_HOSTADDR_STR host; while (rr) { ! printf("%s: ttl: %9d ", rr->name, rr->ttl); switch (rr->type) { case T_A: #ifdef T_AAAA --- 45,51 ---- MAI_HOSTADDR_STR host; while (rr) { ! printf("%s: ttl: %9d ", rr->rname, rr->ttl); switch (rr->type) { case T_A: #ifdef T_AAAA diff -cr /var/tmp/postfix-2.2.8/src/global/ehlo_mask.ref ./src/global/ehlo_mask.ref *** /var/tmp/postfix-2.2.8/src/global/ehlo_mask.ref Sat Dec 18 16:28:11 2004 --- ./src/global/ehlo_mask.ref Tue Jan 17 14:30:43 2006 *************** *** 1,3 **** ! starttls, 8bitmime, verp, etrn, etrn -> 0x51 -> 8BITMIME ETRN VERP foobar, auth, pipelining, size, vrfy -> 0x2e -> AUTH PIPELINING SIZE VRFY ! xclient, xforward -> 0x180 -> XCLIENT XFORWARD --- 1,3 ---- ! starttls, 8bitmime, verp, etrn, etrn -> 0xd1 -> 8BITMIME ETRN VERP STARTTLS foobar, auth, pipelining, size, vrfy -> 0x2e -> AUTH PIPELINING SIZE VRFY ! xclient, xforward -> 0x300 -> XCLIENT XFORWARD diff -cr /var/tmp/postfix-2.2.8/src/global/input_transp.c ./src/global/input_transp.c *** /var/tmp/postfix-2.2.8/src/global/input_transp.c Thu Feb 3 20:50:05 2005 --- ./src/global/input_transp.c Wed Jan 25 11:23:28 2006 *************** *** 26,32 **** /* given in parentheses: /* .IP "no_unknown_recipient_checks (INPUT_TRANSP_UNKNOWN_RCPT)" /* Do not try to reject unknown recipients. ! /* .IP "no_address_mapping (INPUT_TRANSP_ADDRESS_MAPPING) /* Disable canonical address mapping, virtual alias map expansion, /* address masquerading, and automatic BCC recipients. /* .IP "no_header_body_checkss (INPUT_TRANSP_HEADER_BODY) --- 26,32 ---- /* given in parentheses: /* .IP "no_unknown_recipient_checks (INPUT_TRANSP_UNKNOWN_RCPT)" /* Do not try to reject unknown recipients. ! /* .IP "no_address_mappings (INPUT_TRANSP_ADDRESS_MAPPING) /* Disable canonical address mapping, virtual alias map expansion, /* address masquerading, and automatic BCC recipients. /* .IP "no_header_body_checkss (INPUT_TRANSP_HEADER_BODY) diff -cr /var/tmp/postfix-2.2.8/src/global/mail_addr_find.c ./src/global/mail_addr_find.c *** /var/tmp/postfix-2.2.8/src/global/mail_addr_find.c Tue Jan 20 12:44:21 2004 --- ./src/global/mail_addr_find.c Fri Jan 13 15:47:10 2006 *************** *** 107,113 **** if (*var_rcpt_delim == 0) { bare_key = saved_ext = 0; } else { ! bare_key = strip_addr(full_key, &saved_ext, *var_rcpt_delim); } /* --- 107,116 ---- if (*var_rcpt_delim == 0) { bare_key = saved_ext = 0; } else { ! /* Preserve case of extension. */ ! bare_key = strip_addr(address, &saved_ext, *var_rcpt_delim); ! if (bare_key != 0) ! lowercase(bare_key); } /* diff -cr /var/tmp/postfix-2.2.8/src/global/mail_params.h ./src/global/mail_params.h *** /var/tmp/postfix-2.2.8/src/global/mail_params.h Sun Feb 27 10:06:07 2005 --- ./src/global/mail_params.h Fri Feb 3 11:06:52 2006 *************** *** 2346,2351 **** --- 2346,2358 ---- #define DEF_SMTP_EHLO_DIS_MAPS "" extern char *var_smtp_ehlo_dis_maps; + /* + * Allow CNAME lookup result to override the server hostname. + */ + #define VAR_SMTP_CNAME_OVERR "smtp_cname_overrides_servername" + #define DEF_SMTP_CNAME_OVERR 1 + extern bool var_smtp_cname_overr; + /* LICENSE /* .ad /* .fi diff -cr /var/tmp/postfix-2.2.8/src/lmtp/lmtp_addr.c ./src/lmtp/lmtp_addr.c *** /var/tmp/postfix-2.2.8/src/lmtp/lmtp_addr.c Tue Jan 18 20:22:03 2005 --- ./src/lmtp/lmtp_addr.c Wed Jan 4 14:56:48 2006 *************** *** 105,111 **** msg_warn("skipping record type %s: %m", dns_strtype(addr->type)); } else { msg_info("pref %4d host %s/%s", ! addr->pref, addr->name, hostaddr.buf); } } --- 105,111 ---- msg_warn("skipping record type %s: %m", dns_strtype(addr->type)); } else { msg_info("pref %4d host %s/%s", ! addr->pref, addr->rname, hostaddr.buf); } } diff -cr /var/tmp/postfix-2.2.8/src/lmtp/lmtp_connect.c ./src/lmtp/lmtp_connect.c *** /var/tmp/postfix-2.2.8/src/lmtp/lmtp_connect.c Tue Jan 18 20:22:03 2005 --- ./src/lmtp/lmtp_connect.c Wed Jan 4 14:56:09 2006 *************** *** 200,209 **** SOCKADDR_TO_HOSTADDR(sa, salen, &hostaddr, (MAI_SERVPORT_STR *) 0, 0); if (msg_verbose) msg_info("%s: trying: %s[%s] port %d...", ! myname, addr->name, hostaddr.buf, ntohs(port)); return (lmtp_connect_sock(sock, sa, salen, ! addr->name, hostaddr.buf, destination, why)); } /* lmtp_connect_sock - connect a socket over some transport */ --- 200,209 ---- SOCKADDR_TO_HOSTADDR(sa, salen, &hostaddr, (MAI_SERVPORT_STR *) 0, 0); if (msg_verbose) msg_info("%s: trying: %s[%s] port %d...", ! myname, addr->rname, hostaddr.buf, ntohs(port)); return (lmtp_connect_sock(sock, sa, salen, ! addr->rname, hostaddr.buf, destination, why)); } /* lmtp_connect_sock - connect a socket over some transport */ diff -cr /var/tmp/postfix-2.2.8/src/local/local.c ./src/local/local.c *** /var/tmp/postfix-2.2.8/src/local/local.c Wed Mar 9 12:43:16 2005 --- ./src/local/local.c Sun Jan 8 15:42:54 2006 *************** *** 829,834 **** --- 829,835 ---- VAR_PROP_EXTENSION, DEF_PROP_EXTENSION, &var_prop_extension, 0, 0, VAR_DELIVER_HDR, DEF_DELIVER_HDR, &var_deliver_hdr, 0, 0, VAR_MAILBOX_LOCK, DEF_MAILBOX_LOCK, &var_mailbox_lock, 1, 0, + VAR_MAILBOX_CMD_MAPS, DEF_MAILBOX_CMD_MAPS, &var_mailbox_cmd_maps, 0, 0, 0, }; static CONFIG_BOOL_TABLE bool_table[] = { *************** *** 844,850 **** VAR_EXEC_DIRECTORY, DEF_EXEC_DIRECTORY, &var_exec_directory, 0, 0, VAR_FORWARD_PATH, DEF_FORWARD_PATH, &var_forward_path, 0, 0, VAR_MAILBOX_COMMAND, DEF_MAILBOX_COMMAND, &var_mailbox_command, 0, 0, - VAR_MAILBOX_CMD_MAPS, DEF_MAILBOX_CMD_MAPS, &var_mailbox_cmd_maps, 0, 0, VAR_LUSER_RELAY, DEF_LUSER_RELAY, &var_luser_relay, 0, 0, 0, }; --- 845,850 ---- diff -cr /var/tmp/postfix-2.2.8/src/oqmgr/qmgr_message.c ./src/oqmgr/qmgr_message.c *** /var/tmp/postfix-2.2.8/src/oqmgr/qmgr_message.c Sat Feb 12 21:16:04 2005 --- ./src/oqmgr/qmgr_message.c Mon Feb 6 22:53:46 2006 *************** *** 841,848 **** /* * Content filtering overrides the address resolver. */ ! else if (message->filter_xport) { vstring_strcpy(reply.transport, message->filter_xport); if ((nexthop = split_at(STR(reply.transport), ':')) == 0 || *nexthop == 0) --- 841,854 ---- /* * Content filtering overrides the address resolver. + * + * XXX Bypass content_filter inspection for user-generated probes + * (sendmail -bv). MTA-generated probes never have the "please filter + * me" bits turned on, but we handle them here anyway for the sake of + * future proofing. */ ! else if (message->filter_xport ! && (message->tflags & DEL_REQ_TRACE_ONLY_MASK) == 0) { vstring_strcpy(reply.transport, message->filter_xport); if ((nexthop = split_at(STR(reply.transport), ':')) == 0 || *nexthop == 0) diff -cr /var/tmp/postfix-2.2.8/src/qmgr/qmgr_message.c ./src/qmgr/qmgr_message.c *** /var/tmp/postfix-2.2.8/src/qmgr/qmgr_message.c Sat Feb 12 21:13:55 2005 --- ./src/qmgr/qmgr_message.c Mon Feb 6 22:53:46 2006 *************** *** 885,892 **** /* * Content filtering overrides the address resolver. */ ! else if (message->filter_xport) { vstring_strcpy(reply.transport, message->filter_xport); if ((nexthop = split_at(STR(reply.transport), ':')) == 0 || *nexthop == 0) --- 885,898 ---- /* * Content filtering overrides the address resolver. + * + * XXX Bypass content_filter inspection for user-generated probes + * (sendmail -bv). MTA-generated probes never have the "please filter + * me" bits turned on, but we handle them here anyway for the sake of + * future proofing. */ ! else if (message->filter_xport ! && (message->tflags & DEL_REQ_TRACE_ONLY_MASK) == 0) { vstring_strcpy(reply.transport, message->filter_xport); if ((nexthop = split_at(STR(reply.transport), ':')) == 0 || *nexthop == 0) diff -cr /var/tmp/postfix-2.2.8/src/smtp/smtp.c ./src/smtp/smtp.c *** /var/tmp/postfix-2.2.8/src/smtp/smtp.c Fri Feb 11 18:57:29 2005 --- ./src/smtp/smtp.c Wed Jan 4 20:34:07 2006 *************** *** 85,90 **** --- 85,94 ---- /* Always send EHLO at the start of an SMTP session. /* .IP "\fBsmtp_never_send_ehlo (no)\fR" /* Never send EHLO at the start of an SMTP session. + /* .IP "\fBsmtp_cname_overrides_servername (yes)\fR" + /* Allow DNS CNAME records to override the servername that the + /* Postfix SMTP client uses for logging, SASL password lookup, TLS + /* policy decisions, or TLS certificate verification. /* .IP "\fBsmtp_defer_if_no_mx_address_found (no)\fR" /* Defer mail delivery when no MX record resolves to an IP address. /* .IP "\fBsmtp_line_length_limit (990)\fR" *************** *** 497,502 **** --- 501,507 ---- char *var_smtp_generic_maps; char *var_prop_extension; + bool var_smtp_cname_overr; /* * Global variables. smtp_errno is set by the address lookup routines and by *************** *** 790,795 **** --- 795,801 ---- VAR_SMTP_TLS_ENFORCE_PN, DEF_SMTP_TLS_ENFORCE_PN, &var_smtp_tls_enforce_peername, VAR_SMTP_TLS_NOTEOFFER, DEF_SMTP_TLS_NOTEOFFER, &var_smtp_tls_note_starttls_offer, #endif + VAR_SMTP_CNAME_OVERR, DEF_SMTP_CNAME_OVERR, &var_smtp_cname_overr, 0, }; diff -cr /var/tmp/postfix-2.2.8/src/smtp/smtp.h ./src/smtp/smtp.h *** /var/tmp/postfix-2.2.8/src/smtp/smtp.h Wed Mar 2 13:38:21 2005 --- ./src/smtp/smtp.h Wed Jan 4 14:57:49 2006 *************** *** 164,169 **** --- 164,175 ---- #endif + + /* + * What's in a name? + */ + #define SMTP_HNAME(rr) (var_smtp_cname_overr ? (rr)->rname : (rr)->qname) + /* * smtp_session.c */ diff -cr /var/tmp/postfix-2.2.8/src/smtp/smtp_addr.c ./src/smtp/smtp_addr.c *** /var/tmp/postfix-2.2.8/src/smtp/smtp_addr.c Wed Mar 30 07:45:36 2005 --- ./src/smtp/smtp_addr.c Wed Jan 4 14:58:29 2006 *************** *** 119,125 **** msg_warn("skipping record type %s: %m", dns_strtype(addr->type)); } else { msg_info("pref %4d host %s/%s", ! addr->pref, addr->name, hostaddr.buf); } } --- 119,125 ---- msg_warn("skipping record type %s: %m", dns_strtype(addr->type)); } else { msg_info("pref %4d host %s/%s", ! addr->pref, SMTP_HNAME(addr), hostaddr.buf); } } diff -cr /var/tmp/postfix-2.2.8/src/smtp/smtp_connect.c ./src/smtp/smtp_connect.c *** /var/tmp/postfix-2.2.8/src/smtp/smtp_connect.c Sat Nov 5 21:00:04 2005 --- ./src/smtp/smtp_connect.c Wed Jan 4 14:58:39 2006 *************** *** 228,234 **** SOCKADDR_TO_HOSTADDR(sa, salen, &hostaddr, (MAI_SERVPORT_STR *) 0, 0); if (msg_verbose) msg_info("%s: trying: %s[%s] port %d...", ! myname, addr->name, hostaddr.buf, ntohs(port)); if (var_smtp_conn_tmout > 0) { non_blocking(sock, NON_BLOCKING); conn_stat = timed_connect(sock, sa, salen, var_smtp_conn_tmout); --- 228,234 ---- SOCKADDR_TO_HOSTADDR(sa, salen, &hostaddr, (MAI_SERVPORT_STR *) 0, 0); if (msg_verbose) msg_info("%s: trying: %s[%s] port %d...", ! myname, SMTP_HNAME(addr), hostaddr.buf, ntohs(port)); if (var_smtp_conn_tmout > 0) { non_blocking(sock, NON_BLOCKING); conn_stat = timed_connect(sock, sa, salen, var_smtp_conn_tmout); *************** *** 240,246 **** } if (conn_stat < 0) { vstring_sprintf(why, "connect to %s[%s]: %m", ! addr->name, hostaddr.buf); smtp_errno = SMTP_ERR_RETRY; close(sock); return (0); --- 240,246 ---- } if (conn_stat < 0) { vstring_sprintf(why, "connect to %s[%s]: %m", ! SMTP_HNAME(addr), hostaddr.buf); smtp_errno = SMTP_ERR_RETRY; close(sock); return (0); *************** *** 251,257 **** */ if (read_wait(sock, var_smtp_helo_tmout) < 0) { vstring_sprintf(why, "connect to %s[%s]: read timeout", ! addr->name, hostaddr.buf); smtp_errno = SMTP_ERR_RETRY; close(sock); return (0); --- 251,257 ---- */ if (read_wait(sock, var_smtp_helo_tmout) < 0) { vstring_sprintf(why, "connect to %s[%s]: read timeout", ! SMTP_HNAME(addr), hostaddr.buf); smtp_errno = SMTP_ERR_RETRY; close(sock); return (0); *************** *** 263,269 **** stream = vstream_fdopen(sock, O_RDWR); if ((ch = VSTREAM_GETC(stream)) == VSTREAM_EOF) { vstring_sprintf(why, "connect to %s[%s]: server dropped connection without sending the initial SMTP greeting", ! addr->name, hostaddr.buf); smtp_errno = SMTP_ERR_RETRY; vstream_fclose(stream); return (0); --- 263,269 ---- stream = vstream_fdopen(sock, O_RDWR); if ((ch = VSTREAM_GETC(stream)) == VSTREAM_EOF) { vstring_sprintf(why, "connect to %s[%s]: server dropped connection without sending the initial SMTP greeting", ! SMTP_HNAME(addr), hostaddr.buf); smtp_errno = SMTP_ERR_RETRY; vstream_fclose(stream); return (0); *************** *** 281,293 **** VSTRING *salvage_buf = smtp_salvage(stream); vstring_sprintf(why, "connect to %s[%s]: server refused to talk to me: %s", ! addr->name, hostaddr.buf, STR(salvage_buf)); vstring_free(salvage_buf); smtp_errno = SMTP_ERR_RETRY; vstream_fclose(stream); return (0); } ! return (smtp_session_alloc(stream, dest, addr->name, hostaddr.buf, port, sess_flags)); } --- 281,293 ---- VSTRING *salvage_buf = smtp_salvage(stream); vstring_sprintf(why, "connect to %s[%s]: server refused to talk to me: %s", ! SMTP_HNAME(addr), hostaddr.buf, STR(salvage_buf)); vstring_free(salvage_buf); smtp_errno = SMTP_ERR_RETRY; vstream_fclose(stream); return (0); } ! return (smtp_session_alloc(stream, dest, SMTP_HNAME(addr), hostaddr.buf, port, sess_flags)); } diff -cr /var/tmp/postfix-2.2.8/src/smtp/smtp_session.c ./src/smtp/smtp_session.c *** /var/tmp/postfix-2.2.8/src/smtp/smtp_session.c Sun Mar 20 11:25:22 2005 --- ./src/smtp/smtp_session.c Wed Feb 1 20:03:37 2006 *************** *** 128,141 **** #ifdef USE_TLS /* ! * Per-site policies can override main.cf settings. */ ! typedef struct { ! int dont_use; /* don't use TLS */ ! int use; /* useless, see above */ ! int enforce; /* must always use TLS */ ! int enforce_peername; /* must verify certificate name */ ! } SMTP_TLS_SITE_POLICY; static MAPS *tls_per_site; /* lookup table(s) */ --- 128,147 ---- #ifdef USE_TLS /* ! * TLS enforcement level. Actual TLS policies will be NONE or higher. ! * ! * There are two pseudo levels: NOTFOUND is a sentinel value for the ease of ! * implementation; MAY is a wild-card that indicates "anything goes". ! * ! * Non pseudo levels can also be used to indicate the actual security level of ! * a session. */ ! #define SMTP_TLS_LEV_NOTFOUND (-1) /* sentinel */ ! #define SMTP_TLS_LEV_NONE 0 /* plain-text only */ ! #define SMTP_TLS_LEV_MAY 1 /* wildcard */ ! #define SMTP_TLS_LEV_ENCRYPT 2 /* encrypted connection */ ! #define SMTP_TLS_LEV_VERIFY 3 /* certificate verified */ ! #define SMTP_TLS_LEV_STRICT 4 /* "secure" verification */ static MAPS *tls_per_site; /* lookup table(s) */ *************** *** 147,155 **** DICT_FLAG_LOCK); } /* smtp_tls_site_policy - look up per-site TLS policy */ ! static void smtp_tls_site_policy(SMTP_TLS_SITE_POLICY *policy, const char *site_name, const char *site_class) { --- 153,173 ---- DICT_FLAG_LOCK); } + /* smtp_tls_policy_print - print policy level */ + + static void smtp_tls_policy_print(const char *name, int level) + { + msg_info("%s TLS level: %s", name, + level == SMTP_TLS_LEV_VERIFY ? "verify" : + level == SMTP_TLS_LEV_ENCRYPT ? "encrypt" : + level == SMTP_TLS_LEV_MAY ? "may" : + level == SMTP_TLS_LEV_NONE ? "none" : + "unknown"); + } + /* smtp_tls_site_policy - look up per-site TLS policy */ ! static void smtp_tls_site_policy(int *site_level, const char *site_name, const char *site_class) { *************** *** 157,189 **** char *lookup_key; /* ! * Initialize the default policy. ! */ ! policy->dont_use = 0; ! policy->use = 0; ! policy->enforce = 0; ! policy->enforce_peername = 0; ! ! /* ! * Look up a non-default policy. */ lookup_key = lowercase(mystrdup(site_name)); if ((lookup = maps_find(tls_per_site, lookup_key, 0)) != 0) { ! if (!strcasecmp(lookup, "NONE")) ! policy->dont_use = 1; ! else if (!strcasecmp(lookup, "MAY")) ! policy->use = 1; ! else if (!strcasecmp(lookup, "MUST")) ! policy->enforce = policy->enforce_peername = 1; ! else if (!strcasecmp(lookup, "MUST_NOPEERMATCH")) ! policy->enforce = 1; ! else msg_warn("Table %s: ignoring unknown TLS policy '%s' for %s %s", var_smtp_tls_per_site, lookup, site_class, site_name); } myfree(lookup_key); } #endif /* smtp_session_alloc - allocate and initialize SMTP_SESSION structure */ --- 175,275 ---- char *lookup_key; /* ! * Look up a non-default policy. In case of multiple lookup results, the ! * precedence order is a permutation of the TLS enforcement level order: ! * VERIFY, ENCRYPT, NONE, MAY, NOTFOUND. I.e. we override MAY with a more ! * specific policy including NONE, otherwise we choose the stronger ! * enforcement level. */ lookup_key = lowercase(mystrdup(site_name)); if ((lookup = maps_find(tls_per_site, lookup_key, 0)) != 0) { ! if (!strcasecmp(lookup, "NONE")) { ! /* NONE overrides MAY or NOTFOUND. */ ! if (*site_level <= SMTP_TLS_LEV_MAY) ! *site_level = SMTP_TLS_LEV_NONE; ! } else if (!strcasecmp(lookup, "MAY")) { ! /* MAY overrides NOTFOUND but not NONE. */ ! if (*site_level < SMTP_TLS_LEV_NONE) ! *site_level = SMTP_TLS_LEV_MAY; ! } else if (!strcasecmp(lookup, "MUST_NOPEERMATCH")) { ! if (*site_level < SMTP_TLS_LEV_ENCRYPT) ! *site_level = SMTP_TLS_LEV_ENCRYPT; ! } else if (!strcasecmp(lookup, "MUST")) { ! if (*site_level < SMTP_TLS_LEV_VERIFY) ! *site_level = SMTP_TLS_LEV_VERIFY; ! } else { msg_warn("Table %s: ignoring unknown TLS policy '%s' for %s %s", var_smtp_tls_per_site, lookup, site_class, site_name); + } } myfree(lookup_key); } + /* smtp_tls_level_init - configure session TLS enforcement level */ + + static int smtp_tls_level_init(const char *dest, const char *host) + { + int global_level; + int site_level; + int tls_level; + + /* + * Compute the global TLS policy. This is the default policy level when + * no per-site policy exists. It also is used to override a wild-card + * per-site policy. + */ + if (var_smtp_enforce_tls) + global_level = var_smtp_tls_enforce_peername ? + SMTP_TLS_LEV_VERIFY : SMTP_TLS_LEV_ENCRYPT; + else + global_level = var_smtp_use_tls ? + SMTP_TLS_LEV_MAY : SMTP_TLS_LEV_NONE; + if (msg_verbose) + smtp_tls_policy_print("global", global_level); + + /* + * Compute the per-site TLS enforcement level. For compatibility with the + * original TLS patch, this algorithm is gives equal precedence to host + * and next-hop policies. + */ + site_level = SMTP_TLS_LEV_NOTFOUND; + + if (tls_per_site) { + smtp_tls_site_policy(&site_level, dest, "next-hop destination"); + if (strcasecmp(dest, host) != 0) + smtp_tls_site_policy(&site_level, host, "server hostname"); + if (msg_verbose) + smtp_tls_policy_print("site", site_level); + } + + /* + * Override a wild-card per-site policy with a more specific global + * policy. + * + * With the original TLS patch, 1) a per-site ENCRYPT could not override a + * global VERIFY, and 2) a combined per-site (NONE+MAY) policy produced + * inconsistent results: it changed a global VERIFY into NONE, while + * producing MAY with all weaker global policy settings. + * + * With the current implementation, a combined per-site (NONE+MAY) + * consistently overrides global policy with NONE, and global policy can + * override only a per-site MAY wildcard. That is, specific policies + * consistently override wildcard policies, and (non-wildcard) per-site + * policies consistently override global policies. + */ + if (site_level == SMTP_TLS_LEV_NOTFOUND + || (site_level == SMTP_TLS_LEV_MAY + && global_level > SMTP_TLS_LEV_MAY)) + tls_level = global_level; + else + tls_level = site_level; + + if (msg_verbose && tls_per_site) + smtp_tls_policy_print("effective", tls_level); + + return (tls_level); + } + #endif /* smtp_session_alloc - allocate and initialize SMTP_SESSION structure */ *************** *** 194,205 **** { SMTP_SESSION *session; - #ifdef USE_TLS - SMTP_TLS_SITE_POLICY host_policy; - SMTP_TLS_SITE_POLICY rcpt_policy; - - #endif - session = (SMTP_SESSION *) mymalloc(sizeof(*session)); session->stream = stream; session->dest = mystrdup(dest); --- 280,285 ---- *************** *** 236,274 **** session->tls_enforce_peername = 0; session->tls_context = 0; session->tls_info = tls_info_zero; ! ! /* ! * Override the main.cf TLS policy with an optional per-site policy. ! */ ! if (smtp_tls_ctx != 0) { ! smtp_tls_site_policy(&host_policy, host, "receiving host"); ! smtp_tls_site_policy(&rcpt_policy, dest, "recipient domain"); ! ! /* ! * Set up TLS enforcement for this session. ! */ ! if ((var_smtp_enforce_tls && !host_policy.dont_use && !rcpt_policy.dont_use) ! || host_policy.enforce || rcpt_policy.enforce) ! session->tls_enforce_tls = session->tls_use_tls = 1; ! ! /* ! * Set up peername checking for this session. ! * ! * We want to make sure that a MUST* entry in the tls_per_site table ! * always has precedence. MUST always must lead to a peername check, ! * MUST_NOPEERMATCH must always disable it. Only when no explicit ! * setting has been found, the default will be used. There is the ! * case left, that both "host" and "recipient" settings conflict. In ! * this case, the "host" setting wins. ! */ ! if (host_policy.enforce && host_policy.enforce_peername) ! session->tls_enforce_peername = 1; ! else if (rcpt_policy.enforce && rcpt_policy.enforce_peername) ! session->tls_enforce_peername = 1; ! else if (var_smtp_enforce_tls && var_smtp_tls_enforce_peername) ! session->tls_enforce_peername = 1; ! else if ((var_smtp_use_tls && !host_policy.dont_use && !rcpt_policy.dont_use) || host_policy.use || rcpt_policy.use) ! session->tls_use_tls = 1; } #endif debug_peer_check(host, addr); --- 316,329 ---- session->tls_enforce_peername = 0; session->tls_context = 0; session->tls_info = tls_info_zero; ! switch (smtp_tls_level_init(dest, host)) { ! case SMTP_TLS_LEV_VERIFY: ! session->tls_enforce_peername = 1; ! case SMTP_TLS_LEV_ENCRYPT: ! session->tls_enforce_tls = 1; ! case SMTP_TLS_LEV_MAY: ! session->tls_use_tls = 1; ! break; } #endif debug_peer_check(host, addr); diff -cr /var/tmp/postfix-2.2.8/src/smtpd/smtpd_check.c ./src/smtpd/smtpd_check.c *** /var/tmp/postfix-2.2.8/src/smtpd/smtpd_check.c Mon Nov 28 17:28:45 2005 --- ./src/smtpd/smtpd_check.c Fri Feb 3 15:06:51 2006 *************** *** 2314,2320 **** (VSTRING *) 0, (VSTRING *) 0); if (dns_status == DNS_NOTFOUND && h_errno == NO_DATA) { if (type == T_MX) { ! server_list = dns_rr_create(domain, type, C_IN, 0, 0, domain, strlen(domain) + 1); dns_status = DNS_OK; } else if (type == T_NS) { --- 2314,2320 ---- (VSTRING *) 0, (VSTRING *) 0); if (dns_status == DNS_NOTFOUND && h_errno == NO_DATA) { if (type == T_MX) { ! server_list = dns_rr_create(domain, domain, type, C_IN, 0, 0, domain, strlen(domain) + 1); dns_status = DNS_OK; } else if (type == T_NS) { *************** *** 3467,3484 **** msg_warn("restriction `%s' after `%s' is ignored", cpp[1], CHECK_RELAY_DOMAINS); } else if (strcasecmp(name, PERMIT_SASL_AUTH) == 0) { - if (var_smtpd_sasl_enable) #ifdef USE_SASL_AUTH status = permit_sasl_auth(state, SMTPD_CHECK_OK, SMTPD_CHECK_DUNNO); - #else - msg_warn("restriction `%s' ignored: no SASL support", name); #endif #ifdef USE_TLS } else if (strcasecmp(name, PERMIT_TLS_ALL_CLIENTCERTS) == 0) { ! status = permit_tls_clientcerts(state, 1); } else if (strcasecmp(name, PERMIT_TLS_CLIENTCERTS) == 0) { ! status = permit_tls_clientcerts(state, 0); #endif } else if (strcasecmp(name, REJECT_UNKNOWN_RCPTDOM) == 0) { if (state->recipient) --- 3467,3482 ---- msg_warn("restriction `%s' after `%s' is ignored", cpp[1], CHECK_RELAY_DOMAINS); } else if (strcasecmp(name, PERMIT_SASL_AUTH) == 0) { #ifdef USE_SASL_AUTH + if (var_smtpd_sasl_enable) status = permit_sasl_auth(state, SMTPD_CHECK_OK, SMTPD_CHECK_DUNNO); #endif #ifdef USE_TLS } else if (strcasecmp(name, PERMIT_TLS_ALL_CLIENTCERTS) == 0) { ! status = permit_tls_clientcerts(state, 1); } else if (strcasecmp(name, PERMIT_TLS_CLIENTCERTS) == 0) { ! status = permit_tls_clientcerts(state, 0); #endif } else if (strcasecmp(name, REJECT_UNKNOWN_RCPTDOM) == 0) { if (state->recipient) *************** *** 3631,3640 **** status = SMTPD_CHECK_OK; } else if (strcasecmp(name, PERMIT_SASL_AUTH) == 0) { #ifdef USE_SASL_AUTH ! status = permit_sasl_auth(state, SMTPD_CHECK_OK, ! SMTPD_CHECK_DUNNO); ! #else ! status = SMTPD_CHECK_DUNNO; #endif #ifdef USE_TLS } else if (strcasecmp(name, PERMIT_TLS_ALL_CLIENTCERTS) == 0) { --- 3629,3637 ---- status = SMTPD_CHECK_OK; } else if (strcasecmp(name, PERMIT_SASL_AUTH) == 0) { #ifdef USE_SASL_AUTH ! if (var_smtpd_sasl_enable) ! status = permit_sasl_auth(state, SMTPD_CHECK_OK, ! SMTPD_CHECK_DUNNO); #endif #ifdef USE_TLS } else if (strcasecmp(name, PERMIT_TLS_ALL_CLIENTCERTS) == 0) { *************** *** 4337,4342 **** --- 4334,4340 ---- char *var_verify_sender; char *var_smtpd_sasl_opts; char *var_local_rwr_clients; + char *var_smtpd_relay_ccerts; typedef struct { char *name; *************** *** 4379,4384 **** --- 4377,4383 ---- VAR_MAIL_NAME, DEF_MAIL_NAME, &var_mail_name, VAR_SMTPD_SASL_OPTS, DEF_SMTPD_SASL_OPTS, &var_smtpd_sasl_opts, VAR_LOC_RWR_CLIENTS, DEF_LOC_RWR_CLIENTS, &var_local_rwr_clients, + VAR_RELAY_CCERTS, DEF_RELAY_CCERTS, &var_smtpd_relay_ccerts, 0, }; diff -cr /var/tmp/postfix-2.2.8/src/smtpd/smtpd_exp.ref ./src/smtpd/smtpd_exp.ref *** /var/tmp/postfix-2.2.8/src/smtpd/smtpd_exp.ref Mon Oct 25 16:59:11 2004 --- ./src/smtpd/smtpd_exp.ref Wed Jan 18 20:11:38 2006 *************** *** 107,114 **** >>> mail sname@sdomain OK >>> rcpt rname@rdomain ! ./smtpd_check: : reject: RCPT from spike.porcupine.org[168.100.189.2]: 554 Service unavailable; Helo command [example.tld] blocked using abuse.rfc-ignorant.org; Not supporting abuse@domain; from= to= proto=SMTP helo= ! 554 Service unavailable; Helo command [example.tld] blocked using abuse.rfc-ignorant.org; Not supporting abuse@domain >>> # >>> # Check MX access >>> # --- 107,114 ---- >>> mail sname@sdomain OK >>> rcpt rname@rdomain ! ./smtpd_check: : reject: RCPT from spike.porcupine.org[168.100.189.2]: 554 Service unavailable; Helo command [example.tld] blocked using abuse.rfc-ignorant.org; Not supporting abuse@example.tld; from= to= proto=SMTP helo= ! 554 Service unavailable; Helo command [example.tld] blocked using abuse.rfc-ignorant.org; Not supporting abuse@example.tld >>> # >>> # Check MX access >>> # diff -cr /var/tmp/postfix-2.2.8/src/trivial-rewrite/rewrite.c ./src/trivial-rewrite/rewrite.c *** /var/tmp/postfix-2.2.8/src/trivial-rewrite/rewrite.c Thu Feb 3 15:35:07 2005 --- ./src/trivial-rewrite/rewrite.c Mon Jan 30 20:16:18 2006 *************** *** 173,179 **** /* * Append missing @origin */ ! else if (var_append_at_myorigin != 0) { domain = tok822_sub_append(tree, tok822_alloc('@', (char *) 0)); tok822_sub_append(tree, tok822_scan(REW_PARAM_VALUE(context->origin), (TOK822 **) 0)); --- 173,180 ---- /* * Append missing @origin */ ! else if (var_append_at_myorigin != 0 ! && context->origin[0][0] != 0) { domain = tok822_sub_append(tree, tok822_alloc('@', (char *) 0)); tok822_sub_append(tree, tok822_scan(REW_PARAM_VALUE(context->origin), (TOK822 **) 0)); *************** *** 186,191 **** --- 187,193 ---- * alone. */ if (var_append_dot_mydomain != 0 + && context->domain[0][0] != 0 && (domain = tok822_rfind_type(tree->tail, '@')) != 0 && domain != tree->tail && tok822_find_type(domain, TOK822_DOMLIT) == 0