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