New file `auth-sender.conf' lists extra allowed senders for users.
[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
119 !condition = \
4ff4ad42
MW
120 ${if and {{match_ip {$sender_host_address} \
121 {<; 127.0.0.0/8 ; ::1}} \
122 {match_domain {$sender_helo_name} \
123 {localhost : +thishost}}}}
124 !condition = \
fe8f2338
MW
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
137SECTION(global, acl)m4_dnl
284c9d7e
MW
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
147SECTION(global, acl)m4_dnl
185b5456
MW
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 262 !authenticated = *
ff4c943d 263 condition = ${if def:sender_ident}
284c9d7e
MW
264 set acl_c_user = $sender_ident
265
ff4c943d 266 ## User must be authenticated by now.
284c9d7e 267 deny message = Sender not authenticated
ff4c943d 268 condition = ${if !def:acl_c_user}
284c9d7e
MW
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
459abd49
MW
273 !condition = \
274 ${if exists {CONF_sysconf_dir/auth-sender.conf} \
275 {${lookup {$acl_c_user} \
276 lsearch \
277 {CONF_sysconf_dir/auth-sender.conf} \
278 {${if match_address \
279 {$sender_address} \
280 {+value}}} \
281 {false}}}}
284c9d7e
MW
282 !condition = ${LOOKUP_DOMAIN($sender_address_domain,
283 {${if and {{match_local_part \
284 {$acl_c_user} \
285 {+dom_users}} \
286 {match_local_part \
287 {$sender_address_local_part} \
288 {+dom_locals}}}}},
289 {${if and {{match_local_part \
290 {$sender_address_local_part} \
291 {+user_extaddr}} \
292 {or {{eq {$sender_address_domain} \
293 {}} \
294 {match_domain \
295 {$sender_address_domain} \
296 {+public}}}}}}})}
297
298 ## All done.
299 accept
300
301DIVERT(null)
302###--------------------------------------------------------------------------
185b5456
MW
303### Common options for forwarding routers.
304
305## We're pretty permissive here.
306m4_define(<:FILTER_BASE:>,
307 <:driver = redirect
308 modemask = 002
309 check_owner = false
310 check_group = false
311 allow_filter = true
312 allow_defer = true
313 allow_fail = true
314 forbid_blackhole = false
315 check_ancestor = true:>)
316
317## Common options for forwarding routers at verification time.
318m4_define(<:FILTER_VERIFY:>,
319 <:verify_only = true
320 user = CONF_filter_user
321 forbid_filter_dlfunc = true
322 forbid_filter_logwrite = true
323 forbid_filter_perl = true
324 forbid_filter_readsocket = true
325 forbid_filter_run = true
326 file_transport = dummy
327 directory_transport = dummy
328 pipe_transport = dummy
329 reply_transport = dummy:>)
330
331## Transports for redirection filters.
332m4_define(<:FILTER_TRANSPORTS:>,
7ab75d6f 333 <:file_transport = mailbox
185b5456
MW
334 directory_transport = maildir
335 pipe_transport = pipe
336 reply_transport = reply:>)
337
7ab75d6f
MW
338m4_define(<:FILTER_ROUTER:>,
339<:$1_vrf:
340 $2
341 FILTER_VERIFY<::>$3
342$1:
343 $2
344 verify = no
345 FILTER_TRANSPORTS<::>$4:>)
346
185b5456
MW
347DIVERT(null)
348###--------------------------------------------------------------------------
349### Some standard transports.
350
351m4_define(<:USER_DELIVERY:>,
352 <:delivery_date_add = true
353 envelope_to_add = true
354 return_path_add = true:>)
355
356SECTION(transports)m4_dnl
fa5a92c6
MW
357## A standard transport for remote delivery. By default, try to do TLS, and
358## don't worry too much if it's not very secure: the alternative is sending
359## in plaintext anyway. But all of this can be overridden from the
beb15dae
MW
360## `domains.conf' file. Annoyingly, the `tls_dh_min_bits' setting isn't
361## expanded before use, so we can't set it the obvious way. Instead, encode
362## it into the transport name. This is very unpleasant, of course.
534d411b
MW
363smtp:
364 driver = smtp
365 tls_require_ciphers = CONF_acceptable_ciphers
366 tls_dh_min_bits = 1020
367 tls_tempfail_tryclear = true
368
beb15dae
MW
369m4_define(<:SMTP_TRANS_DHBITS:>,
370 <:driver = smtp
ae9744ce 371 hosts_try_auth = *
fa5a92c6 372 hosts_require_tls = DOMKV(tls-peer-ca, {*}{})
ae9744ce
MW
373 hosts_require_auth = \
374 ${if bool {DOMKV(require-auth, {$value}{false})} {*}{}}
fa5a92c6
MW
375 tls_certificate = DOMKV(tls-certificate, {${expand:$value}}fail)
376 tls_privatekey = DOMKV(tls-private-key, {${expand:$value}}fail)
377 tls_verify_certificates = DOMKV(tls-peer-ca, {${expand:$value}}fail)
378 tls_require_ciphers = \
379 DOMKV(tls-ciphers,
380 {${extract {${expand:$value}} \
381 { good = CONF_good_ciphers \
382 any = CONF_acceptable_ciphers } \
383 {$value} \
384 {${expand:$value}}}} \
385 {CONF_acceptable_ciphers})
beb15dae
MW
386 tls_dh_min_bits = $1
387 tls_tempfail_tryclear = true:>)m4_dnl
beb15dae
MW
388smtp_dhbits_1024:
389 SMTP_TRANS_DHBITS(1020)
390smtp_dhbits_2048:
391 SMTP_TRANS_DHBITS(2046)
185b5456
MW
392
393## Transport to a local SMTP server; use TLS and perform client
394## authentication.
395smtp_local:
396 driver = smtp
397 hosts_require_tls = *
398 tls_certificate = CONF_sysconf_dir/client.cert
399 tls_privatekey = CONF_sysconf_dir/client.key
400 tls_verify_certificates = CONF_ca_dir/ca.cert
401 tls_require_ciphers = CONF_good_ciphers
b6d74252 402 tls_dh_min_bits = 2046
185b5456
MW
403 tls_tempfail_tryclear = false
404 authenticated_sender = ${if def:authenticated_id \
0bed9b7f 405 {$authenticated_id@CONF_master_domain} \
185b5456
MW
406 fail}
407
408## A standard transport for local delivery.
409deliver:
410 driver = appendfile
411 file = /var/mail/$local_part
8f6af4ae
MW
412 group = mail
413 mode = 0600
414 mode_fail_narrower = false
185b5456
MW
415 USER_DELIVERY
416
417## Transports for user filters.
418mailbox:
419 driver = appendfile
8f6af4ae 420 initgroups = true
185b5456
MW
421 USER_DELIVERY
422
423maildir:
424 driver = appendfile
425 maildir_format = true
8f6af4ae 426 initgroups = true
185b5456
MW
427 USER_DELIVERY
428
429pipe:
430 driver = pipe
8f6af4ae
MW
431 path = ${if and {{def:home} {exists{$home/bin}}} {$home/bin:} {}}\
432 /usr/local/bin:/usr/local/sbin:\
433 /usr/bin:/usr/sbin:/bin:/sbin
434 initgroups = true
435 umask = 002
436 return_fail_output = true
437 log_output = true
185b5456
MW
438
439## A special dummy transport for use during address verification.
440dummy:
441 driver = appendfile
442 file = /dev/null
443
444DIVERT(null)
445###--------------------------------------------------------------------------
446### Retry configuration.
447
448SECTION(retry, default)m4_dnl
449## Default.
450* * \
451 F,2h,15m; G,16h,2h,1.5; F,4d,6h
452
453DIVERT(null)
454###----- That's all, folks --------------------------------------------------