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