chiark / gitweb /
90e20f25d2bb7ef54a85408d5794725bc132d3b7
[exim-config] / base.m4
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
28 admin_groups = CONF_admin_groups
29 prod_requires_admin = false
30
31 SECTION(global, logging)m4_dnl
32 log_file_path = : syslog
33 log_selector = \
34         +smtp_confirmation \
35         +tls_peerdn
36 log_timezone = true
37 syslog_duplication = false
38 syslog_timestamp = false
39
40 SECTION(global, daemon)m4_dnl
41 local_interfaces = <; CONF_interfaces
42 extra_local_interfaces = <; 0.0.0.0 ; ::
43
44 SECTION(global, resource)m4_dnl
45 deliver_queue_load_max = 8
46 queue_only_load = 12
47 smtp_accept_max = 16
48 smtp_accept_queue = 32
49 smtp_accept_reserve = 4
50 smtp_load_reserve = 10
51 smtp_reserve_hosts = +trusted
52
53 SECTION(global, policy)m4_dnl
54 host_lookup = *
55
56 SECTION(global, users)m4_dnl
57 gecos_name = $1
58 gecos_pattern = ([^,:]*)
59
60 SECTION(global, incoming)m4_dnl
61 received_header_text = Received: \
62         ${if def:sender_rcvhost \
63              {from $sender_rcvhost\n\t} \
64              {${if def:sender_ident \
65                    {from ${quote_local_part:$sender_ident} }}}}\
66         by $primary_hostname \
67         (Exim $version_number)\
68         ${if def:tls_cipher {\n\t} { }}\
69         ${if def:received_protocol \
70              {with $received_protocol \
71               ${if def:tls_cipher {(cipher=$tls_cipher)}}}}\n\t\
72         ${if def:sender_address \
73              {(envelope-from $sender_address\
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
79 SECTION(global, smtp)m4_dnl
80 smtp_return_error_details = true
81 accept_8bitmime = true
82
83 SECTION(global, process)m4_dnl
84 extract_addresses_remove_arguments = false
85 headers_charset = utf-8
86 qualify_domain = CONF_master_domain
87
88 SECTION(global, bounce)m4_dnl
89 delay_warning = 1h : 24h : 2d
90
91 SECTION(global, tls)m4_dnl
92 tls_certificate = CONF_sysconf_dir/server.cert
93 tls_privatekey = CONF_sysconf_dir/server.key
94 tls_advertise_hosts = ${if exists {CONF_sysconf_dir/server.key} {*}{}}
95 tls_dhparam = CONF_ca_dir/dh-param-2048.pem
96 tls_require_ciphers = ${if or {{={$received_port}{CONF_submission_port}} \
97                                {match_ip {$sender_host_address}{+trusted}}} \
98                            {CONF_good_ciphers} \
99                            {CONF_acceptable_ciphers}}
100 tls_verify_certificates = CONF_ca_dir/ca.cert
101 tls_verify_hosts = ${if eq{$acl_c_mode}{submission} {} {+allnets}}
102
103 DIVERT(null)
104 ###--------------------------------------------------------------------------
105 ### Access control lists.
106
107 SECTION(global, acl-after)
108 SECTION(global, acl)m4_dnl
109 acl_smtp_helo = helo
110 SECTION(acl, misc)m4_dnl
111 helo:
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 = \
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 = \
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
134
135         accept
136
137 SECTION(global, acl)m4_dnl
138 acl_not_smtp_start = not_smtp_start
139 SECTION(acl, misc)m4_dnl
140 not_smtp_start:
141         ## Record the user's name.
142         warn     set acl_c_user = $sender_ident
143
144         ## Done.
145         accept
146
147 SECTION(global, acl)m4_dnl
148 acl_smtp_mail = mail
149 SECTION(acl, mail)m4_dnl
150 mail:
151
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\
158                         helo-name=$sender_helo_name \
159                         address=$sender_host_address
160
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
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
183 SECTION(acl, mail-tail)m4_dnl
184         ## And we're done.
185         accept
186
187 SECTION(global, acl)m4_dnl
188 acl_smtp_connect = connect
189 SECTION(acl, connect)m4_dnl
190 connect:
191 SECTION(acl, connect-tail)m4_dnl
192         ## Configure variables according to the submission mode.
193         warn     acl = check_submission
194
195         ## Done.
196         accept
197
198 check_submission:
199         ## See whether this message needs hacking on.
200         accept  !hosts = +thishost
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
210 SECTION(global, acl)m4_dnl
211 acl_smtp_rcpt = rcpt
212 SECTION(acl, rcpt)m4_dnl
213 rcpt:
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
227 SECTION(acl, rcpt-tail)m4_dnl
228         ## Everything checks out OK: let this one go through.
229         accept
230
231 SECTION(global, acl)m4_dnl
232 acl_smtp_data = data
233 SECTION(acl, data)m4_dnl
234 data:
235
236 SECTION(acl, data-tail)m4_dnl
237         accept
238
239 SECTION(global, acl)m4_dnl
240 acl_smtp_expn = expn_vrfy
241 acl_smtp_vrfy = expn_vrfy
242 SECTION(acl)m4_dnl
243 expn_vrfy:
244         accept   hosts = +trusted
245         deny     message = Suck it and see
246
247 DIVERT(null)
248 ###--------------------------------------------------------------------------
249 ### Verification of sender address.
250
251 SECTION(acl, misc)m4_dnl
252 mail_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
261                  hosts = +thishost
262                 !authenticated = *
263                  condition = ${if def:sender_ident}
264                  set acl_c_user = $sender_ident
265
266         ## User must be authenticated by now.
267         deny     message = Sender not authenticated
268                  condition = ${if !def:acl_c_user}
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 = \
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}}}}
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
301 DIVERT(null)
302 ###--------------------------------------------------------------------------
303 ### Common options for forwarding routers.
304
305 ## We're pretty permissive here.
306 m4_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.
318 m4_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.
332 m4_define(<:FILTER_TRANSPORTS:>,
333         <:file_transport = mailbox
334         directory_transport = maildir
335         pipe_transport = pipe
336         reply_transport = reply:>)
337
338 m4_define(<:FILTER_ROUTER:>,
339 <:$1_vrf:
340         $2
341         FILTER_VERIFY<::>$3
342 $1:
343         $2
344         verify = no
345         FILTER_TRANSPORTS<::>$4:>)
346
347 DIVERT(null)
348 ###--------------------------------------------------------------------------
349 ### Some standard transports.
350
351 m4_define(<:USER_DELIVERY:>,
352         <:delivery_date_add = true
353         envelope_to_add = true
354         return_path_add = true:>)
355
356 SECTION(transports)m4_dnl
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
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.
363 smtp:
364         driver = smtp
365         tls_require_ciphers = CONF_acceptable_ciphers
366         tls_dh_min_bits = 1020
367         tls_tempfail_tryclear = true
368
369 m4_define(<:SMTP_TRANS_DHBITS:>,
370         <:driver = smtp
371         hosts_try_auth = *
372         hosts_require_tls = DOMKV(tls-peer-ca, {*}{})
373         hosts_require_auth = \
374                 ${if bool {DOMKV(require-auth, {$value}{false})} {*}{}}
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})
386         tls_dh_min_bits = $1
387         tls_tempfail_tryclear = true:>)m4_dnl
388 smtp_dhbits_1024:
389         SMTP_TRANS_DHBITS(1020)
390 smtp_dhbits_2048:
391         SMTP_TRANS_DHBITS(2046)
392
393 ## Transport to a local SMTP server; use TLS and perform client
394 ## authentication.
395 smtp_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
402         tls_dh_min_bits = 2046
403         tls_tempfail_tryclear = false
404         authenticated_sender = ${if def:authenticated_id \
405                                     {$authenticated_id@CONF_master_domain} \
406                                     fail}
407
408 ## A standard transport for local delivery.
409 deliver:
410         driver = appendfile
411         file = /var/mail/$local_part
412         group = mail
413         mode = 0600
414         mode_fail_narrower = false
415         USER_DELIVERY
416
417 ## Transports for user filters.
418 mailbox:
419         driver = appendfile
420         initgroups = true
421         USER_DELIVERY
422
423 maildir:
424         driver = appendfile
425         maildir_format = true
426         initgroups = true
427         USER_DELIVERY
428
429 pipe:
430         driver = pipe
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
438
439 ## A special dummy transport for use during address verification.
440 dummy:
441         driver = appendfile
442         file = /dev/null
443
444 DIVERT(null)
445 ###--------------------------------------------------------------------------
446 ### Retry configuration.
447
448 SECTION(retry, default)m4_dnl
449 ## Default.
450 *                                       * \
451         F,2h,15m; G,16h,2h,1.5; F,4d,6h
452
453 DIVERT(null)
454 ###----- That's all, folks --------------------------------------------------