chiark / gitweb /
exchange.m4: Reluctantly accept local senders from remote clients.
[exim-config] / exchange.m4
1 ### -*-m4-*-
2 ###
3 ### Transmission to remote hosts for distorted.org.uk Exim configuration.
4 ###
5 ### (c) 2012 Mark Wooding
6 ###
7
8 ###----- Licensing notice ---------------------------------------------------
9 ###
10 ### This program is free software; you can redistribute it and/or modify
11 ### it under the terms of the GNU General Public License as published by
12 ### the Free Software Foundation; either version 2 of the License, or
13 ### (at your option) any later version.
14 ###
15 ### This program is distributed in the hope that it will be useful,
16 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ### GNU General Public License for more details.
19 ###
20 ### You should have received a copy of the GNU General Public License
21 ### along with this program; if not, write to the Free Software Foundation,
22 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 ###--------------------------------------------------------------------------
25 ### Listen for incoming connections.
26
27 SECTION(global, tls)m4_dnl
28 tls_certificate = CONF_sysconf_dir/server.cert
29 tls_privatekey = CONF_sysconf_dir/server.key
30 tls_advertise_hosts = *
31 tls_dhparam = CONF_ca_dir/dh-param.pem
32 tls_require_ciphers = ${if or {{={$received_port}{CONF_submission_port}} \
33                                {match_ip {$sender_host_address}{+trusted}}} \
34                            {CONF_good_ciphers} \
35                            {CONF_acceptable_ciphers}}
36 tls_verify_certificates = CONF_ca_dir/ca.cert
37 tls_verify_hosts = ${if eq{$acl_c_mode}{submission} {} {+allnets}}
38
39 DIVERT(null)
40 ###--------------------------------------------------------------------------
41 ### Check source addresses for apparently local senders.
42
43 SECTION(acl, mail-hooks)m4_dnl
44         ## Check that a submitted message's sender address is allowable.
45         require  acl = mail_client_addr
46
47         ## Insist that a local client connect through TLS.
48         deny     message = Hosts within CONF_master_domain must use TLS
49                 !condition = ${if eq{$acl_c_mode}{submission}}
50                  hosts = +allnets
51                 !encrypted = *
52
53 SECTION(acl, misc)m4_dnl
54 mail_client_addr:
55
56         ## If this is a message submission then that's handled elsewhere.
57         accept   condition = ${if eq{$acl_c_mode}{submission}}
58
59         ## Make sure that the sender matches the client address.  I feel like
60         ## I want to reject these, but that will break stuff.  For example,
61         ## if I send mail to an externally hosted address which is really a
62         ## distribution list containing some local address, then we'll
63         ## (approximately legitimately) receive mail with an apparently-local
64         ## sender from a remote host.
65         warn    !hosts = ${LOOKUP_DOMAIN($sender_address_domain,
66                            {KV(hosts, {$value}{+allnets})},
67                            {${if match_domain {$sender_address_domain} \
68                                               {+public} \
69                                  {+allnets}{! +allnets}}})}
70                  add_header = :after_received:X-Distorted-Warning: \
71                         RCLNTLSNDR \
72                         Apparently local sender, but received from remote \
73                         server.
74
75         ## OK.
76         accept
77
78 DIVERT(null)
79 ###--------------------------------------------------------------------------
80 ### The obvious trivial router.
81
82 SECTION(routers, remote)m4_dnl
83 ## Send mail on to a host in our own network.  We must apply extra security.
84 local:
85         driver = dnslookup
86         domains = ! +known : *.CONF_master_domain
87         self = fail
88         transport = smtp_local
89         no_more
90
91 ## Send mail on to unknown hosts.
92 remote:
93         driver = dnslookup
94         domains = ! +known
95         self = fail
96         transport = smtp
97         no_more
98
99 DIVERT(null)
100 ###----- That's all, folks --------------------------------------------------