chiark / gitweb /
base.m4: Simplify the bare `smtp' router.
[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} \
131 {$value}}}}}}
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.
217 deny message = Relaying not permitted
218 !hosts = CONF_relay_clients
219 !authenticated = *
220 !domains = +known
221
222 ## Ensure that the recipient is routable.
223 require message = Invalid recipient \
224 ($recipient_verify_failure; $acl_verify_message)
225 verify = recipient
226
227SECTION(acl, rcpt-tail)m4_dnl
228 ## Everything checks out OK: let this one go through.
229 accept
230
231SECTION(global, acl)m4_dnl
232acl_smtp_data = data
233SECTION(acl, data)m4_dnl
234data:
235
236SECTION(acl, data-tail)m4_dnl
237 accept
238
239SECTION(global, acl)m4_dnl
240acl_smtp_expn = expn_vrfy
241acl_smtp_vrfy = expn_vrfy
242SECTION(acl)m4_dnl
243expn_vrfy:
244 accept hosts = +trusted
245 deny message = Suck it and see
246
247DIVERT(null)
248###--------------------------------------------------------------------------
284c9d7e
MW
249### Verification of sender address.
250
251SECTION(acl, misc)m4_dnl
252mail_check_auth:
253
254 ## If this isn't a submission then it doesn't need checking.
255 accept condition = ${if !eq{$acl_c_mode}{submission}}
256
257 ## If the caller hasn't formally authenticated, but this is a
258 ## loopback connection, then we can trust identd to tell us the right
259 ## answer. So we should stash the right name somewhere consistent.
260 warn set acl_c_user = $authenticated_id
4ff4ad42 261 hosts = +thishost
284c9d7e
MW
262 !authenticated = *
263 set acl_c_user = $sender_ident
264
265 ## User must be authenticated.
266 deny message = Sender not authenticated
4ff4ad42 267 !hosts = +thishost
284c9d7e
MW
268 !authenticated = *
269
270 ## Make sure that the local part is one that the authenticated sender
271 ## is allowed to claim.
272 deny message = Sender address forbidden to calling user
273 !condition = ${LOOKUP_DOMAIN($sender_address_domain,
274 {${if and {{match_local_part \
275 {$acl_c_user} \
276 {+dom_users}} \
277 {match_local_part \
278 {$sender_address_local_part} \
279 {+dom_locals}}}}},
280 {${if and {{match_local_part \
281 {$sender_address_local_part} \
282 {+user_extaddr}} \
283 {or {{eq {$sender_address_domain} \
284 {}} \
285 {match_domain \
286 {$sender_address_domain} \
287 {+public}}}}}}})}
288
289 ## All done.
290 accept
291
292DIVERT(null)
293###--------------------------------------------------------------------------
185b5456
MW
294### Common options for forwarding routers.
295
296## We're pretty permissive here.
297m4_define(<:FILTER_BASE:>,
298 <:driver = redirect
299 modemask = 002
300 check_owner = false
301 check_group = false
302 allow_filter = true
303 allow_defer = true
304 allow_fail = true
305 forbid_blackhole = false
306 check_ancestor = true:>)
307
308## Common options for forwarding routers at verification time.
309m4_define(<:FILTER_VERIFY:>,
310 <:verify_only = true
311 user = CONF_filter_user
312 forbid_filter_dlfunc = true
313 forbid_filter_logwrite = true
314 forbid_filter_perl = true
315 forbid_filter_readsocket = true
316 forbid_filter_run = true
317 file_transport = dummy
318 directory_transport = dummy
319 pipe_transport = dummy
320 reply_transport = dummy:>)
321
322## Transports for redirection filters.
323m4_define(<:FILTER_TRANSPORTS:>,
7ab75d6f 324 <:file_transport = mailbox
185b5456
MW
325 directory_transport = maildir
326 pipe_transport = pipe
327 reply_transport = reply:>)
328
7ab75d6f
MW
329m4_define(<:FILTER_ROUTER:>,
330<:$1_vrf:
331 $2
332 FILTER_VERIFY<::>$3
333$1:
334 $2
335 verify = no
336 FILTER_TRANSPORTS<::>$4:>)
337
185b5456
MW
338DIVERT(null)
339###--------------------------------------------------------------------------
340### Some standard transports.
341
342m4_define(<:USER_DELIVERY:>,
343 <:delivery_date_add = true
344 envelope_to_add = true
345 return_path_add = true:>)
346
347SECTION(transports)m4_dnl
fa5a92c6
MW
348## A standard transport for remote delivery. By default, try to do TLS, and
349## don't worry too much if it's not very secure: the alternative is sending
350## in plaintext anyway. But all of this can be overridden from the
beb15dae
MW
351## `domains.conf' file. Annoyingly, the `tls_dh_min_bits' setting isn't
352## expanded before use, so we can't set it the obvious way. Instead, encode
353## it into the transport name. This is very unpleasant, of course.
534d411b
MW
354smtp:
355 driver = smtp
356 tls_require_ciphers = CONF_acceptable_ciphers
357 tls_dh_min_bits = 1020
358 tls_tempfail_tryclear = true
359
beb15dae
MW
360m4_define(<:SMTP_TRANS_DHBITS:>,
361 <:driver = smtp
ae9744ce 362 hosts_try_auth = *
fa5a92c6 363 hosts_require_tls = DOMKV(tls-peer-ca, {*}{})
ae9744ce
MW
364 hosts_require_auth = \
365 ${if bool {DOMKV(require-auth, {$value}{false})} {*}{}}
fa5a92c6
MW
366 tls_certificate = DOMKV(tls-certificate, {${expand:$value}}fail)
367 tls_privatekey = DOMKV(tls-private-key, {${expand:$value}}fail)
368 tls_verify_certificates = DOMKV(tls-peer-ca, {${expand:$value}}fail)
369 tls_require_ciphers = \
370 DOMKV(tls-ciphers,
371 {${extract {${expand:$value}} \
372 { good = CONF_good_ciphers \
373 any = CONF_acceptable_ciphers } \
374 {$value} \
375 {${expand:$value}}}} \
376 {CONF_acceptable_ciphers})
beb15dae
MW
377 tls_dh_min_bits = $1
378 tls_tempfail_tryclear = true:>)m4_dnl
beb15dae
MW
379smtp_dhbits_1024:
380 SMTP_TRANS_DHBITS(1020)
381smtp_dhbits_2048:
382 SMTP_TRANS_DHBITS(2046)
185b5456
MW
383
384## Transport to a local SMTP server; use TLS and perform client
385## authentication.
386smtp_local:
387 driver = smtp
388 hosts_require_tls = *
389 tls_certificate = CONF_sysconf_dir/client.cert
390 tls_privatekey = CONF_sysconf_dir/client.key
391 tls_verify_certificates = CONF_ca_dir/ca.cert
392 tls_require_ciphers = CONF_good_ciphers
b6d74252 393 tls_dh_min_bits = 2046
185b5456
MW
394 tls_tempfail_tryclear = false
395 authenticated_sender = ${if def:authenticated_id \
0bed9b7f 396 {$authenticated_id@CONF_master_domain} \
185b5456
MW
397 fail}
398
399## A standard transport for local delivery.
400deliver:
401 driver = appendfile
402 file = /var/mail/$local_part
8f6af4ae
MW
403 group = mail
404 mode = 0600
405 mode_fail_narrower = false
185b5456
MW
406 USER_DELIVERY
407
408## Transports for user filters.
409mailbox:
410 driver = appendfile
8f6af4ae 411 initgroups = true
185b5456
MW
412 USER_DELIVERY
413
414maildir:
415 driver = appendfile
416 maildir_format = true
8f6af4ae 417 initgroups = true
185b5456
MW
418 USER_DELIVERY
419
420pipe:
421 driver = pipe
8f6af4ae
MW
422 path = ${if and {{def:home} {exists{$home/bin}}} {$home/bin:} {}}\
423 /usr/local/bin:/usr/local/sbin:\
424 /usr/bin:/usr/sbin:/bin:/sbin
425 initgroups = true
426 umask = 002
427 return_fail_output = true
428 log_output = true
185b5456
MW
429
430## A special dummy transport for use during address verification.
431dummy:
432 driver = appendfile
433 file = /dev/null
434
435DIVERT(null)
436###--------------------------------------------------------------------------
437### Retry configuration.
438
439SECTION(retry, default)m4_dnl
440## Default.
441* * \
442 F,2h,15m; G,16h,2h,1.5; F,4d,6h
443
444DIVERT(null)
445###----- That's all, folks --------------------------------------------------