]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
snapshot-19991227
authorWietse Venema <wietse@porcupine.org>
Mon, 27 Dec 1999 05:00:00 +0000 (00:00 -0500)
committerWietse Venema <wietse@porcupine.org>
Thu, 17 Jan 2013 23:10:04 +0000 (18:10 -0500)
15 files changed:
postfix/BEWARE
postfix/HISTORY
postfix/RELEASE_NOTES
postfix/conf/main.cf
postfix/conf/sample-smtpd.cf
postfix/global/mail_params.h
postfix/global/mail_version.h
postfix/global/resolve_clnt.c
postfix/html/faq.html
postfix/html/smtpd.8.html
postfix/html/uce.html
postfix/man/man8/smtpd.8
postfix/smtpd/smtpd.c
postfix/smtpd/smtpd_check.c
postfix/trivial-rewrite/resolve.c

index 89cf9f8a0d8353093c32985ce4426d9082db679c..10adbd496f0805608a420eaa4aa0ab363cbed87e 100644 (file)
@@ -7,44 +7,3 @@ disable synchronous logfile writes by prepending a - to the logfile
 name:
 
     mail.*                          -/var/log/mail.log
-
-SPAM BLOCKING SOURCE ROUTED ADDRESSES
-=====================================
-
-If you are responsible for a backup MX host for some domain (either
-your own domain or the domain of some other organization) it is
-prudent to block addresses with multiple address operators at the
-SMTP port, such as:
-
-    user@elsewhere@some.domain
-    user%elsewhere@some.domain
-    elsewhere!user@some.domain
-
-The problem is that the primary MX host for some.domain may forward
-the above to user@elsewhere. This can happen because the primary
-MX host somehow "trusts" your backup MX host, or because the primary
-MX host is badly configured.
-
-The bad news is that your backup MX machine can end up on a black
-list because it accepted the mail, even though the problem involves
-a primary MX host that perhaps is not under your control.
-
-The simplest solution is to install a regular expression filter:
-
-    /etc/postfix/main.cf: 
-       smtpd_recipient_restrictions = 
-           regexp:/etc/postfix/regexp_access
-           ...other restrictions...
-
-    /etc/postfix/regexp_access:
-       /[%!@].*[%!@]/ 550 Sender specified routing is not supported here.
-
-For the local domain, Postfix will do the right thing with:
-
-    user@elsewhere@my.own.domain
-    user%elsewhere@my.own.domain
-    elsewhere!user@my.own.domain
-
-That is, it bounces the first form because "user@elsewhere" is not
-a valid local user, and it accepts the second and third forms only
-when user@elsewhere is a valid relay destination.
index b87f5c7b9d167c743df2f9195ed541d090ec7de0..31cc0327f1ff0df70f6399fefc11ffda020fbdf6 100644 (file)
@@ -3477,20 +3477,21 @@ Apologies for any names omitted.
        Bugfix: the relative symlink code in INSTALL.sh computed
        the ../ prefix from the wrong pathname.
 
-1999122[56]
-
-       Feature: "allow_routed_relaying = no" (default) disallows
-       forwarding of mail with sender-specified routing (example:
-       user%domain2@domain1, user@domain2@domain1, etc.). This
-       plugs an "open relay" loophole where a backup MX host would
-       forward junk mail to a primary MX host which would forward
-       it to the Internet.  Files:  global/quote_822_local.c,
-       smtp/quote_821_local.c, trivial-rewrite/rewrite.c,
-       trivial-rewrite/resolve.c, smtp/smtpd_check.c.
-
-       In order to make this possible, the resolver now passes a
-       status back to the client that says if the result is a
-       routed address.
+1999122[5-7]
+
+       Feature: "allow_untrusted_routing = no" (default) prevents
+       forwarding of source-routed mail from untrusted clients to
+       destinations that are blessed by the relay_domains parameter
+       (example:  user@domain2@domain1 etc.).  This plugs a mail
+       relay loophole where a backup MX host forwards junk mail
+       to a primary MX host which forwards the junk to the Internet.
+       Files:  global/quote_822_local.c, smtp/quote_821_local.c,
+       trivial-rewrite/rewrite.c, trivial-rewrite/resolve.c,
+       smtp/smtpd_check.c.
+
+       In order to make this possible, the Postfix resolver data
+       structure and protocol has changed, so that all resolver
+       clients need to be re-compiled.
 
        Side effect from the above change: from now on, an address
        with @ in the recipient localpart no longer bounces with
index 57de191255265859839fbeb25d7be208ca465539..ebdd3f7833701124514ea1849676d747c0d87fa0 100644 (file)
@@ -1,19 +1,22 @@
-Incompatible changes with snapshot 19991226
+Incompatible changes with snapshot 19991227
 ===========================================
 
