chiark / gitweb /
Add warning headers directly.
[exim-config] / base.m4
1 ### -*-m4-*-
2 ###
3 ### Basic settings 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 ### Global settings.
26
27 SECTION(global, priv)m4_dnl
28 admin_groups = CONF_admin_groups
29 trusted_groups = CONF_trusted_groups
30 prod_requires_admin = false
31
32 SECTION(global, logging)m4_dnl
33 log_file_path = : syslog
34 log_selector = \
35         +smtp_confirmation \
36         +tls_peerdn
37 log_timezone = true
38 syslog_duplication = false
39 syslog_timestamp = false
40
41 SECTION(global, daemon)m4_dnl
42 local_interfaces = <; CONF_interfaces
43 extra_local_interfaces = <; 0.0.0.0 ; ::0
44
45 SECTION(global, resource)m4_dnl
46 deliver_queue_load_max = 8
47 queue_only_load = 12
48 smtp_accept_max = 16
49 smtp_accept_queue = 32
50 smtp_accept_reserve = 4
51 smtp_load_reserve = 10
52 smtp_reserve_hosts = +trusted
53
54 SECTION(global, policy)m4_dnl
55 host_lookup = *
56
57 SECTION(global, users)m4_dnl
58 gecos_name = $1
59 gecos_pattern = ([^,:]*)
60
61 SECTION(global, incoming)m4_dnl
62 received_header_text = Received: \
63         ${if def:sender_rcvhost \
64              {from $sender_rcvhost\n\t} \
65              {${if def:sender_ident \
66                    {from ${quote_local_part:$sender_ident} }}}}\
67         by $primary_hostname \
68         (Exim $version_number)\
69         ${if def:tls_cipher {\n\t} { }}\
70         ${if def:received_protocol \
71              {with $received_protocol \
72               ${if def:tls_cipher {(cipher=$tls_cipher)}}}}\n\t\
73         ${if def:sender_address \
74              {(envelope-from $sender_address\
75               ${if def:authenticated_id \
76                    {; auth=$authenticated_id}})\n\t}}\
77         id $message_exim_id\
78         ${if def:received_for {\n\tfor $received_for}}
79
80 SECTION(global, smtp)m4_dnl
81 smtp_return_error_details = true
82 accept_8bitmime = true
83
84 SECTION(global, process)m4_dnl
85 extract_addresses_remove_arguments = false
86 headers_charset = utf-8
87 qualify_domain = CONF_master_domain
88 untrusted_set_sender = *
89
90 SECTION(global, bounce)m4_dnl
91 delay_warning = 1h : 24h : 2d
92
93 SECTION(global, tls)m4_dnl
94 tls_certificate = CONF_sysconf_dir/server.certlist
95 tls_privatekey = CONF_sysconf_dir/server.key
96 tls_advertise_hosts = ${if exists {CONF_sysconf_dir/server.key} {*}{}}
97 tls_dhparam = CONF_ca_dir/dh-param-2048.pem
98 tls_require_ciphers = ${if or {{={$received_port}{CONF_submission_port}} \
99                                {match_ip {$sender_host_address}{+trusted}}} \
100                            {CONF_good_ciphers} \
101                            {CONF_acceptable_ciphers}}
102 tls_verify_certificates = CONF_ca_dir/ca.cert
103 tls_verify_hosts = ${if eq{$acl_c_mode}{submission} {} {+allnets}}
104
105 DIVERT(null)
106 ###--------------------------------------------------------------------------
107 ### Access control lists.
108
109 SECTION(global, acl-after)
110 SECTION(global, acl)m4_dnl
111 acl_smtp_helo = helo
112 SECTION(acl, misc)m4_dnl
113 helo:
114         ## Check that the caller's claimed identity is actually plausible.
115         ## This seems like it's a fairly effective filter on spamminess, but
116         ## it's too blunt a tool.  Rather than reject, add a warning header.
117         ## Only we can't do this the easy way, so save it up for use in MAIL.
118         ## Also, we're liable to get a subsequent HELO (e.g., after STARTTLS)
119         ## and we should only care about the most recent one.
120         warn     set acl_c_helo_warning = false
121                 !condition = \
122                         ${if and {{match_ip {$sender_host_address} \
123                                             {<; 127.0.0.0/8 ; ::1}} \
124                                   {match_domain {$sender_helo_name} \
125                                                 {localhost : +thishost}}}}
126                 !condition = \
127                         ${if exists {CONF_sysconf_dir/helo.conf} \
128                              {${lookup {$sender_helo_name} \
129                                        partial0-lsearch \
130                                        {CONF_sysconf_dir/helo.conf} \
131                                        {${if match_ip \
132                                              {$sender_host_address} \
133                                              {<; $value}}}}}}
134                 !verify = helo
135                  set acl_c_helo_warning = true
136
137         accept
138
139 SECTION(global, acl)m4_dnl
140 acl_not_smtp_start = not_smtp_start
141 SECTION(acl, misc)m4_dnl
142 not_smtp_start:
143         ## Record the user's name.
144         warn     set acl_c_user = $sender_ident
145
146         ## Done.
147         accept
148
149 SECTION(global, acl)m4_dnl
150 acl_smtp_mail = mail
151 SECTION(acl, mail)m4_dnl
152 mail:
153
154         ## If we stashed a warning header about HELO from earlier, we should
155         ## add it now.  Only don't bother if the client has authenticated
156         ## successfully for submission (because we can't expect mobile
157         ## clients to be properly set up knowing their names), or it's one of
158         ## our own satellites (because they're either properly set up anyway,
159         ## or satellites using us as a smarthost).
160         warn     condition = $acl_c_helo_warning
161                 !condition = ${if eq{$acl_c_mode}{submission}}
162                 !hosts = +allnets
163                  WARNING_HEADER(BADHELO,
164                                 <:Client's HELO doesn't match its IP address.\n\t\
165                                   helo-name=$sender_helo_name \
166                                   address=$sender_host_address:>)
167
168         ## Always allow the empty sender, so that we can receive bounces.
169         accept   senders = :
170
171         ## Ensure that the sender looks valid.
172         require  acl = mail_check_sender
173
174         ## If this is directly from a client then hack on it for a while.
175         warn     condition = ${if eq{$acl_c_mode}{submission}}
176                  control = submission/sender_retain
177
178         ## Insist that a local client connect through TLS.
179         deny     message = Hosts within CONF_master_domain must use TLS
180                 !condition = ${if eq{$acl_c_mode}{submission}}
181                  hosts = +allnets
182                 !encrypted = *
183
184         ## Check that a submitted message's sender address is allowable.
185         require  acl = mail_check_auth
186
187 SECTION(acl, mail-tail)m4_dnl
188         ## And we're done.
189         accept
190
191 SECTION(acl, misc)m4_dnl
192 mail_check_sender:
193
194         ## See whether there's a special exception for this sender domain.
195         accept   senders = ${LOOKUP_DOMAIN($sender_address_domain,
196                              {KV(senders, {$value}{})},
197                              {})}
198
199         ## Ensure that the sender is routable.  This is important to prevent
200         ## undeliverable bounces.
201         require  message = Invalid sender; \
202                         ($sender_verify_failure; $acl_verify_message)
203                  verify = sender
204
205         ## We're good, then.
206         accept
207
208 SECTION(global, acl)m4_dnl
209 acl_smtp_connect = connect
210 SECTION(acl, connect)m4_dnl
211 connect:
212 SECTION(acl, connect-tail)m4_dnl
213         ## Configure variables according to the submission mode.
214         warn     acl = check_submission
215
216         ## Done.
217         accept
218
219 check_submission:
220         ## See whether this message needs hacking on.
221         accept  !hosts = +thishost
222                 !condition = ${if ={$received_port}{CONF_submission_port}}
223                  set acl_c_mode = relay
224
225         ## Remember to apply submission controls.
226         warn     set acl_c_mode = submission
227
228         ## Done.
229         accept
230
231 SECTION(global, acl)m4_dnl
232 acl_smtp_rcpt = rcpt
233 SECTION(acl, rcpt)m4_dnl
234 rcpt:
235
236         ## Reject if the client isn't allowed to relay and the recipient
237         ## isn't in one of our known domains.
238         require  message = Relaying not permitted
239                  acl = check_relay
240
241         ## Ensure that the recipient is routable.
242         require  message = Invalid recipient \
243                         ($recipient_verify_failure; $acl_verify_message)
244                  verify = recipient
245
246 SECTION(acl, misc)m4_dnl
247 check_relay:
248         ## Accept either if the client is allowed to relay through us, or if
249         ## we're the correct place to send this mail.
250
251         ## Known clients and authenticated users are OK.
252         accept    hosts = CONF_relay_clients
253         accept    authenticated = *
254
255         ## Known domains are OK.
256         accept    domains = +public
257
258         ## Finally, domains in our table are OK, unless they say they aren't.
259         accept    domains = \
260                 ${if exists{CONF_sysconf_dir/domains.conf} \
261                      {partial0-lsearch; CONF_sysconf_dir/domains.conf}}
262                   condition = DOMKV(service, {$value}{true})
263
264         ## Nope, that's not allowed.
265         deny
266
267 SECTION(acl, rcpt-tail)m4_dnl
268         ## Everything checks out OK: let this one go through.
269         accept
270
271 SECTION(global, acl)m4_dnl
272 acl_smtp_data = data
273 SECTION(acl, data)m4_dnl
274 data:
275
276 SECTION(acl, data-tail)m4_dnl
277         accept
278
279 SECTION(global, acl)m4_dnl
280 acl_smtp_expn = expn_vrfy
281 acl_smtp_vrfy = expn_vrfy
282 SECTION(acl, misc)m4_dnl
283 expn_vrfy:
284         accept   hosts = +trusted
285         deny     message = Suck it and see
286
287 DIVERT(null)
288 ###--------------------------------------------------------------------------
289 ### Verification of sender address.
290
291 SECTION(acl, misc)m4_dnl
292 mail_check_auth:
293
294         ## If this isn't a submission then it doesn't need checking.
295         accept   condition = ${if !eq{$acl_c_mode}{submission}}
296
297         ## If the caller hasn't formally authenticated, but this is a
298         ## loopback connection, then we can trust identd to tell us the right
299         ## answer.  So we should stash the right name somewhere consistent.
300         warn     set acl_c_user = $authenticated_id
301                  hosts = +thishost
302                 !authenticated = *
303                  condition = ${if def:sender_ident}
304                  set acl_c_user = $sender_ident
305
306         ## User must be authenticated by now.
307         deny     message = Sender not authenticated
308                  condition = ${if !def:acl_c_user}
309
310         ## All done.
311         accept
312
313 DIVERT(null)
314 ###--------------------------------------------------------------------------
315 ### Common options for forwarding routers.
316
317 ## We're pretty permissive here.
318 m4_define(<:FILTER_BASE:>,
319         <:driver = redirect
320         modemask = 002
321         check_owner = false
322         check_group = false
323         allow_filter = true
324         allow_defer = true
325         allow_fail = true
326         forbid_blackhole = false
327         check_ancestor = true:>)
328
329 ## Common options for forwarding routers at verification time.
330 m4_define(<:FILTER_VERIFY:>,
331         <:verify_only = true
332         user = CONF_filter_user
333         forbid_filter_dlfunc = true
334         forbid_filter_logwrite = true
335         forbid_filter_perl = true
336         forbid_filter_readsocket = true
337         forbid_filter_run = true
338         file_transport = dummy
339         directory_transport = dummy
340         pipe_transport = dummy
341         reply_transport = dummy:>)
342
343 ## Transports for redirection filters.
344 m4_define(<:FILTER_TRANSPORTS:>,
345         <:file_transport = mailbox
346         directory_transport = maildir
347         pipe_transport = pipe
348         reply_transport = reply:>)
349
350 m4_define(<:FILTER_ROUTER:>,
351 <:$1_vrf:
352         $2
353         FILTER_VERIFY<::>$3
354 $1:
355         $2
356         verify = no
357         FILTER_TRANSPORTS<::>$4:>)
358
359 DIVERT(null)
360 ###--------------------------------------------------------------------------
361 ### Common routers.
362
363 SECTION(routers, alias)m4_dnl
364 ## Look up the local part in the address map.
365 alias:
366         driver = redirect
367         allow_fail = true
368         allow_defer = true
369         user = CONF_filter_user
370         FILTER_TRANSPORTS
371         local_parts = nwildlsearch; CONF_alias_file
372         data = ${expand:$local_part_data}
373 SECTION(routers, alias-opts)m4_dnl
374
375 DIVERT(null)
376 ###--------------------------------------------------------------------------
377 ### Some standard transports.
378
379 m4_define(<:USER_DELIVERY:>,
380         <:delivery_date_add = true
381         envelope_to_add = true
382         return_path_add = true:>)
383
384 m4_define(<:APPLY_HEADER_CHANGES:>,
385         <:headers_add = m4_ifelse(<:$1:>, <::>,
386                 <:$acl_m_hdradd:>,
387                 <:${if def:acl_m_hdradd{$acl_m_hdradd\n}}\
388                 $1:>)
389         headers_remove = m4_ifelse(<:$2:>, <::>,
390                 <:$acl_m_hdrrm:>,
391                 <:${if def:acl_m_hdrrm{$acl_m_hdrrm:}}\
392                 $2:>):>)
393
394 SECTION(transports)m4_dnl
395 ## A standard transport for remote delivery.  By default, try to do TLS, and
396 ## don't worry too much if it's not very secure: the alternative is sending
397 ## in plaintext anyway.  But all of this can be overridden from the
398 ## `domains.conf' file.  Annoyingly, the `tls_dh_min_bits' setting isn't
399 ## expanded before use, so we can't set it the obvious way.  Instead, encode
400 ## it into the transport name.  This is very unpleasant, of course.
401 smtp:
402         driver = smtp
403         APPLY_HEADER_CHANGES
404         tls_require_ciphers = CONF_acceptable_ciphers
405         tls_dh_min_bits = 1020
406         tls_tempfail_tryclear = true
407
408 m4_define(<:SMTP_TRANS_DHBITS:>,
409         <:driver = smtp
410         APPLY_HEADER_CHANGES
411         hosts_try_auth = *
412         hosts_require_tls = DOMKV(tls-peer-ca, {*}{})
413         hosts_require_auth = \
414                 ${if bool {DOMKV(require-auth, {$value}{false})} {*}{}}
415         tls_certificate = DOMKV(tls-certificate, {${expand:$value}}fail)
416         tls_privatekey = DOMKV(tls-private-key, {${expand:$value}}fail)
417         tls_verify_certificates = DOMKV(tls-peer-ca, {${expand:$value}}fail)
418         tls_require_ciphers = \
419                 DOMKV(tls-ciphers,
420                       {${extract {${expand:$value}} \
421                                  { good = CONF_good_ciphers \
422                                    any = CONF_acceptable_ciphers } \
423                                  {$value} \
424                                  {${expand:$value}}}} \
425                       {CONF_acceptable_ciphers})
426         tls_dh_min_bits = $1
427         tls_tempfail_tryclear = true:>)m4_dnl
428 smtp_dhbits_1024:
429         SMTP_TRANS_DHBITS(1020)
430 smtp_dhbits_2048:
431         SMTP_TRANS_DHBITS(2046)
432
433 ## Transport to a local SMTP server; use TLS and perform client
434 ## authentication.
435 smtp_local:
436         driver = smtp
437         APPLY_HEADER_CHANGES
438         hosts_require_tls = *
439         tls_certificate = CONF_sysconf_dir/client.certlist
440         tls_privatekey = CONF_sysconf_dir/client.key
441         tls_verify_certificates = CONF_ca_dir/ca.cert
442         tls_require_ciphers = CONF_good_ciphers
443         tls_dh_min_bits = 2046
444         tls_tempfail_tryclear = false
445         authenticated_sender = ${if def:authenticated_id \
446                                     {$authenticated_id@CONF_master_domain} \
447                                     fail}
448
449 ## A standard transport for local delivery.
450 deliver:
451         driver = appendfile
452         APPLY_HEADER_CHANGES
453         file = /var/mail/$local_part
454         group = mail
455         mode = 0600
456         mode_fail_narrower = false
457         USER_DELIVERY
458
459 ## Transports for user filters.
460 mailbox:
461         driver = appendfile
462         APPLY_HEADER_CHANGES
463         initgroups = true
464         USER_DELIVERY
465
466 maildir:
467         driver = appendfile
468         APPLY_HEADER_CHANGES
469         maildir_format = true
470         initgroups = true
471         USER_DELIVERY
472
473 pipe:
474         driver = pipe
475         APPLY_HEADER_CHANGES
476         path = ${if and {{def:home} {exists{$home/bin}}} {$home/bin:} {}}\
477                 /usr/local/bin:/usr/local/sbin:\
478                 /usr/bin:/usr/sbin:/bin:/sbin
479         initgroups = true
480         umask = 002
481         return_fail_output = true
482         log_output = true
483
484 ## A special dummy transport for use during address verification.
485 dummy:
486         driver = appendfile
487         file = /dev/null
488
489 DIVERT(null)
490 ###--------------------------------------------------------------------------
491 ### Retry configuration.
492
493 SECTION(retry, default)m4_dnl
494 ## Default.
495 *                                       * \
496         F,2h,15m; G,16h,2h,1.5; F,4d,6h
497
498 DIVERT(null)
499 ###----- That's all, folks --------------------------------------------------