chiark / gitweb /
spam.m4: No, we can't check domains in the DATA ACL.
[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
MW
91SECTION(global, tls)m4_dnl
92tls_certificate = CONF_sysconf_dir/server.cert
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
164 ## Ensure that the sender is routable. This is important to prevent
165 ## undeliverable bounces.
166 require message = Invalid sender; \
167 ($sender_verify_failure; $acl_verify_message)
168 verify = sender
169
170 ## If this is directly from a client then hack on it for a while.
171 warn condition = ${if eq{$acl_c_mode}{submission}}
172 control = submission
173
284c9d7e
MW
174 ## Insist that a local client connect through TLS.
175 deny message = Hosts within CONF_master_domain must use TLS
176 !condition = ${if eq{$acl_c_mode}{submission}}
177 hosts = +allnets
178 !encrypted = *
179
180 ## Check that a submitted message's sender address is allowable.
181 require acl = mail_check_auth
182
185b5456
MW
183SECTION(acl, mail-tail)m4_dnl
184 ## And we're done.
185 accept
186
187SECTION(global, acl)m4_dnl
188acl_smtp_connect = connect
189SECTION(acl, connect)m4_dnl
190connect:
191SECTION(acl, connect-tail)m4_dnl
e12c9586 192 ## Configure variables according to the submission mode.
185b5456 193 warn acl = check_submission
e12c9586
MW
194
195 ## Done.
185b5456
MW
196 accept
197
198check_submission:
199 ## See whether this message needs hacking on.
4ff4ad42 200 accept !hosts = +thishost
185b5456
MW
201 !condition = ${if ={$received_port}{CONF_submission_port}}
202 set acl_c_mode = relay
203
204 ## Remember to apply submission controls.
205 warn set acl_c_mode = submission
206
207 ## Done.
208 accept
209
210SECTION(global, acl)m4_dnl
211acl_smtp_rcpt = rcpt
212SECTION(acl, rcpt)m4_dnl
213rcpt:
214
215 ## Reject if the client isn't allowed to relay and the recipient
216 ## isn't in one of our known domains.
e4666f2d
MW
217 require message = Relaying not permitted
218 acl = check_relay
185b5456
MW
219
220 ## Ensure that the recipient is routable.
221 require message = Invalid recipient \
222 ($recipient_verify_failure; $acl_verify_message)
223 verify = recipient
224
e4666f2d
MW
225SECTION(acl, misc)m4_dnl
226check_relay:
227 ## Accept either if the client is allowed to relay through us, or if
228 ## we're the correct place to send this mail.
229
230 ## Known clients and authenticated users are OK.
231 accept hosts = CONF_relay_clients
232 accept authenticated = *
233
234 ## Known domains are OK.
235 accept domains = +public
236
237 ## Finally, domains in our table are OK, unless they say they aren't.
238 accept domains = \
239 ${if exists{CONF_sysconf_dir/domains.conf} \
240 {partial0-lsearch; CONF_sysconf_dir/domains.conf}}
241 condition = DOMKV(service, {$value}{true})
242
243 ## Nope, that's not allowed.
244 deny
245
185b5456
MW
246SECTION(acl, rcpt-tail)m4_dnl
247 ## Everything checks out OK: let this one go through.
248 accept
249
250SECTION(global, acl)m4_dnl
251acl_smtp_data = data
252SECTION(acl, data)m4_dnl
253data:
254
255SECTION(acl, data-tail)m4_dnl
256 accept
257
258SECTION(global, acl)m4_dnl
259acl_smtp_expn = expn_vrfy
260acl_smtp_vrfy = expn_vrfy
261SECTION(acl)m4_dnl
262expn_vrfy:
263 accept hosts = +trusted
264 deny message = Suck it and see
265
266DIVERT(null)
267###--------------------------------------------------------------------------
284c9d7e
MW
268### Verification of sender address.
269
270SECTION(acl, misc)m4_dnl
271mail_check_auth:
272
273 ## If this isn't a submission then it doesn't need checking.
274 accept condition = ${if !eq{$acl_c_mode}{submission}}
275
276 ## If the caller hasn't formally authenticated, but this is a
277 ## loopback connection, then we can trust identd to tell us the right
278 ## answer. So we should stash the right name somewhere consistent.
279 warn set acl_c_user = $authenticated_id
4ff4ad42 280 hosts = +thishost
284c9d7e 281 !authenticated = *
ff4c943d 282 condition = ${if def:sender_ident}
284c9d7e
MW
283 set acl_c_user = $sender_ident
284
ff4c943d 285 ## User must be authenticated by now.
284c9d7e 286 deny message = Sender not authenticated
ff4c943d 287 condition = ${if !def:acl_c_user}
284c9d7e
MW
288
289 ## Make sure that the local part is one that the authenticated sender
290 ## is allowed to claim.
291 deny message = Sender address forbidden to calling user
459abd49
MW
292 !condition = \
293 ${if exists {CONF_sysconf_dir/auth-sender.conf} \
294 {${lookup {$acl_c_user} \
295 lsearch \
296 {CONF_sysconf_dir/auth-sender.conf} \
297 {${if match_address \
298 {$sender_address} \
299 {+value}}} \
300 {false}}}}
284c9d7e
MW
301 !condition = ${LOOKUP_DOMAIN($sender_address_domain,
302 {${if and {{match_local_part \
303 {$acl_c_user} \
304 {+dom_users}} \
305 {match_local_part \
306 {$sender_address_local_part} \
307 {+dom_locals}}}}},
308 {${if and {{match_local_part \
309 {$sender_address_local_part} \
310 {+user_extaddr}} \
311 {or {{eq {$sender_address_domain} \
312 {}} \
313 {match_domain \
314 {$sender_address_domain} \
315 {+public}}}}}}})}
316
317 ## All done.
318 accept
319
320DIVERT(null)
321###--------------------------------------------------------------------------
185b5456
MW
322### Common options for forwarding routers.
323
324## We're pretty permissive here.
325m4_define(<:FILTER_BASE:>,
326 <:driver = redirect
327 modemask = 002
328 check_owner = false
329 check_group = false
330 allow_filter = true
331 allow_defer = true
332 allow_fail = true
333 forbid_blackhole = false
334 check_ancestor = true:>)
335
336## Common options for forwarding routers at verification time.
337m4_define(<:FILTER_VERIFY:>,
338 <:verify_only = true
339 user = CONF_filter_user
340 forbid_filter_dlfunc = true
341 forbid_filter_logwrite = true
342 forbid_filter_perl = true
343 forbid_filter_readsocket = true
344 forbid_filter_run = true
345 file_transport = dummy
346 directory_transport = dummy
347 pipe_transport = dummy
348 reply_transport = dummy:>)
349
350## Transports for redirection filters.
351m4_define(<:FILTER_TRANSPORTS:>,
7ab75d6f 352 <:file_transport = mailbox
185b5456
MW
353 directory_transport = maildir
354 pipe_transport = pipe
355 reply_transport = reply:>)
356
7ab75d6f
MW
357m4_define(<:FILTER_ROUTER:>,
358<:$1_vrf:
359 $2
360 FILTER_VERIFY<::>$3
361$1:
362 $2
363 verify = no
364 FILTER_TRANSPORTS<::>$4:>)
365
185b5456
MW
366DIVERT(null)
367###--------------------------------------------------------------------------
368### Some standard transports.
369
370m4_define(<:USER_DELIVERY:>,
371 <:delivery_date_add = true
372 envelope_to_add = true
373 return_path_add = true:>)
374
375SECTION(transports)m4_dnl
fa5a92c6
MW
376## A standard transport for remote delivery. By default, try to do TLS, and
377## don't worry too much if it's not very secure: the alternative is sending
378## in plaintext anyway. But all of this can be overridden from the
beb15dae
MW
379## `domains.conf' file. Annoyingly, the `tls_dh_min_bits' setting isn't
380## expanded before use, so we can't set it the obvious way. Instead, encode
381## it into the transport name. This is very unpleasant, of course.
534d411b
MW
382smtp:
383 driver = smtp
384 tls_require_ciphers = CONF_acceptable_ciphers
385 tls_dh_min_bits = 1020
386 tls_tempfail_tryclear = true
387
beb15dae
MW
388m4_define(<:SMTP_TRANS_DHBITS:>,
389 <:driver = smtp
ae9744ce 390 hosts_try_auth = *
fa5a92c6 391 hosts_require_tls = DOMKV(tls-peer-ca, {*}{})
ae9744ce
MW
392 hosts_require_auth = \
393 ${if bool {DOMKV(require-auth, {$value}{false})} {*}{}}
fa5a92c6
MW
394 tls_certificate = DOMKV(tls-certificate, {${expand:$value}}fail)
395 tls_privatekey = DOMKV(tls-private-key, {${expand:$value}}fail)
396 tls_verify_certificates = DOMKV(tls-peer-ca, {${expand:$value}}fail)
397 tls_require_ciphers = \
398 DOMKV(tls-ciphers,
399 {${extract {${expand:$value}} \
400 { good = CONF_good_ciphers \
401 any = CONF_acceptable_ciphers } \
402 {$value} \
403 {${expand:$value}}}} \
404 {CONF_acceptable_ciphers})
beb15dae
MW
405 tls_dh_min_bits = $1
406 tls_tempfail_tryclear = true:>)m4_dnl
beb15dae
MW
407smtp_dhbits_1024:
408 SMTP_TRANS_DHBITS(1020)
409smtp_dhbits_2048:
410 SMTP_TRANS_DHBITS(2046)
185b5456
MW
411
412## Transport to a local SMTP server; use TLS and perform client
413## authentication.
414smtp_local:
415 driver = smtp
416 hosts_require_tls = *
417 tls_certificate = CONF_sysconf_dir/client.cert
418 tls_privatekey = CONF_sysconf_dir/client.key
419 tls_verify_certificates = CONF_ca_dir/ca.cert
420 tls_require_ciphers = CONF_good_ciphers
b6d74252 421 tls_dh_min_bits = 2046
185b5456
MW
422 tls_tempfail_tryclear = false
423 authenticated_sender = ${if def:authenticated_id \
0bed9b7f 424 {$authenticated_id@CONF_master_domain} \
185b5456
MW
425 fail}
426
427## A standard transport for local delivery.
428deliver:
429 driver = appendfile
430 file = /var/mail/$local_part
8f6af4ae
MW
431 group = mail
432 mode = 0600
433 mode_fail_narrower = false
185b5456
MW
434 USER_DELIVERY
435
436## Transports for user filters.
437mailbox:
438 driver = appendfile
8f6af4ae 439 initgroups = true
185b5456
MW
440 USER_DELIVERY
441
442maildir:
443 driver = appendfile
444 maildir_format = true
8f6af4ae 445 initgroups = true
185b5456
MW
446 USER_DELIVERY
447
448pipe:
449 driver = pipe
8f6af4ae
MW
450 path = ${if and {{def:home} {exists{$home/bin}}} {$home/bin:} {}}\
451 /usr/local/bin:/usr/local/sbin:\
452 /usr/bin:/usr/sbin:/bin:/sbin
453 initgroups = true
454 umask = 002
455 return_fail_output = true
456 log_output = true
185b5456
MW
457
458## A special dummy transport for use during address verification.
459dummy:
460 driver = appendfile
461 file = /dev/null
462
463DIVERT(null)
464###--------------------------------------------------------------------------
465### Retry configuration.
466
467SECTION(retry, default)m4_dnl
468## Default.
469* * \
470 F,2h,15m; G,16h,2h,1.5; F,4d,6h
471
472DIVERT(null)
473###----- That's all, folks --------------------------------------------------