-- The SMTP server by default no longer forwards mail to non-local
-destinations with sender-specified routing (stuff[@%!]stuff[@%!]stuff).
-This closes an open relay loophole with primary and secondary MX
-hosts.  To get old behavior, specify "allow_routed_relaying = yes".
+- The SMTP server no longer forwards mail from untrusted clients
+with sender-specified routing (stuff[@%!]stuff[@%!]stuff) to
+destinations that are authorized by the relay_domains parameter.
+This closes a loophole that exploits trust relationships between
+hosts.  Example:  a trusted backup MX host forwards junk mail to
+a primary MX host which forwards the junk to the Internet. Specify
+"allow_untrusted_routing = yes" to restore the old behavior.
 
 - In order to support the above, the data structure and protocol
 of the trivial-rewrite service was changed. This means you must
 re-compile and re-link existing software that uses the Postfix
 resolve_clnt interface.
 
-- As a side effect of the above, an address with @ in the localpart
-(user@there@here) no longer bounces with "user unknown" but instead
-is rejected with "relay access denied".
+- As a side effect of the above, an address from an untrusted client
+with @ in the localpart (user@remote@here) no longer bounces with
+"user unknown" but instead is rejected with "relay access denied".
 
 - The experimental permit_recipient_map and local_transports features
 are gone. They were never part of an official release.  Both are
@@ -40,7 +43,7 @@ transport maps, it is better to always have explicit entries for
 all domain names you have in $mydestination.  See the html/faq.html
 sections for firewalls and intranets.
 
-Major changes with snapshot 19991226
+Major changes with snapshot 19991227
 ====================================
 
 - It is now much more difficult to configure Postfix as an open
@@ -49,12 +52,13 @@ contains at least one restriction that by default refuses mail (as
 is the default).  There were too many accidents with changes to
 the UCE restrictions.
 
-- An "open relay" loophole is now plugged where a backup MX host
-would forward stuff[@%!]stuff[@%!]stuff to a primary MX host which
-would then spam it out to the world.  To get the old behavior,
-specify "allow_routed_relaying = yes".  The old behavior is safe
-only for non-MX hosts, and for primary MX hosts of domains that
-have no backup MX hosts.
+- The SMTP server no longer forwards mail from untrusted clients
+with sender-specified routing (stuff[@%!]stuff[@%!]stuff) to
+destinations that are authorized by the relay_domains parameter.
+This closes a loophole that exploits trust relationships between
+hosts.  Example:  a trusted backup MX host forwards junk mail to
+a primary MX host which forwards the junk to the Internet. Specify
+"allow_untrusted_routing = yes" to restore the old behavior.
 
 - The relay_domains parameter no longer needs to contain $virtual_maps.
 
index 7aa37deffc3f75a98ec56045dd29004856d31fd8..538eb04e9d4a1fa67981a938436e9406f58203b0 100644 (file)
@@ -278,9 +278,10 @@ mail_owner = postfix
 # file sample-smtpd.cf.
 #
 # By default, Postfix relays mail
-# - from clients whose IP address matches $mynetworks, 
-# - from clients matching $relay_domains or subdomains thereof,
-# - to destinations that match $relay_domains or subdomains thereof.
+# - from trusted clients whose IP address matches $mynetworks, 
+# - from trusted clients matching $relay_domains or subdomains thereof,
+# - from untrusted clients to destinations that match $relay_domains
+#   or subdomains thereof, except addresses with sender-specified routing.
 # The default relay_domains value is $mydestination.
 # 
 # In addition to the above, the Postfix SMTP server by default accepts mail
index 22dac53d9954c9e9588bcd80c14ebd5457a7aa47..f662bfa2ce59d60bf18063dd9b37eefc3feedf56 100644 (file)
@@ -188,9 +188,10 @@ smtpd_sender_restrictions =
 # recipient addresses that SMTP clients can send in RCPT TO commands.
 # 
 # By default, Postfix relays mail
-# - from clients whose IP address matches $mynetworks,
-# - from clients matching $relay_domains or subdomains thereof,
-# - to destinations that match $relay_domains or subdomains thereof.
+# - from trusted clients whose IP address matches $mynetworks,
+# - from trusted clients matching $relay_domains or subdomains thereof,
+# - from untrusted clients to destinations that match $relay_domains
+#   or subdomains thereof, except addresses with sender-specified routing.
 # The default relay_domains value is $mydestination.
 #
 # In addition to the above, the Postfix SMTP server by default accepts mail
@@ -209,19 +210,22 @@ smtpd_sender_restrictions =
 #   reject_unknown_hostname: reject HELO hostname without DNS A or MX record.
 #   reject_unknown_sender_domain: reject sender domain without A or MX record.
 #  *check_relay_domains: permit only mail 
-#      - from clients matching $relay_domains or subdomain thereof,
-#      - to destinations matching $relay_domains or subdomain thereof,
 #      - to destinations matching $inet_interfaces, $mydestination, 
