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