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