-#        or $virtual_maps.
+#        or $virtual_maps,
+#      - from trusted clients matching $relay_domains or subdomain thereof,
+#      - from untrusted clients to destinations matching $relay_domains or
+#        subdomain thereof (except addresses with sender-specified routing),
 #      Reject anything else.
 #   permit_auth_destination: permit mail 
-#      - to destinations matching $relay_domains or subdomain thereof,
 #      - to destinations matching $inet_interfaces, $mydestination, 
 #        or $virtual_maps.
-#   reject_unauth_destination: reject mail unless it is sent 
 #      - to destinations matching $relay_domains or subdomain thereof,
+#        except for addresses with sender-specified routing.
+#   reject_unauth_destination: reject mail unless it is sent 
 #      - to destinations matching $inet_interfaces, $mydestination, 
 #        or $virtual_maps.
+#      - to destinations matching $relay_domains or subdomain thereof,
+#        except for addresses with sender-specified routing.
 #   reject_unauth_pipelining: reject mail from improperly pipelining spamware
 #   permit_mx_backup: accept mail for sites that list me as MX host.
 #   reject_unknown_recipient_domain: reject domains without A or MX record.
@@ -254,15 +258,17 @@ smtpd_recipient_restrictions = permit_mynetworks,check_relay_domains
 # ADDITIONAL UCE CONTROLS
 #
 
-# The allow_routed_relaying parameter controls whether the host will
-# forward addresses with sender-specified routing. This is disabled
-# by default, in order to close a nasty open relay loophole where a
-# backup MX host can be tricked into forwarding mail to a primary MX
-# host which then spams it out to the world. Don't change this if
-# this system is backup MX host for any domain, or if this system
-# receives mail from any backup MX host.
-#
-allow_routed_relaying = no
+# The allow_untrusted_routing parameter controls if Postfix will
+# forward mail with sender-specified routing (user[@%!]remote[@%!]site)
+# from untrusted clients to destinations that are blessed by the
+# relay_domains parameter.
+# 
+# By default, untrusted clients are not allowed to specify routing.
+# This closes a nasty open relay loophole where a backup MX host can
+# be tricked into forwarding junk mail to a primary MX host which
+# then spams it out to the world.
+#
+allow_untrusted_routing = no
 
 # The maps_rbl_domains parameter specifies an optional list of DNS
 # domains that publish the network addresses of blacklisted hosts.
@@ -282,9 +288,10 @@ maps_rbl_domains = rbl.maps.vix.com
 # this system will relay mail to.
 # 
 # By default, Postfix relays mail
-# - from clients whose IP address matches $mynetworks, 
-# - from clients matching $relay_domains or subdomains thereof,
-# - to destinations that match $relay_domains or subdomains thereof.
+# - from trusted clients whose IP address matches $mynetworks, 
+# - from trusted clients matching $relay_domains or subdomains thereof,
+# - from untrusted clients to destinations that match $relay_domains
+#   or subdomains thereof, except addresses with sender-specified routing.
 # The default relay_domains value is $mydestination.  
 # 
 # In addition to the above, the Postfix SMTP server by default accepts mail 
index 81194ed53fffbbe143f811b6d64b2bde6e1d03fd..d01ad59777868e7a8fb192b0c918401a7066f6d2 100644 (file)
@@ -748,9 +748,9 @@ extern char *var_etrn_checks;
 #define DEF_REST_CLASSES       ""
 extern char *var_rest_classes;
 
-#define VAR_ALLOW_ROUTED_RELAY "allow_routed_relaying"
-#define DEF_ALLOW_ROUTED_RELAY 0
-extern bool var_allow_routed_relay;
+#define VAR_ALLOW_UNTRUST_ROUTE        "allow_untrusted_routing"
+#define DEF_ALLOW_UNTRUST_ROUTE        0
+extern bool var_allow_untrust_route;
 
  /*
   * Names of specific restrictions, and the corresponding configuration
index 35757105bb4b3ca92e28e9a78fcbe03e68d354ef..82bec8f2db0bf201542d4054bbde8442b3dbf7d1 100644 (file)
@@ -15,7 +15,7 @@
   * Version of this program.
   */
 #define VAR_MAIL_VERSION       "mail_version"
