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