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