-#define DEF_MAIL_VERSION       "Snapshot-19991226"
+#define DEF_MAIL_VERSION       "Snapshot-19991227"
 extern char *var_mail_version;
 
 /* LICENSE
index fc86c798d374c33abcaf6b2befa0df66cb2d3ee4..ff27504a627684f376961e20ab42dd7acecbd245 100644 (file)
@@ -45,8 +45,9 @@
 /*     domain that is handled by the local machine. This flag is currently
 /*     not used.
 /* .IP RESOLVE_FLAG_ROUTED
-/*     The recipient address contains routing information, so the
-/*     destination domain is not necessarily the final destination.
+/*     After address resolution the recipient localpart contains further
+/*     routing information, so the resolved next-hop destination is not
+/*     the final destination.
 /* DIAGNOSTICS
 /*     Warnings: communication failure. Fatal error: mail system is down.
 /* SEE ALSO
index df99aa277d52c5e4973450cddfd8c1f25f089661..d5f5d8e651a262cce28cefe867c5f4350710c4c2 100644 (file)
@@ -157,8 +157,7 @@ distribution list</a>
 
 <li><a href="#command">Commands don't work in Postfix virtual maps</a>
 
-<li><a href="#unknown_virtual">Mail for unknown virtual users fails
-with a mail loop error</a>
+<li><a href="#unknown_virtual">Rejecting mail for unknown virtual users</a>
 
 <li><a href="#relay_virtual">Postfix refuses to receive mail for some
 virtual domains</a>
@@ -708,15 +707,15 @@ mail for arbitrary non-local destinations:
 
 <p>
 
-Don't Panic!  Upgrade to a Postfix version of 19991226 or later.
+Don't Panic!  Upgrade to a Postfix version of 19991227 or later.
 
 <p>
 
-Older Postfix versions would either bounce the mail because
+Older Postfix versions would either <i>bounce</i> the mail because
 "test@some.other.site" is not a known local username (which is
-good), or they would forward the mail to a primary MX host for
-"some.site" which would then spam it into the Internet (which is
-bad).
+good), or they would <i>forward</i> the mail to a primary MX host
+for "some.site" which would then spam it into the Internet (which
+is bad).
 
 <hr>
 
@@ -1481,12 +1480,15 @@ To find out the location for your system, execute the command
 
 <hr>
 
-<a name="unknown_virtual"><h3>Mail for unknown virtual users fails
-with a mail loop error</h3>
+<a name="unknown_virtual"><h3>Rejecting mail for unknown virtual users</h3>
+
+Problem: mail for an unknown virtual user is misdelivered to a local
+user with the same name.
+
+<p>
 
 Problem: mail for an unknown virtual user results in an ugly "mail
-loops back to myself" error from the Postfix SMTP client. Why
-doesn't Postfix generate a "user unknown" instead?
+loops back to myself" error from Postfix.
 
 <p>
 
index d977b5b8ffb8821705a19677154cb62b8bfcf1cd..ad4d3024fc0cd1235fa268d9039bbe4a5c3a7eeb 100644 (file)
@@ -215,48 +215,48 @@ SMTPD(8)                                                 SMTPD(8)
               Restrict what domain names can be used in <b>ETRN</b> com-
               mands, and what clients may issue <b>ETRN</b> commands.
 
+       <b>allow</b><i>_</i><b>untrusted</b><i>_</i><b>routing</b>
+              Allow untrusted clients to specify  addresses  with
+              sender-specified  routing.   Enabling this opens up
+              nasty relay loopholes involving trusted  backup  MX
+              hosts.
+
        <b>restriction</b><i>_</i><b>classes</b>
-              Declares the name of zero or more  parameters  that
-              contain  a  list  of UCE restrictions. The names of
-              these parameters can then be used  instead  of  the
+              Declares  the  name of zero or more parameters that
+              contain a list of UCE restrictions.  The  names  of
+              these  parameters  can  then be used instead of the
               restriction lists that they represent.
 
        <b>maps</b><i>_</i><b>rbl</b><i>_</i><b>domains</b>
-              List  of  DNS domains that publish the addresses of
+              List of DNS domains that publish the  addresses  of
               blacklisted hosts.
 
        <b>relay</b><i>_</i><b>domains</b>
-              Restrict what domains or networks this mail  system
+              Restrict  what domains or networks this mail system
               will relay mail from or to.
 
 <b>UCE</b> <b>control</b> <b>responses</b>
        <b>access</b><i>_</i><b>map</b><i>_</i><b>reject</b><i>_</i><b>code</b>
-              Server  response  when  a client violates an access
+              Server response when a client  violates  an  access
               database restriction.
 
        <b>invalid</b><i>_</i><b>hostname</b><i>_</i><b>reject</b><i>_</i><b>code</b>
-              Server  response  when  a   client   violates   the
+              Server   response   when   a  client  violates  the
               <b>reject</b><i>_</i><b>invalid</b><i>_</i><b>hostname</b> restriction.
 
        <b>maps</b><i>_</i><b>rbl</b><i>_</i><b>reject</b><i>_</i><b>code</b>
-              Server   response   when   a  client  violates  the
+              Server  response  when  a   client   violates   the
               <b>maps</b><i>_</i><b>rbl</b><i>_</i><b>domains</b> restriction.
 
        <b>reject</b><i>_</i><b>code</b>
-              Response code when  the  client  matches  a  <b>reject</b>
+              Response  code  when  the  client  matches a <b>reject</b>
               restriction.
 
        <b>relay</b><i>_</i><b>domains</b><i>_</i><b>reject</b><i>_</i><b>code</b>
-              Server  response  when a client attempts to violate
+              Server response when a client attempts  to  violate
               the mail relay policy.
 
-       <b>unknown</b><i>_</i><b>address</b><i>_</i><b>reject</b><i>_</i><b>code</b>
-              Server  response  when  a   client   violates   the
-              <b>reject</b><i>_</i><b>unknown</b><i>_</i><b>address</b> restriction.
 
-       <b>unknown</b><i>_</i><b>client</b><i>_</i><b>reject</b><i>_</i><b>code</b>
-              Server  response  when  a client without address to
-              name mapping  violates  the  <b>reject</b><i>_</i><b>unknown</b><i>_</i><b>clients</b>
 
 
 
@@ -269,10 +269,17 @@ SMTPD(8)                                                 SMTPD(8)
 SMTPD(8)                                                 SMTPD(8)
 
 
+       <b>unknown</b><i>_</i><b>address</b><i>_</i><b>reject</b><i>_</i><b>code</b>
+              Server   response   when   a  client  violates  the
+              <b>reject</b><i>_</i><b>unknown</b><i>_</i><b>address</b> restriction.
+
+       <b>unknown</b><i>_</i><b>client</b><i>_</i><b>reject</b><i>_</i><b>code</b>
+              Server response when a client  without  address  to
+              name  mapping  violates  the <b>reject</b><i>_</i><b>unknown</b><i>_</i><b>clients</b>
               restriction.
 
        <b>unknown</b><i>_</i><b>hostname</b><i>_</i><b>reject</b><i>_</i><b>code</b>
-              Server   response   when   a  client  violates  the
+              Server  response  when  a   client   violates   the
               <b>reject</b><i>_</i><b>unknown</b><i>_</i><b>hostname</b> restriction.
 
 <b>SEE</b> <b>ALSO</b>
@@ -281,7 +288,7 @@ SMTPD(8)                                                 SMTPD(8)
        syslogd(8) system logging
 
 <b>LICENSE</b>
-       The Secure Mailer license must be  distributed  with  this
+       The  Secure  Mailer  license must be distributed with this
        software.
 
 <b>AUTHOR(S)</b>
@@ -311,13 +318,6 @@ SMTPD(8)                                                 SMTPD(8)
 
 
 
-
-
-
-
-
-
-
 
 
 
index 857dcd193465ffd71bfdd92a8167bcffd3c89a3e..7c82ad5d92130855cf46e66354c17b01dfdd497b 100644 (file)
@@ -575,14 +575,16 @@ relays mail:
 
 <ul>
 
-<li>from clients whose IP address matches <a
+<li>from trusted clients whose IP address matches <a
 href="basic.html#mynetworks">$mynetworks</a>,
 
-<li>from clients whose hostname matches <a
+<li>from trusted clients whose hostname matches <a
 href="#relay_domains">$relay_domains</a> or a subdomain thereof,
 
-<li>to destinations that match <a href="#relay_domains">
-$relay_domains</a> or a subdomain thereof.
+<li>from untrusted clients to destinations that match <a
+href="#relay_domains"> $relay_domains</a> or a subdomain thereof,
+except for addresses that contain sender-specified routing
+(<i>user@there@here</i>).
 
 </ul>
 
@@ -625,9 +627,6 @@ on the client hostname or network address.
 
 <dt> Example:
 
-<dd> <b>smtpd_recipient_restrictions = permit_mynetworks,
-check_relay_domains</b>
-
 <dd> <b>smtpd_recipient_restrictions = permit_mynetworks,
 reject_unauth_destination</b>
 
@@ -647,6 +646,7 @@ mail otherwise. </i>
 <a name="check_relay_domains">
 
 <dt> <b>check_relay_domains</b> <dd> Permit the request when 
+one of the following is true:
 
 <ul>
 
@@ -655,6 +655,8 @@ or a subdomain thereof,
 
 <li>the resolved destination address matches <a
 href="#relay_domains">$relay_domains</a> or a subdomain thereof,
+and the address contains no sender-specified routing
+(<i>user@there@here</i>),
 
 <li>Postfix is the final destination:  any destination that matches
 <a href="basic.html#mydestination">$mydestination</a>, <a
@@ -678,6 +680,8 @@ Permit the request when:
 
 <li>the resolved destination address matches <a
 href="#relay_domains">$relay_domains</a> or a subdomain thereof,
+and the address contains no sender-specified routing
+(<i>user@there@here</i>),
 
 <li>Postfix is the final destination:  any destination that matches
 <a href="basic.html#mydestination">$mydestination</a>, <a
@@ -699,6 +703,8 @@ hostname.  Reject the request unless:
 
 <li>the resolved destination address matches <a
 href="#relay_domains">$relay_domains</a> or a subdomain thereof,
+and the address contains no sender-specified routing
+(<i>user@there@here</i>),
 
 <li>Postfix is the final destination:  any destination that matches
 <a href="basic.html#mydestination">$mydestination</a>, <a
@@ -1014,14 +1020,16 @@ relays mail:
 
 <ul>
 
-<li>from clients whose IP address matches <a
+<li>from trusted clients whose IP address matches <a
 href="basic.html#mynetworks">$mynetworks</a>,
 
-<li>from clients whose hostname matches <a
+<li>from trusted clients whose hostname matches <a
 href="#relay_domains">$relay_domains</a> or a subdomain thereof,
 
-<li>to destinations that match <a href="#relay_domains">
-$relay_domains</a> or a subdomain thereof.
+<li>from untrusted clients to destinations that match <a
+href="#relay_domains"> $relay_domains</a> or a subdomain thereof,
+except for addresses that contain sender-specified routing
+(<i>user@there@here</i>).
 
 </ul>
 
index 9067b806a609645d2fe27b4bc4d2b3580a51eaac..fbc3225ba2ad9ca22d346ad731d149bbf40a4c71 100644 (file)
@@ -157,6 +157,10 @@ Restrict what recipient addresses are allowed in \fBRCPT TO\fR commands.
 .IP \fBsmtpd_etrn_restrictions\fR
 Restrict what domain names can be used in \fBETRN\fR commands,
 and what clients may issue \fBETRN\fR commands.
+.IP \fBallow_untrusted_routing\fR
+Allow untrusted clients to specify addresses with sender-specified
+routing.  Enabling this opens up nasty relay loopholes involving
+trusted backup MX hosts.
 .IP \fBrestriction_classes\fR
 Declares the name of zero or more parameters that contain a
 list of UCE restrictions. The names of these parameters can
index ceb1ba6819cf7d0d53cee473c63b63a67597eaff..17e7cdd9a24773411c7ce7ff894338c9ccdbeece 100644 (file)
 /* .IP \fBsmtpd_etrn_restrictions\fR
 /*     Restrict what domain names can be used in \fBETRN\fR commands,
 /*     and what clients may issue \fBETRN\fR commands.
-/* .IP \fBallow_routed_relaying\fR
-/*     Allow the relaying of addresses with sender-specified routing.
-/*     Enabling this opens up nasty relay loopholes if your domain has
-/*     primary and backup MX hosts.
+/* .IP \fBallow_untrusted_routing\fR
+/*     Allow untrusted clients to specify addresses with sender-specified 
+/*     routing.  Enabling this opens up nasty relay loopholes involving 
+/*     trusted backup MX hosts.
 /* .IP \fBrestriction_classes\fR
 /*     Declares the name of zero or more parameters that contain a
 /*     list of UCE restrictions. The names of these parameters can
@@ -304,7 +304,7 @@ char   *var_rcpt_canon_maps;
 char   *var_virtual_maps;
 char   *var_alias_maps;
 char   *var_local_rcpt_maps;
-bool    var_allow_routed_relay;
+bool    var_allow_untrust_route;
 
  /*
   * Global state, for stand-alone mode queue file cleanup. When this is
@@ -1327,7 +1327,7 @@ int     main(int argc, char **argv)
        VAR_SMTPD_DELAY_REJECT, DEF_SMTPD_DELAY_REJECT, &var_smtpd_delay_reject,
        VAR_STRICT_RFC821_ENV, DEF_STRICT_RFC821_ENV, &var_strict_rfc821_env,
        VAR_DISABLE_VRFY_CMD, DEF_DISABLE_VRFY_CMD, &var_disable_vrfy_cmd,
-       VAR_ALLOW_ROUTED_RELAY, DEF_ALLOW_ROUTED_RELAY, &var_allow_routed_relay,
+       VAR_ALLOW_UNTRUST_ROUTE, DEF_ALLOW_UNTRUST_ROUTE, &var_allow_untrust_route,
        0,
     };
     static CONFIG_STR_TABLE str_table[] = {
@@ -1344,11 +1344,11 @@ int     main(int argc, char **argv)
        VAR_ALWAYS_BCC, DEF_ALWAYS_BCC, &var_always_bcc, 0, 0,
        VAR_ERROR_RCPT, DEF_ERROR_RCPT, &var_error_rcpt, 1, 0,
        VAR_REST_CLASSES, DEF_REST_CLASSES, &var_rest_classes, 0, 0,
-       VAR_LOCAL_RCPT_MAPS, DEF_LOCAL_RCPT_MAPS, &var_local_rcpt_maps, 0, 0,
        VAR_CANONICAL_MAPS, DEF_CANONICAL_MAPS, &var_canonical_maps, 0, 0,
        VAR_RCPT_CANON_MAPS, DEF_RCPT_CANON_MAPS, &var_rcpt_canon_maps, 0, 0,
        VAR_VIRTUAL_MAPS, DEF_VIRTUAL_MAPS, &var_virtual_maps, 0, 0,
        VAR_ALIAS_MAPS, DEF_ALIAS_MAPS, &var_alias_maps, 0, 0,
+       VAR_LOCAL_RCPT_MAPS, DEF_LOCAL_RCPT_MAPS, &var_local_rcpt_maps, 0, 0,
        0,
     };
 
index c5ae37d8d959557577bfe525c38bf90fb7e98e56..3be739290ceafe12f45ec150156bbad0c9a40ff6 100644 (file)
@@ -377,22 +377,50 @@ static ARGV *smtpd_check_parse(const char *checks)
     return (argv);
 }
 
-/* check_required - make sure minimally-required restriction is present */
+/* has_required - make sure required restriction is present */
 
