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