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