-static void check_required(char *name, ARGV *restrictions, char **required)
+static int has_required(ARGV *restrictions, char **required)
 {
     char  **rest;
     char  **reqd;
-    VSTRING *example;
+    ARGV   *expansion;
 
-    for (rest = restrictions->argv; *rest; rest++)
+    /*
+     * Recursively check list membership.
+     */
+    for (rest = restrictions->argv; *rest; rest++) {
        for (reqd = required; *reqd; reqd++)
            if (strcmp(*rest, *reqd) == 0)
-               return;
+               return (1);
+       if ((expansion = (ARGV *) htable_find(smtpd_rest_classes, *rest)) != 0)
+           if (has_required(expansion, required))
+               return (1);
+    }
+    return (0);
+}
+
+/* fail_required - handle failure to use required restriction */
+
+static void fail_required(char *name, char **required)
+{
+    char   *myname = "fail_required";
+    char  **reqd;
+    VSTRING *example;
+
+    /*
+     * Sanity check.
+     */
+    if (required[0] == 0)
+       msg_panic("%s: null required list", myname);
+
+    /*
+     * Go bust.
+     */
     example = vstring_alloc(10);
     for (reqd = required; *reqd; reqd++)
        vstring_sprintf_append(example, "%s ", *reqd);
-    msg_fatal("%s requires at least one of %s", name, STR(example));
+    msg_fatal("parameter \"%s\": specify at least one explicit instance of: %s",
+             name, STR(example));
 }
 
 /* smtpd_check_init - initialize once during process lifetime */
