auth.m4, base.m4, exchange.m4: Make sender-address checking universal.
[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
MW
62 ${if def:sender_rcvhost \
63 {from $sender_rcvhost\
185b5456 64 ${if def:sender_helo_name \
2cf9db84
MW
65 { (helo=$sender_helo_name)}}\n\t} \
66 {${if def:sender_ident \
67 {from ${quote_local_part:$sender_ident} }}}}\
185b5456 68 by $primary_hostname \
b92689d6
MW
69 (Exim $version_number)\
70 ${if def:tls_cipher {\n\t} { }}\
185b5456
MW
71 ${if def:received_protocol \
72 {with $received_protocol \
b92689d6 73 ${if def:tls_cipher {(cipher=$tls_cipher)}}}}\n\t\
185b5456 74 ${if def:sender_address \
43e6fc69 75 {(envelope-from $sender_address\
185b5456
MW
76 ${if def:authenticated_id \
77 {; auth=$authenticated_id}})\n\t}}\
78 id $message_exim_id\
79 ${if def:received_for {\n\tfor $received_for}}
80
81SECTION(global, smtp)m4_dnl
82smtp_return_error_details = true
83accept_8bitmime = true
84
85SECTION(global, process)m4_dnl
86extract_addresses_remove_arguments = false
87headers_charset = utf-8
88qualify_domain = CONF_master_domain
89
90SECTION(global, bounce)m4_dnl
91delay_warning = 1h : 24h : 2d
92
93DIVERT(null)
94###--------------------------------------------------------------------------
95### Access control lists.
96
97SECTION(global, acl-after)
98SECTION(global, acl)m4_dnl
99acl_smtp_helo = helo
100SECTION(acl, misc)m4_dnl
101helo:
fe8f2338
MW
102 ## Check that the caller's claimed identity is actually plausible.
103 ## This seems like it's a fairly effective filter on spamminess, but
104 ## it's too blunt a tool. Rather than reject, add a warning header.
105 ## Only we can't do this the easy way, so save it up for use in MAIL.
106 ## Also, we're liable to get a subsequent HELO (e.g., after STARTTLS)
107 ## and we should only care about the most recent one.
108 warn set acl_c_helo_warning = false
109 !condition = \
110 ${if exists {CONF_sysconf_dir/helo.conf} \
111 {${lookup {$sender_helo_name} \
112 partial0-lsearch \
113 {CONF_sysconf_dir/helo.conf} \
114 {${if match_ip \
115 {$sender_host_address} \
116 {$value}}}}}}
117 !verify = helo
118 set acl_c_helo_warning = true
185b5456
MW
119
120 accept
121
122SECTION(global, acl)m4_dnl
284c9d7e
MW
123acl_not_smtp_start = not_smtp_start
124SECTION(acl, misc)m4_dnl
125not_smtp_start:
126 ## Record the user's name.
127 warn set acl_c_user = $sender_ident
128
129 ## Done.
130 accept
131
132SECTION(global, acl)m4_dnl
185b5456
MW
133acl_smtp_mail = mail
134SECTION(acl, mail)m4_dnl
135mail:
136
fe8f2338
MW
137 ## If we stashed a warning header about HELO from earlier, we should
138 ## add it now.
139 warn condition = $acl_c_helo_warning
140 add_header = :after_received:X-Distorted-Warning: \
141 BADHELO \
142 Client's HELO doesn't match its IP address.\n\t\
d70f6d53
MW
143 HELO name=$sender_helo_name, \
144 address=$sender_host_address
fe8f2338 145
185b5456
MW
146 ## Always allow the empty sender, so that we can receive bounces.
147 accept senders = :
148
149 ## Ensure that the sender is routable. This is important to prevent
150 ## undeliverable bounces.
151 require message = Invalid sender; \
152 ($sender_verify_failure; $acl_verify_message)
153 verify = sender
154
155 ## If this is directly from a client then hack on it for a while.
156 warn condition = ${if eq{$acl_c_mode}{submission}}
157 control = submission
158
284c9d7e
MW
159 ## Insist that a local client connect through TLS.
160 deny message = Hosts within CONF_master_domain must use TLS
161 !condition = ${if eq{$acl_c_mode}{submission}}
162 hosts = +allnets
163 !encrypted = *
164
165 ## Check that a submitted message's sender address is allowable.
166 require acl = mail_check_auth
167
185b5456
MW
168SECTION(acl, mail-tail)m4_dnl
169 ## And we're done.
170 accept
171
172SECTION(global, acl)m4_dnl
173acl_smtp_connect = connect
174SECTION(acl, connect)m4_dnl
175connect:
176SECTION(acl, connect-tail)m4_dnl
e12c9586 177 ## Configure variables according to the submission mode.
185b5456 178 warn acl = check_submission
e12c9586
MW
179
180 ## Done.
185b5456
MW
181 accept
182
183check_submission:
184 ## See whether this message needs hacking on.
185 accept !hosts = +localnet
186 !condition = ${if ={$received_port}{CONF_submission_port}}
187 set acl_c_mode = relay
188
189 ## Remember to apply submission controls.
190 warn set acl_c_mode = submission
191
192 ## Done.
193 accept
194
195SECTION(global, acl)m4_dnl
196acl_smtp_rcpt = rcpt
197SECTION(acl, rcpt)m4_dnl
198rcpt:
199
200 ## Reject if the client isn't allowed to relay and the recipient
201 ## isn't in one of our known domains.
202 deny message = Relaying not permitted
203 !hosts = CONF_relay_clients
204 !authenticated = *
205 !domains = +known
206
207 ## Ensure that the recipient is routable.
208 require message = Invalid recipient \
209 ($recipient_verify_failure; $acl_verify_message)
210 verify = recipient
211
212SECTION(acl, rcpt-tail)m4_dnl
213 ## Everything checks out OK: let this one go through.
214 accept
215
216SECTION(global, acl)m4_dnl
217acl_smtp_data = data
218SECTION(acl, data)m4_dnl
219data:
220
221SECTION(acl, data-tail)m4_dnl
222 accept
223
224SECTION(global, acl)m4_dnl
225acl_smtp_expn = expn_vrfy
226acl_smtp_vrfy = expn_vrfy
227SECTION(acl)m4_dnl
228expn_vrfy:
229 accept hosts = +trusted
230 deny message = Suck it and see
231
232DIVERT(null)
233###--------------------------------------------------------------------------
284c9d7e
MW
234### Verification of sender address.
235
236SECTION(acl, misc)m4_dnl
237mail_check_auth:
238
239 ## If this isn't a submission then it doesn't need checking.
240 accept condition = ${if !eq{$acl_c_mode}{submission}}
241
242 ## If the caller hasn't formally authenticated, but this is a
243 ## loopback connection, then we can trust identd to tell us the right
244 ## answer. So we should stash the right name somewhere consistent.
245 warn set acl_c_user = $authenticated_id
246 hosts = +localnet
247 !authenticated = *
248 set acl_c_user = $sender_ident
249
250 ## User must be authenticated.
251 deny message = Sender not authenticated
252 !hosts = +localnet
253 !authenticated = *
254
255 ## Make sure that the local part is one that the authenticated sender
256 ## is allowed to claim.
257 deny message = Sender address forbidden to calling user
258 !condition = ${LOOKUP_DOMAIN($sender_address_domain,
259 {${if and {{match_local_part \
260 {$acl_c_user} \
261 {+dom_users}} \
262 {match_local_part \
263 {$sender_address_local_part} \
264 {+dom_locals}}}}},
265 {${if and {{match_local_part \
266 {$sender_address_local_part} \
267 {+user_extaddr}} \
268 {or {{eq {$sender_address_domain} \
269 {}} \
270 {match_domain \
271 {$sender_address_domain} \
272 {+public}}}}}}})}
273
274 ## All done.
275 accept
276
277DIVERT(null)
278###--------------------------------------------------------------------------
185b5456
MW
279### Common options for forwarding routers.
280
281## We're pretty permissive here.
282m4_define(<:FILTER_BASE:>,
283 <:driver = redirect
284 modemask = 002
285 check_owner = false
286 check_group = false
287 allow_filter = true
288 allow_defer = true
289 allow_fail = true
290 forbid_blackhole = false
291 check_ancestor = true:>)
292
293## Common options for forwarding routers at verification time.
294m4_define(<:FILTER_VERIFY:>,
295 <:verify_only = true
296 user = CONF_filter_user
297 forbid_filter_dlfunc = true
298 forbid_filter_logwrite = true
299 forbid_filter_perl = true
300 forbid_filter_readsocket = true
301 forbid_filter_run = true
302 file_transport = dummy
303 directory_transport = dummy
304 pipe_transport = dummy
305 reply_transport = dummy:>)
306
307## Transports for redirection filters.
308m4_define(<:FILTER_TRANSPORTS:>,
7ab75d6f 309 <:file_transport = mailbox
185b5456
MW
310 directory_transport = maildir
311 pipe_transport = pipe
312 reply_transport = reply:>)
313
7ab75d6f
MW
314m4_define(<:FILTER_ROUTER:>,
315<:$1_vrf:
316 $2
317 FILTER_VERIFY<::>$3
318$1:
319 $2
320 verify = no
321 FILTER_TRANSPORTS<::>$4:>)
322
185b5456
MW
323DIVERT(null)
324###--------------------------------------------------------------------------
325### Some standard transports.
326
327m4_define(<:USER_DELIVERY:>,
328 <:delivery_date_add = true
329 envelope_to_add = true
330 return_path_add = true:>)
331
332SECTION(transports)m4_dnl
333## A standard transport for remote delivery. Try to do TLS, and don't worry
334## too much if it's not very secure: the alternative is sending in plaintext
335## anyway.
336smtp:
337 driver = smtp
338 tls_require_ciphers = CONF_acceptable_ciphers
339 tls_dh_min_bits = 1020
340 tls_tempfail_tryclear = true
341
342## Transport to a local SMTP server; use TLS and perform client
343## authentication.
344smtp_local:
345 driver = smtp
346 hosts_require_tls = *
347 tls_certificate = CONF_sysconf_dir/client.cert
348 tls_privatekey = CONF_sysconf_dir/client.key
349 tls_verify_certificates = CONF_ca_dir/ca.cert
350 tls_require_ciphers = CONF_good_ciphers
b6d74252 351 tls_dh_min_bits = 2046
185b5456
MW
352 tls_tempfail_tryclear = false
353 authenticated_sender = ${if def:authenticated_id \
0bed9b7f 354 {$authenticated_id@CONF_master_domain} \
185b5456
MW
355 fail}
356
357## A standard transport for local delivery.
358deliver:
359 driver = appendfile
360 file = /var/mail/$local_part
8f6af4ae
MW
361 group = mail
362 mode = 0600
363 mode_fail_narrower = false
185b5456
MW
364 USER_DELIVERY
365
366## Transports for user filters.
367mailbox:
368 driver = appendfile
8f6af4ae 369 initgroups = true
185b5456
MW
370 USER_DELIVERY
371
372maildir:
373 driver = appendfile
374 maildir_format = true
8f6af4ae 375 initgroups = true
185b5456
MW
376 USER_DELIVERY
377
378pipe:
379 driver = pipe
8f6af4ae
MW
380 path = ${if and {{def:home} {exists{$home/bin}}} {$home/bin:} {}}\
381 /usr/local/bin:/usr/local/sbin:\
382 /usr/bin:/usr/sbin:/bin:/sbin
383 initgroups = true
384 umask = 002
385 return_fail_output = true
386 log_output = true
185b5456
MW
387
388## A special dummy transport for use during address verification.
389dummy:
390 driver = appendfile
391 file = /dev/null
392
393DIVERT(null)
394###--------------------------------------------------------------------------
395### Retry configuration.
396
397SECTION(retry, default)m4_dnl
398## Default.
399* * \
400 F,2h,15m; G,16h,2h,1.5; F,4d,6h
401
402DIVERT(null)
403###----- That's all, folks --------------------------------------------------