@@ -446,14 +474,6 @@ void    smtpd_check_init(void)
     rcpt_restrctions = smtpd_check_parse(var_rcpt_checks);
     etrn_restrctions = smtpd_check_parse(var_etrn_checks);
 
-    /*
-     * People screw up the relay restrictions too often. Require that they
-     * list at least one restriction that rejects mail by default.
-     */
-#ifndef TEST
-    check_required(VAR_RCPT_CHECKS, rcpt_restrctions, rcpt_required);
-#endif
-
     /*
      * Parse the pre-defined restriction classes.
      */
@@ -477,6 +497,15 @@ void    smtpd_check_init(void)
     htable_enter(smtpd_rest_classes, "check_relay_domains",
            smtpd_check_parse("permit_mydomain reject_unauth_destination"));
 #endif
+
+    /*
+     * People screw up the relay restrictions too often. Require that they
+     * list at least one restriction that rejects mail by default.
+     */
+#ifndef TEST
+    if (!has_required(rcpt_restrctions, rcpt_required))
+       fail_required(VAR_RCPT_CHECKS, rcpt_required);
+#endif
 }
 
 /* smtpd_check_reject - do the boring things that must be done */
@@ -798,6 +827,12 @@ static int permit_auth_destination(char *recipient)
        || (*var_virtual_maps && maps_find(virtual_maps, domain, 0)))
        return (SMTPD_CHECK_OK);
 
+    /*
+     * Skip source-routed mail (uncertain destination).
+     */
+    if (var_allow_untrust_route == 0 && (reply.flags & RESOLVE_FLAG_ROUTED))
+       return (SMTPD_CHECK_DUNNO);
+
     /*
      * Permit if the destination matches the relay_domains list.
      */
@@ -820,7 +855,7 @@ static int reject_unauth_destination(SMTPD_STATE *state, char *recipient)
        msg_info("%s: %s", myname, recipient);
 
     /*
-     * Permit authorized destination.
+     * Skip authorized destination.
      */
     if (permit_auth_destination(recipient) == SMTPD_CHECK_OK)
        return (SMTPD_CHECK_DUNNO);
@@ -852,52 +887,6 @@ static int reject_unauth_pipelining(SMTPD_STATE *state)
     return (SMTPD_CHECK_DUNNO);
 }
 
-/* reject_routed_relay - FAIL for relaying via sender-specified route */
-
-static int reject_routed_relay(SMTPD_STATE *state, char *recipient,
-                                      char *reply_name, char *reply_class)
-{
-    char   *myname = "reject_routed_relay";
-    char   *domain;
-
-    if (msg_verbose)
-       msg_info("%s: %s", myname, recipient);
-
-    /*
-     * Resolve the address.
-     */
-    canon_addr_internal(query, recipient);
-    resolve_clnt_query(STR(query), &reply);
-
-    /*
-     * Handle special case that is not supposed to happen.
-     */
-    if ((domain = strrchr(STR(reply.recipient), '@')) == 0)
-       return (SMTPD_CHECK_DUNNO);
-    domain += 1;
-
-    /*
-     * Permit final delivery: the destination matches mydestination or
-     * virtual_maps.
-     */
-    if (resolve_local(domain)
-       || (*var_virtual_maps && maps_find(virtual_maps, domain, 0)))
-       return (SMTPD_CHECK_DUNNO);
-
-    /*
-     * Reject source-routed mail to a non-local destination.
-     */
-    if ((reply.flags & RESOLVE_FLAG_ROUTED) != 0)
-       return (smtpd_check_reject(state, MAIL_ERROR_POLICY,
-                 "%d <%s>: %s rejected: Source-routed relay access denied",
-                                  var_relay_code, reply_name, reply_class));
-
-    /*
-     * Something else.
-     */
-    return (SMTPD_CHECK_DUNNO);
-}
-
 /* has_my_addr - see if this host name lists one of my network addresses */
 
 static int has_my_addr(char *host)
@@ -1847,13 +1836,10 @@ char   *smtpd_check_rcpt(SMTPD_STATE *state, char *recipient)
      */
     state->recursion = 0;
     status = setjmp(smtpd_check_buf);
-    if (status == 0 && rcpt_restrctions->argc) {
+    if (status == 0 && rcpt_restrctions->argc)
        status = generic_checks(state, rcpt_restrctions,
                          recipient, SMTPD_NAME_RECIPIENT, CHECK_RECIP_ACL);
-       if (var_allow_routed_relay == 0 && status != SMTPD_CHECK_REJECT)
-           status = reject_routed_relay(state, recipient,
-                                        recipient, SMTPD_NAME_RECIPIENT);
-    }
+
     SMTPD_CHECK_RCPT_RETURN(status == SMTPD_CHECK_REJECT ? STR(error_text) : 0);
 }
 
@@ -2114,7 +2100,7 @@ int     var_access_map_code;
 int     var_reject_code;
 int     var_non_fqdn_code;
 int     var_smtpd_delay_reject;
-int     var_allow_routed_relay;
+int     var_allow_untrust_route;
 
 static INT_TABLE int_table[] = {
     "msg_verbose", 0, &msg_verbose,
@@ -2128,7 +2114,7 @@ static INT_TABLE int_table[] = {
     VAR_REJECT_CODE, DEF_REJECT_CODE, &var_reject_code,
     VAR_NON_FQDN_CODE, DEF_NON_FQDN_CODE, &var_non_fqdn_code,
     VAR_SMTPD_DELAY_REJECT, DEF_SMTPD_DELAY_REJECT, &var_smtpd_delay_reject,
-    VAR_ALLOW_ROUTED_RELAY, DEF_ALLOW_ROUTED_RELAY, &var_allow_routed_relay,
+    VAR_ALLOW_UNTRUST_ROUTE, DEF_ALLOW_UNTRUST_ROUTE, &var_allow_untrust_route,
     0,
 };
 
@@ -2165,7 +2151,7 @@ static int int_update(char **argv)
 typedef struct {
     char   *name;
     ARGV  **target;
-} REST_TABLE;
+}       REST_TABLE;
 
 static REST_TABLE rest_table[] = {
     "client_restrictions", &client_restrctions,
index 3d0324bfd7cadc363b2fcf11fe4464d66e0b7839..eb45b6d13f3fc51ded0c498f347e40f21bedcfa8 100644 (file)
@@ -140,17 +140,13 @@ void    resolve_addr(char *addr, VSTRING *channel, VSTRING *nexthop,
        /*
         * After stripping the local domain, if any, replace foo%bar by
         * foo@bar, site!user by user@site, rewrite to canonical form, and
-        * retry. Recognize routing operators in the address localpart. This
-        * is needed to prevent primary MX hosts from relaying third-party
-        * destinations from backup MX hosts, otherwise the primary could end
-        * up on black lists.
+        * retry.
         * 
         * Otherwise we're done.
         */
        if (tok822_rfind_type(tree->tail, '@')
            || (var_swap_bangpath && tok822_rfind_type(tree->tail, '!'))
            || (var_percent_hack && tok822_rfind_type(tree->tail, '%'))) {
-           *flags |= RESOLVE_FLAG_ROUTED;
            rewrite_tree(REWRITE_CANON, tree);
        } else {
            domain = 0;