eximconf: reject poor Outlook forgeries
[mirror/dsa-puppet.git] / modules / exim / templates / eximconf.erb
1 ##
2 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
3 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
4 ##
5
6 # This is the main exim4 configuration file based on the 28.08.05 version by
7 # ametzler
8
9 # The configuration file uses a set of rules to generate an
10 # acceptable mail environment for debian.org machines. It deviates
11 # considerably from what could be considered a standard Exim configuration.
12
13 # This configuration file brings in the necessary information from
14 # other databases stored in /etc/exim4/ and the files distributed by ud-ldap
15
16 # This file is independent of the local host, it should not be changed
17 # per machine. primary_hostname is used in all places that require per-host 
18 # settings.
19
20 # The configuration files in /etc/exim4 are as follows:
21 #  locals - This is a list of domains that are considered local. A local
22 #           domain is essentially one for which deliveries to /var/mail
23 #           will be attempted. The users available for local delivery
24 #           come from /etc/passwd and /etc/aliases. Wildcards are not
25 #           permitted.
26 #  virtualdomains - This is a list of all virtual domains. A virtual domain
27 #           is much like a local domain, execpt that the delivery location
28 #           and allowed set of users is controlled by a virtual domain
29 #           alias file and not /etc/passwd. Wildcards are permitted
30 #  bsmtp_domains - Domains that we deliver locally via bsmtp
31 #  submission-domains - Domains for which mail will be accepted via the
32 #           submission port
33 <%- if @is_mailrelay -%>
34 #  mailhubdomains - Domains for which we are the MX, but the mail is relayed
35 #           elsewhere.  This is designed for use with small volume or
36 #           restricted machines that need to use a smarthost for mail
37 #           traffic.  We will relay for them based on ssl cert validation
38 #           but we need to teach Exim how to route the mail to them.  This is
39 #           that list.
40 <%- end -%>
41
42 # From /var/lib/misc / UD:
43 #
44 # mail-forward.db - aliases for @d.o
45 # user-forward.db - aliases for @thishost.d.o
46 #
47 # Note that the BDB files generated by ud-ldap use keys that are not
48 # null-terminated, so Exim needs to use the "dbmnz" lookup type, rather
49 # than "dbm".
50
51 # Exim's wildcard mechanism is a bit odd in that to say "any address in
52 # debian.org including debian.org" you must use two patterns,
53 #   *.debian.org
54 #   debian.org
55 # Also you can only place a * before a . and as the first char in a string.
56 # Wildcards always match last so they may be used as a catchall.
57
58 # Further details can be found in each of the files.
59
60 # Useful Exim commands:
61 #  exim4 -qf  - Try sending all messages right now, including frozen ones
62 #  exim4 -bt foo@blah - Write what Exim would do if it saw the address
63 #                      Great for testing virtual domains and forward files
64
65 # Special Features for users:
66 # .forward-foo - is understood as an extension address for bar-foo@cow.com
67 # .forward-default - is understood to be a catch all for bar-*@cow.com
68 # .procmailrc - with no .forward file invokes procmail for delivery
69 #               automatically.
70
71 # For virtual domains the first lookup is done against a linear text
72 # database called 'aliases', then .forward files are consulted. Exim
73 # filtering is available for these .forward files only. .forward-default
74 # is the universal catch all for everything not handled.
75
76 # Heuristic check (none bad enough to cause a hard reject, but in aggregate
77 # will trigger things like rcpt to rate limiting or possibly a reject if
78 # enough hits are triggered).
79 #
80 # value is stored in acl_c_scr
81
82 ######################################################################
83 #                    MAIN CONFIGURATION SETTINGS                     #
84 ######################################################################
85
86 <%- if @heavy -%>
87  perl_startup = do '/etc/exim4/exim_surbl.pl'
88 <%- end -%>
89
90 # These options specify the Access Control Lists (ACLs) that
91 # are used for incoming SMTP messages - after the RCPT and DATA
92 # commands, respectively.
93
94 acl_smtp_helo = check_helo
95 acl_smtp_rcpt = ${if ={$interface_port}{587} {check_submission}{check_recipient}}
96 acl_smtp_data = check_message
97 <%- if @heavy -%>
98 acl_smtp_mime = acl_check_mime
99 <%- end -%>
100 acl_smtp_predata = acl_check_predata
101
102 # accept domain literal syntax in e-mail addresses. To actually make use of
103 # this a router is also required
104 allow_domain_literals = true
105
106 # This setting defines a named domain list called
107 # local_domains. It will be referenced
108 # later on by the syntax "+local_domains".
109 # Other domain and host lists may follow.
110 # @ is the local FQDN, @[] matches the IP address of any local interface.
111
112 domainlist local_domains = @ : \
113     @[] : \
114     localhost : \
115     ${if exists {/etc/exim4/locals}{lsearch;/etc/exim4/locals}}
116
117 domainlist virtual_domains = partial-lsearch;/etc/exim4/virtualdomains
118
119 domainlist submission_domains = ${if exists {/etc/exim4/submission-domains}{/etc/exim4/submission-domains}{}}
120
121 domainlist bsmtp_domains = ${if exists {/etc/exim4/bsmtp}{partial-lsearch;/etc/exim4/bsmtp}{}}
122
123 domainlist handled_domains = +local_domains : +virtual_domains : +bsmtp_domains
124
125 domainlist ourself_and_handled = $primary_hostname : +handled_domains
126
127 localpartlist local_only_users = lsearch;/etc/exim4/localusers
128
129 localpartlist postmasterish = postmaster : abuse : hostmaster
130
131 hostlist debianhosts = <; ; 127.0.0.1 ; ::1 ; /var/lib/misc/thishost/debianhosts
132
133 hostlist reservedaddrs = 0.0.0.0/8 : 127.0.0.0/8 : 10.0.0.0/8 : 169.254.0.0/16 : 172.16.0.0/12 : 192.0.0.0/24 : 192.168.0.0/16 : 224.0.0.0/4 : 240.0.0.0/5 : 248.0.0.0/5
134
135 domainlist google_mxen = aspmx.l.google.com : gmail-smtp-in.l.google.com : \
136                          *.aspmx.l.google.com : *.gmail-smtp-in.l.google.com
137
138 domainlist single_domain_mx = +google_mxen
139 domainlist ipv4_only_domain_mx = +google_mxen
140
141 <%- if @is_mailrelay -%>
142 # Domains we relay for; that is domains that aren't considered local but we 
143 # accept mail for them.
144 domainlist mailhubdomains = lsearch;/etc/exim4/manualroute
145
146 <%- end -%>
147 tls_certificate = /etc/exim4/ssl/thishost.crt
148 tls_privatekey = /etc/exim4/ssl/thishost.key
149 tls_try_verify_hosts = *
150 tls_verify_certificates = /etc/exim4/ssl/ca.crt
151 tls_crl = /etc/exim4/ssl/ca.crl
152
153 # The setting below causes Exim to do a reverse DNS lookup on all incoming
154 # IP calls, in order to get the true host name. If you feel this is too
155 # expensive, you can specify the networks for which a lookup is done, or
156 # remove the setting entirely.
157 host_lookup = *
158
159 # If this option is set, then any process that is running as one of the
160 # listed users may pass a message to Exim and specify the sender's
161 # address using the "-f" command line option, without Exim's adding a
162 # "Sender" header.
163
164 untrusted_set_sender = *
165
166 # Some spam scanners (*cough* irritated *cough*) want the Sender field
167 # to exist.  Appease them by not actually adding a Sender field.
168
169 local_from_check = false
170
171 # Some operating systems use the "gecos" field in the system password file
172 # to hold other information in addition to users' real names. Exim looks up
173 # this field when it is creating "sender" and "from" headers. If these options
174 # are set, Exim uses "gecos_pattern" to parse the gecos field, and then
175 # expands "gecos_name" as the user's name. $1 etc refer to sub-fields matched
176 # by the pattern.
177
178 gecos_pattern = ^([^,:]*)
179 gecos_name = $1
180
181 # Do *not* include the body of the original message in a bounce
182 # The combination of bounce_return_message and bounce_return_body
183 # allows us to return only the headers within a bounce
184
185 bounce_return_message = true
186 bounce_return_body    = false
187
188 # This tells Exim to immediately discard error messages (ie double bounces).
189 ignore_bounce_errors_after = 0s
190 auto_thaw = 1d
191 timeout_frozen_after=14d
192
193 message_size_limit = 100M
194 message_logs = false
195 smtp_accept_max_per_host = ${if match_ip {$sender_host_address}{+debianhosts}{0}{7}}
196 <%- if @heavy -%>
197 smtp_accept_max = 300
198 smtp_accept_queue = 200
199 smtp_accept_queue_per_connection = 50
200 smtp_accept_reserve = 25
201 <%- else -%>
202 smtp_accept_max = 30
203 smtp_accept_queue = 20
204 smtp_accept_queue_per_connection = 10
205 smtp_accept_reserve = 5
206 <%- end -%>
207 smtp_reserve_hosts = +debianhosts
208
209 split_spool_directory = true
210 check_spool_inodes = 200
211 check_spool_space  = 20M
212
213 delay_warning =
214
215 <%- if @heavy -%>
216 message_body_visible = 5000
217 queue_run_max = 50
218 deliver_queue_load_max = 50
219 queue_only_load = 35
220 smtp_load_reserve = 20
221 <%- else -%>
222 queue_run_max = 5
223 <%- if scope.lookupvar('::processorcount').to_s != 'undefined' -%>
224 deliver_queue_load_max = <%= [scope.lookupvar('::processorcount').to_i,2].max * 5 %>
225 queue_only_load = <%= [scope.lookupvar('::processorcount').to_i,2].max * 4 %>
226 <%- else -%>
227 deliver_queue_load_max = 10
228 queue_only_load = 8
229 <%- end -%>
230 <%- end -%>
231 queue_list_requires_admin = false
232
233 <%- if has_variable?("clamd") && @clamd -%>
234 av_scanner = clamd:/var/run/clamav/clamd.ctl
235 <%- end -%>
236
237 <%= 
238 ports = []
239 out = "daemon_smtp_ports = "
240 ports << 25
241 if @mail_port  # if we have an overridden mail_port
242   ports << @mail_port
243 end
244
245 if @is_bugsmx
246   ports << 587
247 end
248
249 if @is_mailrelay
250   ports << @smarthost_port
251 end
252
253 out += ports.uniq.sort.join(" : ")
254 out
255 %>
256
257 admin_groups = adm
258 remote_sort_domains = *.debian.org:*.debian.net
259
260 pipelining_advertise_hosts = !*
261 tls_advertise_hosts = *
262 smtp_enforce_sync = true
263
264 log_selector = \
265                +subject \
266                +tls_cipher \
267                +tls_peerdn \
268                +queue_time \
269                +queue_time_overall \
270                +deliver_time \
271                +received_recipients \
272                +sender_on_delivery \
273                +return_path_on_delivery \
274                +incoming_port \
275                +unknown_in_list \
276                +smtp_connection \
277                +smtp_incomplete_transaction \
278                +smtp_confirmation \
279                +smtp_syntax_error \
280                +smtp_no_mail \
281                +smtp_protocol_error
282
283 received_header_text = Received: ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
284                                  {${if def:sender_ident {from ${quote_local_part:$sender_ident} }}${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
285                                  ${if and {{eq {$tls_certificate_verified}{1}}{def:tls_peerdn}}{from $tls_peerdn (verified)\n\t}}\
286                                  by $primary_hostname ${if def:received_protocol {with $received_protocol}} ${if def:tls_cipher {($tls_cipher)\n\t}}\
287                                  (Exim $version_number)\n\t\
288                                  ${if def:sender_address {(envelope-from <$sender_address>)\n\t}}\
289                                  id $message_exim_id${if def:received_for {\n\tfor $received_for}}
290
291 # macro definitions.
292 # Do not wrap!
293 MAX_SCAN_SIZE = 256000
294 VDOMAINDATA = ${lookup{$domain}partial-lsearch{/etc/exim4/virtualdomains}{$value}}
295 VSENDERDOMAINDATA = ${lookup{$sender_address_domain}partial-lsearch{/etc/exim4/virtualdomains}{$value}}
296 WHITELIST = ${if match_domain{$domain}{+virtual_domains}\
297             {${if exists {${extract{directory}{VDOMAINDATA}{${value}/whitelist}}}\
298             {${lookup{$local_part}lsearch{${extract{directory}{VDOMAINDATA}{${value}/whitelist}}}{$value}{}}}{}}}\
299             {/etc/exim4/whitelist} } : \
300             ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-whitelist}{$value}{}}
301 GREYLIST_LOCAL_PARTS = ${if match_domain{$domain}{+virtual_domains}\
302                        {${if exists {${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}\
303                        {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}{$local_part}{}}}{}}}\
304                        {${lookup{$local_part}lsearch{/etc/exim4/grey_users}{$local_part}{}}}} : \
305                        ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-greylist}{$local_part}{}}
306 # Users from LDAP can decide whether to subscribe to default filtering.
307 # If a user has not explicitly disabled the option, the assumption is in
308 # favour of filtering.
309 HAS_DEFAULT_OPTIONS = ${if and {\
310                        {eq{${lookup{$local_part}dbmnz{/var/lib/misc/$primary_hostname/default-mail-options.db}{$value}{TRUE}}}{TRUE}}\
311                        {exists{${extract{directory}{VDOMAINDATA}{${value}/mail-forward.db}}}}\
312                        {! eq {${lookup{$local_part}dbmnz{${extract{directory}{VDOMAINDATA}{${value}/mail-forward.db}}}}}{}}\
313                        }}
314 <%- if @is_rtmaster -%>
315 # This subject rewrite is embedded in double-quoted strings. As such, some of
316 # the items need more escaping than usual, otherwise \N becomes simply "N" and
317 # the following "\[" a literal "[".
318 # Note that the lack of space in "Subject:${" is intentional, as the raw Subject
319 # header will include the leading space, if present.
320 RT_SUBJECT = Subject:${if and {{first_delivery}{match {${sg {$rh_Subject:}{\\n([ \\t])}{ }}}{\\N(?i)(.*?)\\[?debian rt\\]?[:\\t ]*(.*)\\N}}}{$1$2}{$h_subject:}}
321 RT_QUEUE_MAP = /srv/rt.debian.org/mail/rt_queue_map
322 <%- end -%>
323
324 keep_environment =
325 add_environment =
326
327 ######################################################################
328 #                        ACL CONFIGURATION                           #
329 ######################################################################
330 begin acl
331
332 acl_spamlovers:
333   # There are a few profiles that don't want much smtp time checking of
334   # mail.  It's easier to track them in one place
335
336   accept  condition      = ${if eq {$acl_m_prf}{PopconMail}}
337   accept  condition      = ${if eq {$acl_m_prf}{BugsMail}}
338   deny
339
340 acl_getprofile:
341
342   # Determine the mail profile for this recipient.
343   # An empty string implies no match has been found.
344
345   warn    set acl_m_rprf = 
346
347   warn    recipients     = survey@popcon.debian.org
348           set acl_m_rprf = PopconMail
349
350   accept  condition      = ${if !eq {$acl_m_rprf}{}}
351
352   warn    local_parts    = +local_only_users
353           domains        = +local_domains
354           hosts          = !+debianhosts
355           set acl_m_rprf = localonly
356
357 <%- if @is_mailrelay -%>
358   warn    local_parts    = +local_only_users
359           domains        = +mailhubdomains
360           hosts          = !+debianhosts
361           set acl_m_rprf = localonly
362
363 <%- end -%>
364   accept  condition      = ${if !eq {$acl_m_rprf}{}}
365
366 <%- if @is_rtmaster -%>
367   warn    domains        = rt.debian.org
368           set acl_m_rprf = RTMail
369
370   accept  condition      = ${if !eq {$acl_m_rprf}{}}
371
372 <%- end -%>
373 <%- if @is_bugsmx -%>
374   warn    domains        = bugs.debian.org
375           set acl_m_rprf = BugsMail
376
377   accept  condition      = ${if !eq {$acl_m_rprf}{}}
378
379 <%- end -%>
380 <%- if @is_packagesmaster -%>
381   warn    domains        = packages.debian.org
382           set acl_m_rprf = PackagesMail
383
384   accept  condition      = ${if !eq {$acl_m_rprf}{}}
385
386 <%- end -%>
387 <%- if @is_packagesqamaster -%>
388   warn    recipients     = owner@packages.qa.debian.org : postmaster@packages.qa.debian.org
389           set acl_m_rprf = PTSOwner
390
391   accept  condition      = ${if !eq {$acl_m_rprf}{}}
392
393   warn    senders        = :
394           domains        = packages.qa.debian.org
395           condition      = ${if match{$local_part}{\N^bounces+\N}}
396           set acl_m_rprf = PTSListBounce
397
398   accept  condition      = ${if !eq {$acl_m_rprf}{}}
399
400   warn    domains        = packages.qa.debian.org
401           set acl_m_rprf = PTSMail
402
403   accept  condition      = ${if !eq {$acl_m_rprf}{}}
404
405 <%- end -%>
406   warn    recipients     = change@db.debian.org : changes@db.debian.org : chpasswd@db.debian.org : ping@db.debian.org : recommend@nm.debian.org
407           set acl_m_rprf = DBSignedMail
408
409   accept  condition      = ${if !eq {$acl_m_rprf}{}}
410
411   warn    domains        = +virtual_domains
412           condition      = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction}}}}
413           condition      = ${if eq{${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction}}}{$value}{}}}{markup}}
414           set acl_m_rprf = markup
415
416   accept  condition      = ${if !eq {$acl_m_rprf}{}}
417
418   warn    domains        = +virtual_domains
419           condition      = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction}}}}
420           condition      = ${if eq{${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction}}}{$value}{}}}{blackhole}}
421           set acl_m_rprf = blackhole
422
423   accept  condition      = ${if !eq {$acl_m_rprf}{}}
424
425   warn    domains        = +virtual_domains
426           condition      = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction.db}}}}
427           condition      = ${if eq{${lookup{$local_part}dbmnz{${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction.db}}}{$value}{}}}{markup}}
428           set acl_m_rprf = markup
429
430   accept  condition      = ${if !eq {$acl_m_rprf}{}}
431
432   warn    domains        = +virtual_domains
433           condition      = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction.db}}}}
434           condition      = ${if eq{${lookup{$local_part}dbmnz{${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction.db}}}{$value}{}}}{blackhole}}
435           set acl_m_rprf = blackhole
436
437   accept  condition      = ${if !eq {$acl_m_rprf}{}}
438
439   warn    domains        = +local_domains
440           condition      = ${if eq{${lookup{$local_part}dbmnz{/var/lib/misc/${primary_hostname}/mail-contentinspectionaction.db}{$value}{}}}{markup}}
441           set acl_m_rprf = markup
442
443   accept  condition      = ${if !eq {$acl_m_rprf}{}}
444
445   warn    domains        = +local_domains
446           condition      = ${if eq{${lookup{$local_part}dbmnz{/var/lib/misc/${primary_hostname}/mail-contentinspectionaction.db}{$value}{}}}{blackhole}}
447           set acl_m_rprf = blackhole
448
449   accept  condition      = ${if !eq {$acl_m_rprf}{}}
450
451   warn    set acl_m_rprf = normal
452
453   accept
454
455 check_helo:
456
457   warn    set acl_c_scr    = 0
458
459 <%- if @is_mailrelay -%>
460   accept  verify   = certificate
461
462 <%- end -%>
463 <%- unless @use_smarthost -%>
464   # These are in HELO acl so that they are only run once.  They increment a counter,
465   # so we don't want it to increment per rcpt to.
466
467   # high trust
468   warn    dnslists       = list.dnswl.org&0.0.0.3
469           log_message    = Hit on list.dnswl.org for $sender_host_address
470           set acl_c_scr  = ${eval:$acl_c_scr-30}
471
472   # >= medium trust
473   warn    dnslists       = list.dnswl.org&0.0.0.2
474           log_message    = Hit on list.dnswl.org for $sender_host_address
475           set acl_c_scr  = ${eval:$acl_c_scr-20}
476
477   # any form of listing
478   warn    dnslists       = list.dnswl.org
479           log_message    = Hit on list.dnswl.org for $sender_host_address
480           set acl_c_scr  = ${eval:$acl_c_scr-10}
481
482   warn    condition      = ${if isip {$sender_helo_name}}
483           log_message    = remote host used IP address in HELO/EHLO greeting
484           set acl_c_scr  = ${eval:$acl_c_scr+20}
485
486   warn    !hosts         = +debianhosts
487           condition      = ${if eq{$host_lookup_failed}{1}}
488           set acl_c_scr  = ${eval:$acl_c_scr+20}
489
490   # HELO looks like a dynamic address (with RDNS match)
491   warn    !hosts         = +debianhosts
492           condition      = ${if eq{$host_lookup_failed}{0}}
493           condition      = ${if match{$sender_host_name}{\N(^[^\.]*[0-9]\-+[0-9]|^[^\.]*[0-9]{5,}[^\.]|^([^\.]+\.)?[0-9][^ \.]*\.[^\.]+\..+\.[a-z]|^[^\.]*[0-9]\.[^\.]*[0-9]-[0-9]|^(dyn|cable|dhcp|dialup|ppp|adsl)[^\.]*[0-9])\N}}
494           set acl_c_scr  = ${eval:$acl_c_scr+20}
495
496   # HELO looks like a dynamic address
497   warn    !hosts         = +debianhosts
498           condition      = ${if match{$sender_helo_name}{\N(^[^\.]*[0-9]\-+[0-9]|^[^\.]*[0-9]{5,}[^\.]|^([^\.]+\.)?[0-9][^ \.]*\.[^\.]+\..+\.[a-z]|^[^\.]*[0-9]\.[^\.]*[0-9]-[0-9]|^(dyn|cable|dhcp|dialup|ppp|adsl)[^\.]*[0-9])\N}}
499           set acl_c_scr  = ${eval:$acl_c_scr+20}
500
501   # mail from a dynamic IP address range
502   warn    !hosts         = +debianhosts
503           dnslists       = dul.dnsbl.sorbs.net
504           set acl_c_scr  = ${eval:$acl_c_scr+15}
505
506   # If the sender's helo name is empty, the message will be rejected later
507   # because the helo is empty.  If the rDNS lookup failed, we are already
508   # going to greylist them, so no sense worrying about it here.  Finally,
509   # if rDNS does not match helo name (both lower cased first), greylist.
510
511   warn    !hosts         = +debianhosts
512           condition      = ${if !eq {$host_lookup_failed}{1}}
513           condition      = ${if def:sender_helo_name}
514           condition      = ${if !eq {${lc:$sender_helo_name}}{${lc:$sender_host_name}}}
515           log_message    = HELO doesn't match rDNS
516           set acl_c_scr  = ${eval:$acl_c_scr+8}
517
518   # Regexes of doom
519   # matches 098325879 - looks fishy
520
521   warn condition        = ${if and { \
522                                      { !match{$sender_helo_name}{\N^\[.+\]$\N} } \
523                                      { !match{$sender_helo_name}{\N^(?i)((?=[^-])[a-z0-9-]*[a-z0-9]\.)+[a-z]{2,6}$\N} } \
524                                     } \
525                             }
526        log_message      = non-FQDN HELO
527        set acl_c_scr    = ${eval:$acl_c_scr+12}
528
529   # Matches DOMAIN99.com - looks bad
530
531   warn condition       = ${if match {$sender_helo_name}{\N^[A-Z]+[A-Z0-9\-]+\.[A-Za-z0-9]+$\N}}
532        log_message     = SHOUTING HELO
533        set acl_c_scr   = ${eval:$acl_c_scr+7}
534
535   # Random HELO (run of 7 consonants) (constructed by viruses).  We purposefully
536   # skip matching on machines named .*smtp.*, since that's 4 already.  This is a fairly
537   # naive test, so it's not worth much
538
539   warn condition       = ${if !match {${lc:$sender_helo_name}}{smtp}}
540        condition       = ${if match {${lc:$sender_helo_name}}{\N^[a-z0-9]+\.[a-z]+$\N}}
541        condition       = ${if match {${lc:$sender_helo_name}}{\N.*[bcdfghjklmnpqrstvwxz]{7,}.*\.[a-z]+$\N}}
542        log_message     = random HELO
543        set acl_c_scr   = ${eval:$acl_c_scr+5}
544
545 <%- else -%>
546   drop !hosts          = +debianhosts
547        log_message     = mail from non-d.o host
548        message         = Interesting.  I doubt that should have happened.
549
550 <%- end -%>
551   # Implicit, but simpler to just say it
552   accept
553
554 #!!# ACL that is used after the RCPT command on the submission port
555 check_submission:
556
557   accept  hosts = +debianhosts
558
559 <%- if @is_mailrelay -%>
560   accept  verify   = certificate
561
562 <%- end -%>
563   # Defer after too many bad RCPT TO's.  Legit MTAs will retry later.
564   # This is a rough pass at preventing address harvesting or other mail blasts.
565
566   defer  log_message   = Too many bad recipients ${eval:$rcpt_fail_count} out of $rcpt_count
567          message       = Too many bad recipients, try again later
568          condition     = ${if > {${eval:$rcpt_fail_count}}{3}}
569
570   defer
571           ratelimit      = 5 / 60m / per_rcpt / $sender_host_address
572           !hosts         = +debianhosts
573           message        = sorry, only 5 reports per hour for submission
574
575   accept  domains  = +local_domains
576           hosts    = +debianhosts
577           endpass
578           verify   = recipient
579
580 <%- if @is_mailrelay -%>
581   accept  domains  = +mailhubdomains
582           endpass
583           verify   = recipient/callout=30s,defer_ok,use_sender,no_cache
584
585 <%- end -%>
586   accept  domains  = +submission_domains
587           endpass
588           verify   = recipient
589
590   deny    message = relay not permitted
591
592 #!!# ACL that is used after the RCPT command
593 check_recipient:
594
595 <%- if @is_mailrelay -%>
596   accept  verify   = certificate
597
598 <%- end -%>
599   accept  hosts = <; ::1 ; 127.0.0.1 ; @
600   warn    acl           = acl_getprofile
601           condition     = ${if eq{$acl_m_prf}{}}
602           set acl_m_prf = $acl_m_rprf
603
604   defer   condition     = ${if !eq{$acl_m_prf}{$acl_m_rprf}}
605           message       = Different profile, please retry
606           log_message   = Only one profile at a time, please
607
608   warn    set acl_m_rdefopt = ${if bool_lax{HAS_DEFAULT_OPTIONS}}
609
610   warn    condition        = ${if eq{$acl_m_defopt}{}}
611           set acl_m_defopt = $acl_m_rdefopt
612
613   defer   condition     = ${if !eq{$acl_m_defopt}{$acl_m_rdefopt}}
614           message       = Different profile, please retry
615           log_message   = Only one default options profile at a time, please
616
617   # Set a flag to indicate whether the current recipient
618   # has explicitly requested greylisting
619   warn    set acl_m_grey_recip = 0
620
621   warn    local_parts          = GREYLIST_LOCAL_PARTS
622           domains              = +handled_domains
623           set acl_m_grey_recip = 1
624
625   # Defer after too many bad RCPT TO's.  Legit MTAs will retry later.
626   # This is a rough pass at preventing address harvesting or other mail blasts.
627
628   defer  log_message   = Too many bad recipients ${eval:$rcpt_fail_count} out of $rcpt_count
629          !acl          = acl_spamlovers
630          message       = Too many bad recipients, try again later
631          !hosts        = +debianhosts
632          condition     = ${if > {${eval:$rcpt_fail_count}}{3}}
633
634   # Dump spambots that are so stupid they say helo as our IP address
635
636   drop   !hosts        = +debianhosts
637          !acl          = acl_spamlovers
638          condition     = ${if eq {$sender_helo_name}{$interface_address}}
639          message       = HELO mismatch Forged HELO for ($sender_helo_name)
640
641   # Also for spambots that say helo as us or one of our domains
642
643   drop   !hosts        = +debianhosts
644          !acl          = acl_spamlovers
645          condition     = ${if match_domain{$sender_helo_name}{+ourself_and_handled}}
646          condition     = ${if !match{$sender_host_name}{${rxquote:$sender_helo_name}\N$\N}}
647          message       = HELO mismatch Forged HELO for ($sender_helo_name)
648
649   # This logic gives you a list of commonly forged domains in helo to reject against
650
651   warn set acl_m_frg   = ${lookup{$sender_helo_name} \
652                            nwildlsearch{/etc/exim4/helo-check} \
653                           {${if eq{$value}{}{$sender_helo_name}{$value}}}{}}
654
655   # This is a failsafe in case DNS fails - we defer instead of hard reject if they 
656   # say helo as a name in the list but we can't look them up
657
658   defer  !hosts        = +debianhosts
659          !acl          = acl_spamlovers
660          condition     = ${if !eq{$acl_m_frg}{}}
661          condition     = ${if eq{$sender_host_name}{}}
662          condition     = ${if !eq{$host_lookup_failed}{1}}
663          message       = Access temporarily denied. Resolve failed PTR for $sender_host_address
664
665   # If DNS works, go ahead and reject them
666
667   drop   !hosts        = +debianhosts
668          !acl          = acl_spamlovers
669          condition     = ${if and { {!eq{$acl_m_frg}{}}{!match{$sender_host_name}{${rxquote:$acl_m_frg}\N$\N}}}}
670          message       = HELO mismatch Forged HELO for ($sender_helo_name)
671
672   # disabled accounts don't even get local mail.
673   deny   domains       = +virtual_domains
674          condition    = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/mail-disable}}}\
675                                      {${lookup{${extract{1}{-}{$local_part}}}lsearch{${extract{directory}{VDOMAINDATA}{${value}/mail-disable}}}{true}{false}}}\
676                                      {}}
677          message       = ${lookup{${extract{1}{-}{$local_part}}}lsearch{${extract{directory}{VDOMAINDATA}{${value}/mail-disable}}}{$value}}
678
679   deny   local_parts   = lsearch;/var/lib/misc/$primary_hostname/mail-disable
680          domains       = +local_domains
681          message       = ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-disable}{$value}}
682
683   deny   domains       = +virtual_domains
684          local_parts   = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/localonly}}}\
685                                      {${extract{directory}{VDOMAINDATA}{${value}/localonly}}}\
686                                      {}}
687          hosts         = !+debianhosts
688          message       = mail for <$local_part@$domain> only accepted from debian.org machines
689
690   # Accept if the source is local SMTP (i.e. not over TCP/IP).
691   # We do this by testing for an empty sending host field.
692   accept  hosts = :
693   
694   deny    domains       = +handled_domains
695           local_parts   = ^[.] : ^.*[@%!/|]
696   
697   deny    domains       = !+handled_domains
698           local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
699
700   deny    condition     = ${lookup{$sender_address_local_part}lsearch{/etc/exim4/localusers}{true}}
701           sender_domains= +local_domains
702           hosts         = !+debianhosts
703           message       = mail from <$sender_address> not allowed externally
704
705   deny    sender_domains= +virtual_domains
706           condition     = ${if exists {${extract{directory}{VSENDERDOMAINDATA}{${value}/localusers}}}}
707           condition     = ${lookup{$sender_address_local_part}lsearch{${extract{directory}{VSENDERDOMAINDATA}{${value}/localusers}}}{true}}
708           hosts         = !+debianhosts
709           message       = mail from <$sender_address> not allowed externally
710
711   deny    sender_domains= +virtual_domains
712           condition     = ${if exists {${extract{directory}{VSENDERDOMAINDATA}{${value}/neversenders}}}}
713           condition     = ${lookup{$sender_address_local_part}lsearch{${extract{directory}{VSENDERDOMAINDATA}{${value}/neversenders}}}{true}}
714           message       = no mail should ever come from <$sender_address>
715
716   deny    domains       = +virtual_domains
717           senders       = :
718           condition     = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/neversenders}}}}
719           condition     = ${lookup{$local_part}lsearch{${extract{directory}{VDOMAINDATA}{${value}/neversenders}}}{true}}
720           message       = <$local_part@$domain> does not send mail; rejecting bogus NDR
721
722   warn    condition     = ${if eq{$acl_m_prf}{localonly}}
723           set acl_m_lrc = ${if eq{$acl_m_lrc}{}{$local_part@$domain}{$acl_m_lrc, $local_part@$domain}}
724
725 <%- if @is_packagesmaster -%>
726   warn    condition      = ${if eq {$acl_m_prf}{PackagesMail}}
727           condition      = ${if eq {$sender_address}{$local_part@$domain}}
728           add_header     = X-Packages-FromTo-Same: yes
729
730 <%- end -%>
731   deny    condition      = ${if !eq {$acl_m_prf}{PopconMail}}
732           !verify        = sender
733
734   warn    !hosts         = +debianhosts
735           condition      = ${if !eq {$acl_m_prf}{PopconMail}}
736           condition      = ${if >{${eval:$acl_c_scr+0}}{0}}
737           ratelimit      = 10 / 60m / per_rcpt / strict / $sender_host_address
738           log_message    = Sender rate $sender_rate / $sender_rate_period (limit: $sender_rate_limit)
739
740   defer   !hosts         = +debianhosts
741           condition      = ${if !eq {$acl_m_prf}{PopconMail}}
742           condition      = ${if >{${eval:$acl_c_scr+0}}{0}}
743           ratelimit      = 10 / 60m / per_rcpt / $sender_host_address
744           message        = slow down (no reverse dns, mismatched ehlo, dialup, or in blacklists)
745
746 <%- if has_variable?("policydweight") && @policydweight -%>
747   # Check with policyd-weight
748   warn  !hosts         = +debianhosts
749         condition      = ${if !eq {$acl_m_prf}{PopconMail}}
750         set acl_m_pw   = ${readsocket{inet:127.0.0.1:12525}\
751                           {request=smtpd_access_policy\n\
752                            protocol_state=RCPT\n\
753                            protocol_name=${uc:$received_protocol}\n\
754                            helo_name=$sender_helo_name\n\
755                            queue_id=$message_exim_id\n\
756                            sender=$sender_address\n\
757                            recipient=$local_part@$domain\n\
758                            recipient_count=$rcpt_count\n\
759                            client_address=$sender_host_address\n\
760                            client_name=$sender_host_name\n\
761                            reverse_client_name=$sender_host_name\n\
762                            instance=$sender_host_address.$sender_address.$sender_helo_name\n\n}\
763                           {20s}{\n}{socket failure}}
764
765   # Defer on socket error
766   defer !hosts         = +debianhosts
767         condition      = ${if !eq {$acl_m_prf}{PopconMail}}
768         condition      = ${if eq{$acl_m_pw}{socket failure}}
769         message        = Cannot connect to policyd-weight. Please try again later.
770
771   # Set proposed action to $acl_m_act and message to $acl_m_mes
772   warn  !hosts         = +debianhosts
773         condition      = ${if !eq {$acl_m_prf}{PopconMail}}
774         set acl_m_mes  = ${extract{action}{$acl_m_pw}}
775         set acl_m_act  = ${sg{$acl_m_pw}{\Naction=[^ ]+ (.*)\n\n\N}{\$1}}
776
777   # Add X-policyd-weight header line to message
778   warn  !hosts         = +debianhosts
779         condition      = ${if !eq {$acl_m_prf}{PopconMail}}
780         message        = $acl_m_mes
781         condition      = ${if eq{$acl_m_act}{PREPEND}}
782
783   # Write log message, if policyd-weight can't run checks
784   warn  !hosts         = +debianhosts
785         condition      = ${if !eq {$acl_m_prf}{PopconMail}}
786         log_message    = policyd-weight message: $acl_m_mes
787         condition      = ${if eq{$acl_m_act}{DUNNO}}
788
789   # Deny mails which policyd-weight thinks are spam
790   deny  !hosts         = +debianhosts
791         condition      = ${if !eq {$acl_m_prf}{PopconMail}}
792         message        = policyd-weight said: $acl_m_mes
793         condition      = ${if eq{$acl_m_act}{550}}
794
795   # Defer messages when policyd-weight suggests so.
796   defer  !hosts         = +debianhosts
797          condition      = ${if !eq {$acl_m_prf}{PopconMail}}
798          message        = policyd-weight said: $acl_m_mes
799          condition      = ${if eq{$acl_m_act}{450}}
800
801 <%- end -%>
802 <%- if @is_rtmaster -%>
803   warn    condition     = ${if eq{$acl_m_prf}{RTMail}}
804            set acl_m12  = ${if def:acl_m12 {$acl_m12} {${if or{{match{$local_part}{\N[^+]+\+\d+\N}}{match{$local_part}{\N[^+]+\+new\N}}} {RTMailRecipientHasSubaddress}}}}
805
806 <%- end -%>
807 <%- if has_variable?("greylistd") && @greylistd -%>
808   defer
809     message  = $sender_host_address is not yet authorized to deliver mail from <$sender_address> to <$local_part@$domain>.
810     log_message = greylisted.
811     condition      = ${if or { \
812                                  {eq{$acl_m_grey_recip}{1}} \
813                                  {bool_lax{$acl_m_defopt}} \
814                              } \
815                       }
816     !senders       = :
817     !hosts         = : +debianhosts : WHITELIST : \
818                      ${if exists {/etc/greylistd/whitelist-hosts}\
819                                  {/etc/greylistd/whitelist-hosts}{}} : \
820                      ${if exists {/var/lib/greylistd/whitelist-hosts}\
821                                  {/var/lib/greylistd/whitelist-hosts}{}} 
822     !dnslists      = list.dnswl.org&0.0.0.3
823     condition      = ${if !eq {$acl_m_prf}{PopconMail}}
824     !authenticated = *
825     domains        = +handled_domains
826     condition      = ${readsocket{/var/run/greylistd/socket}\
827                                  {--grey \
828                                   $sender_host_address \
829                                   $sender_address \
830                                   $local_part@$domain}\
831                                  {5s}{}{false}}
832
833 <%- elsif has_variable?("postgrey") && @postgrey -%>
834   # next three are greylisting, inspired by http://www.bebt.de/blog/debian/archives/2006/07/30/T06_12_27/index.html
835   # this adds acl_m_grey if there isn't one (so unique per message)
836   warn
837     !senders       = :
838     !hosts         = : +debianhosts : WHITELIST
839     !dnslists      = list.dnswl.org&0.0.0.3
840     condition      = ${if !eq {$acl_m_prf}{PopconMail}}
841     condition      = ${if ! def:acl_m_grey}
842     set acl_m_grey = $pid.$tod_epoch.$sender_host_port
843
844   # and defers the message if postgrey thinks it should be defered ...
845   defer
846     !senders       = :
847     !hosts         = : +debianhosts : WHITELIST
848     !dnslists      = list.dnswl.org&0.0.0.3
849     condition      = ${if !eq {$acl_m_prf}{PopconMail}}
850     !authenticated = *
851     domains        = +handled_domains
852     condition      = ${if or { \
853                                  {eq{$acl_m_grey_recip}{1}} \
854                                  {bool_lax{$acl_m_defopt}} \
855                              } \
856                       }
857     set acl_m_pgr  = request=smtpd_access_policy\n\
858                      protocol_state=RCPT\n\
859                      protocol_name=${uc:$received_protocol}\n\
860                      instance=${acl_m_grey}\n\
861                      helo_name=${sender_helo_name}\n\
862                      client_address=${sender_host_address}\n\
863                      client_name=${sender_host_name}\n\
864                      sender=${sender_address}\n\
865                      recipient=$local_part@$domain\n\n
866     set acl_m_pgr  = ${sg{\
867                          ${readsocket{/var/run/postgrey/socket}{$acl_m_pgr}\
868                                {5s}{}{action=DUNNO}}\
869                      }{action=}{}}
870     message        = ${sg{$acl_m_pgr}{\N^\w+\s*\N}{}}
871     log_message    = greylisted.
872     condition      = ${if eq{${uc:${substr{0}{5}{$acl_m_pgr}}}}{DEFER}}
873
874  # ... or adds a header with information about how long the delay was
875  warn
876     !senders       = :
877     !hosts         = : +debianhosts : WHITELIST
878     !dnslists      = list.dnswl.org&0.0.0.3
879     condition      = ${if !eq {$acl_m_prf}{PopconMail}}
880     !authenticated = *
881     domains        = +handled_domains
882     condition      = ${if or { \
883                                  {eq{$acl_m_grey_recip}{1}} \
884                                  {bool_lax{$acl_m_defopt}} \
885                              } \
886                       }
887     condition      = ${if eq{${uc:${substr_0_7:$acl_m_pgr}}}{PREPEND}}
888     message        = ${sg{$acl_m_pgr}{\N^\w+\s*\N}{}}
889
890 <%- end -%>
891   deny    hosts        = ${if exists{/etc/exim4/host_blacklist}{/etc/exim4/host_blacklist}{}}
892           message      = I'm terribly sorry, but it seems you have been blacklisted
893           log_message  = blacklisted IP
894
895   deny   log_message   = <$sender_address> is blacklisted
896          senders       = ${if exists{/etc/exim4/blacklist}{/etc/exim4/blacklist}{}}
897          message       = We have blacklisted <$sender_address>.  Please stop mailing us
898
899   accept  local_parts   = +postmasterish
900           domains       = +virtual_domains : +bsmtp_domains
901
902 <%- unless @use_smarthost -%>
903   deny    message  = host $sender_host_address is listed in $dnslist_domain ($dnslist_value)${if >{${strlen:${dnslist_text}}}{0}{; see $dnslist_text}}
904           domains  = +handled_domains
905           !hosts   = +debianhosts : WHITELIST
906           dnslists = ${if match_domain{$domain}{+virtual_domains}\
907                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}\
908                      {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}{$value}{}}}{}}}\
909                      {${lookup{$local_part}lsearch{/etc/exim4/rbllist}{$value}{}}}} : \
910                      ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rbl}{$value}{}}
911
912   deny    message  = host $sender_host_address is listed in $dnslist_domain ($dnslist_value)${if >{${strlen:${dnslist_text}}}{0}{; see $dnslist_text}}
913           domains  = +handled_domains
914           !hosts   = +debianhosts : WHITELIST
915           dnslists = noserver.dnsbl.sorbs.net
916
917   deny    message   = host $sender_host_address is listed in $dnslist_domain ($dnslist_value)${if >{${strlen:${dnslist_text}}}{0}{; see $dnslist_text}}
918           condition = ${if bool_lax{$acl_m_defopt}}
919           domains   = +handled_domains
920           !hosts    = +debianhosts : WHITELIST
921           dnslists  = relays.dnsbl.sorbs.net : xbl.spamhaus.org
922
923 <%- end -%>
924   deny    message  = domain $sender_address_domain is listed in $dnslist_domain ($dnslist_value)${if >{${strlen:${dnslist_text}}}{0}{; see $dnslist_text}}
925           domains  = +handled_domains
926           !hosts   = +debianhosts : WHITELIST
927           dnslists = ${if match_domain{$domain}{+virtual_domains}\
928                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}\
929                      {${expand:${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}{$value}{}}}}{}}}\
930                      {${expand:${lookup{$local_part}lsearch{/etc/exim4/rhsbllist}{$value}{}}}}} : \
931                      ${expand:${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rhsbl}{$value}{}}}
932
933   deny    message  = domain $sender_address_domain is listed in $dnslist_domain ($dnslist_value)${if >{${strlen:${dnslist_text}}}{0}{; see $dnslist_text}}
934           domains  = +handled_domains
935           !hosts   = +debianhosts : WHITELIST
936           dnslists = nomail.rhsbl.sorbs.net/$sender_address_domain
937
938   deny    message   = domain $sender_address_domain is listed in $dnslist_domain ($dnslist_value)${if >{${strlen:${dnslist_text}}}{0}{; see $dnslist_text}}
939           condition = ${if bool_lax{$acl_m_defopt}}
940           domains   = +handled_domains
941           !hosts    = +debianhosts : WHITELIST
942           dnslists  = dbl.spamhaus.org/$sender_address_domain
943
944 <%- unless @use_smarthost -%>
945   deny    domains  = +handled_domains
946           local_parts = ${if match_domain{$domain}{+virtual_domains}\
947                         {${if exists {${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}\
948                         {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}{$local_part}{}}}{}}}\
949                         {${lookup{$local_part}lsearch{/etc/exim4/callout_users}{$local_part}{}}}} : \
950                         ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-callout}{$local_part}{}}
951           !hosts   = +debianhosts : WHITELIST
952           !verify  = sender/callout=90s,maxwait=300s
953           message  = "Sender verification failed: $acl_verify_message"
954
955 <%- end -%>
956 <%- if @is_mailrelay -%>
957   accept  domains  = +mailhubdomains
958           endpass
959           verify   = recipient/callout=30s,defer_ok,use_sender,no_cache
960
961 <%- end -%>
962   accept  domains  = +handled_domains
963           endpass
964           verify   = recipient/defer_ok
965
966   accept  hosts         = +debianhosts
967
968   accept  authenticated = *
969
970   deny    message = relay not permitted
971
972 <%- if @heavy -%>
973 acl_check_mime:
974
975  accept  verify        = certificate
976  accept  hosts         = +debianhosts
977
978  discard condition     = ${if <{$message_size}{MAX_SCAN_SIZE}}
979          condition     = ${if eq {$acl_m_prf}{blackhole}}
980          set acl_m_srb = ${perl{surblspamcheck}}
981          condition     = ${if !eq{$acl_m_srb}{false}}
982          log_message   = discarded surbl message for $recipients
983
984   deny   condition     = ${if <{$message_size}{MAX_SCAN_SIZE}}
985          condition     = ${if !eq {$acl_m_prf}{markup}}
986          condition     = ${if !eq {$acl_m_prf}{PopconMail}}
987          set acl_m_srb = ${perl{surblspamcheck}}
988          condition     = ${if !eq{$acl_m_srb}{false}}
989          log_message   = $acl_m_srb
990          message       = $acl_m_srb
991
992   warn   condition     = ${if <{$message_size}{MAX_SCAN_SIZE}}
993          condition     = ${if eq {$acl_m_prf}{markup}}
994          set acl_m_srb = ${perl{surblspamcheck}}
995          condition     = ${if !eq{$acl_m_srb}{false}}
996          add_header    = X-Surbl-Hit: $primary_hostname: $acl_m_srb
997
998   # Dump MIME parts to disk. "default" creates sequentially-named files
999   # in <spool_directory>/scan/<message_id>/ which should then be
1000   # automagically unlinked after processing.
1001   warn   decode        = default
1002
1003   # Log some information about attachments for debugging
1004   warn   log_message   = MIME part [$mime_part_count] -> [${extract{-1}{.}{${lc:$mime_filename}}}] [$mime_content_type]
1005
1006   accept
1007
1008 <%- end -%>
1009 acl_check_predata:
1010   deny   condition     = ${if eq{$acl_m_prf}{localonly}}
1011          message       = mail for $acl_m_lrc is only accepted internally
1012
1013   accept
1014
1015
1016 #!!# ACL that is used after the DATA command
1017 check_message:
1018
1019   # Some people put from postmaster@something.debian.org in the From
1020   # header.  Take their crack pipe away.
1021   drop   condition = ${if match{${lc:$h_From:}}{\Npostmaster@([^.]+\.)?debian\.org\N}}
1022
1023   # If the sending system says the mail is spam, believe them
1024   deny    condition = ${if eqi {$h_X-Spam-Status:}{YES}}
1025           message   = Incoming spam flags
1026
1027 <%- if @is_rtmaster -%>
1028   deny    condition = ${if eq {$acl_m_prf}{RTMail}}
1029           condition = ${if and{{!match {${lc:$rh_Subject:}} {debian rt}} \
1030                                {!match {${lc:$rh_Subject:]}} {\N\[rt.debian.org \N}} \
1031                                {!match {$acl_m12}{RTMailRecipientHasSubaddress}}}}
1032           message  = messages to the Request Tracker system require a subject tag or a subaddress
1033
1034 <%- end -%>
1035 <%- if @is_packagesqamaster -%>
1036   deny    !hosts  = +debianhosts
1037           condition = ${if eq {$acl_m_prf}{PTSMail}}
1038           condition = ${if !def:h_X-PTS-Approved:}
1039           message   = messages to the PTS require an X-PTS-Approved header
1040
1041 <%- end -%>
1042   deny    condition      = ${if eq {$acl_m_prf}{DBSignedMail}}
1043           condition      = ${if and {{!match {$message_body}{PGP MESSAGE}}              \
1044                                      {!match {$message_body}{PGP SIGNED MESSAGE}}       \
1045                                      {!match {$message_body}{PGP SIGNATURE}}            \
1046                                      {!match {$header_content-type:}{multipart/signed}} \
1047                                      {!match {$header_content-type:}{pgp}}              \
1048                                     }                                                   \
1049                             }
1050           message        = Mail to this address needs to be PGP-signed
1051
1052   accept  verify    = certificate
1053   accept  hosts     = +debianhosts
1054
1055   deny    condition = ${if !eq {$acl_m_prf}{PopconMail}}
1056           !verify   = header_syntax
1057           message   = Invalid header syntax: $acl_verify_message
1058
1059 # RFC 822 and 2822 say that headers must be ASCII.  This kinda emulates
1060 # postfix's strict_7bit_headers option, but only checks a few common problem
1061 # headers, as there doesn't appear to be an easy way to check them all.
1062   deny
1063           condition       = ${if or {{match {$rh_Subject:}{[\200-\377]}}\
1064                                  {match {$rh_To:}{[\200-\377]}}\
1065                                  {match {$rh_From:}{[\200-\377]}}\
1066                                  {match {$rh_Cc:}{[\200-\377]}}}}
1067           condition       = ${if !eq {$acl_m_prf}{PopconMail}}
1068           message         = improper use of 8-bit data in message header: message rejected
1069
1070   deny
1071           condition       = ${if match {$rh_Subject:}{[^[:print:]]\{8\}}}
1072           condition       = ${if !eq {$acl_m_prf}{PopconMail}}
1073           message         = Your mailer is not RFC 2047 compliant: message rejected
1074
1075   deny    condition       = ${if match {$rh_Received:}{\N from [^ ]+\.example\.com \N}}
1076           log_message     = Implausible Received header
1077           message         = Header problem: message rejected
1078
1079   warn    set acl_m_body = ${sg{$message_body}{= }{}}
1080
1081   warn    condition      = ${if bool_lax{$acl_m_defopt}}
1082           condition      = ${if or {\
1083                                     {match {$message_body}{Wenn Sie zuk&uuml;nftig keine weiteren Informationen erhalten m&ouml;chten, <br />unwissentlich oder unbeabsichtigt in den Verteiler aufgenommen wurden,}} \
1084                                     {match {$message_body}{\N(?i)Dear Beneficiary.*You have been selected.*Thousand United States Dollars\N}} \
1085                                     {match {$message_body}{\N(?i)receiving sum of money into your account for safe keeping\N}} \
1086                                     {match {$message_body}{\N(?i)I got your e-mail address through an internet marketing firm\N}} \
1087                                     {match {$message_body}{\N(?i)De conformidad con lo establecido en la Ley 34/2002 Lssice le comunicamos que este escrito procede de Search Task\N}} \
1088                                     {match {$message_body}{\NIf you are already our customer then please ignore this email\N}} \
1089                                     {match {$acl_m_body}{\N\.debian\.org Webmail Administrator\N}} \
1090                                     {match {$acl_m_body}{\N<META name=3D"GENERATOR" content=3D"-\[OUTLOOK_VER\]-">\N}} \
1091                                    }\
1092                             }
1093           set acl_m_content = 1
1094
1095   discard condition      = ${if eq {$acl_m_prf}{blackhole}}
1096           condition      = ${if eq {$acl_m_content}{1}}
1097           log_message    = Discarded suspicious content for $recipients
1098
1099   deny    condition      = ${if !eq {$acl_m_prf}{markup}}
1100           condition      = ${if eq {$acl_m_content}{1}}
1101           message        = Rejected due to suspicious content
1102
1103   warn    condition      = ${if eq {$acl_m_prf}{markup}}
1104           condition      = ${if eq {$acl_m_content}{1}}
1105           add_header     = X-debian-content-warning: yes
1106
1107 <%- if has_variable?("clamd") && @clamd -%>
1108   discard condition       = ${if eq {$acl_m_prf}{blackhole}}
1109           malware         = */defer_ok
1110           log_message     = discarded malware message for $recipients
1111
1112   deny    condition       = ${if !eq {$acl_m_prf}{markup}}
1113           condition       = ${if !eq {$acl_m_prf}{PopconMail}}
1114           malware         = */defer_ok
1115           message         = malware detected: $malware_name: message rejected
1116
1117   warn    condition       = ${if eq {$acl_m_prf}{markup}}
1118           malware         = */defer_ok
1119           message         = X-malware detected: $malware_name
1120
1121 <%- end -%>
1122 <%- if @heavy -%>
1123  discard condition     = ${if <{$message_size}{MAX_SCAN_SIZE}}
1124          condition     = ${if eq {$acl_m_prf}{blackhole}}
1125          set acl_m_srb = ${perl{surblspamcheck}}
1126          condition     = ${if !eq{$acl_m_srb}{false}}
1127          log_message   = discarded surbl message for $recipients
1128
1129   deny   condition     = ${if <{$message_size}{MAX_SCAN_SIZE}}
1130          condition     = ${if !eq {$acl_m_prf}{markup}}
1131          condition     = ${if !eq {$acl_m_prf}{PopconMail}}
1132          set acl_m_srb = ${perl{surblspamcheck}}
1133          condition     = ${if !eq{$acl_m_srb}{false}}
1134          log_message   = $acl_m_srb
1135          message       = $acl_m_srb
1136
1137   warn   condition     = ${if <{$message_size}{MAX_SCAN_SIZE}}
1138          condition     = ${if eq {$acl_m_prf}{markup}}
1139          set acl_m_srb = ${perl{surblspamcheck}}
1140          condition     = ${if !eq{$acl_m_srb}{false}}
1141          message       = X-Surbl-Hit: $primary_hostname: $acl_m_srb
1142
1143 <%- end -%>
1144   # Check header_sender except for survey@popcon.d.o
1145   deny    condition    = ${if !eq{$acl_m_prf}{PopconMail}}
1146           !verify      = header_sender
1147           message      = No valid sender found in the From:, Sender: and Reply-to: headers
1148
1149 <%- if @is_packagesmaster -%>
1150   deny  message        = Congratulations, you scored $spam_score points.
1151         log_message    = spam: $spam_score points.
1152         condition      = ${if eq {$acl_m_prf}{PackagesMail}}
1153         !authenticated = *
1154         !verify        = certificate
1155         !hosts         = +debianhosts
1156         condition      = ${if <{$message_size}{MAX_SCAN_SIZE}}
1157         spam           = pkg_user : true
1158         condition      = ${if >{$spam_score_int}{59}}
1159
1160 <%- end -%>
1161   accept
1162
1163
1164
1165 ######################################################################
1166 #                      REWRITE CONFIGURATION                         #
1167 ######################################################################
1168
1169
1170
1171 begin rewrite
1172
1173 \N^buildd_(.*)@fasolo\.debian\.org$\N buildd_$1@buildd.debian.org T
1174 *@debian.org ${lookup{$1}dbmnz{/var/lib/misc/${primary_hostname}/mail-forward.db}{$value}fail} T
1175 *@people.debian.org ${lookup{$1}dbmnz{/var/lib/misc/${primary_hostname}/mail-forward.db}{$value}fail} T
1176 #*@${primary_hostname} "${if exists{/etc/exim4/email-addresses}{${lookup{$1}lsearch{/etc/exim4/email-addresses}{$value}fail}}fail}" fFs
1177
1178
1179 #!!#######################################################!!#
1180 #!!# Here follow routers created from the old routers,   #!!#
1181 #!!# for handling non-local domains.                     #!!#
1182 #!!#######################################################!!#
1183
1184 begin routers
1185
1186
1187
1188 ######################################################################
1189 #                      ROUTERS CONFIGURATION                         #
1190 #                Specifies how addresses are handled                 #
1191 ######################################################################
1192 #                          ORDER DOES MATTER                         #
1193 #     An address is passed to each in turn until it is accepted.     #
1194 ######################################################################
1195
1196 <%- if @is_mailrelay -%>
1197 relay_manualroute:
1198   debug_print = "R: relay_manualroute for $local_part@$domain"
1199   driver = manualroute
1200   domains = +mailhubdomains
1201   transport = ${if forany{${lookup dnsdb{>: mxh=$domain}}}\
1202                   {match_domain{$item}{+single_domain_mx}}\
1203                   {remote_smtp_single_domain}{remote_smtp}\
1204                }
1205   route_data = ${lookup{$domain}lsearch{/etc/exim4/manualroute}}
1206   require_files = /etc/exim4/manualroute
1207
1208 <%- end -%>
1209 bsmtp:
1210   debug_print = "R: bsmtp for $local_part@$domain"
1211   driver = manualroute
1212   domains = +bsmtp_domains
1213   require_files = /etc/exim4/bsmtp
1214   route_list = * ${extract{file}{\
1215                    ${lookup{$domain}partial-lsearch{/etc/exim4/bsmtp}\
1216                      {$value}fail}}}
1217   transport = bsmtp
1218
1219 # This router routes to remote hosts over SMTP by explicit IP address,
1220 # given as a "domain literal" in the form [nnn.nnn.nnn.nnn]. The RFCs
1221 # require this facility, which is why it is enabled by default in Exim.
1222 ipliteral:
1223   debug_print = "R: ipliteral for $local_part@$domain"
1224   driver = ipliteral
1225   domains = !+handled_domains
1226   transport = remote_smtp
1227   ignore_target_hosts = +reservedaddrs
1228
1229 <%- if @use_smarthost -%>
1230 smarthost:
1231   debug_print = "R: smarthost for $local_part@$domain"
1232   driver = manualroute
1233   domains = !+handled_domains
1234   transport = remote_smtp_smarthost
1235   route_list = * <%= @smarthost %>
1236   host_find_failed = defer
1237   same_domain_copy_routing = yes
1238   no_more
1239 <%- end -%>
1240
1241 # This router routes to remote hosts over SMTP using a DNS lookup.
1242 # Ignore reserved network responses, including localhost.
1243 dnslookup:
1244   debug_print = "R: dnslookup for $local_part@$domain"
1245   driver = dnslookup
1246   domains = !+handled_domains
1247   transport = ${if forany{${lookup dnsdb{>: mxh=$domain}}}\
1248                   {match_domain{$item}{+single_domain_mx}}\
1249                   {remote_smtp_single_domain}{remote_smtp}\
1250                }
1251   ignore_target_hosts = +reservedaddrs : \
1252                ${if forany{${lookup dnsdb{>: mxh=$domain}}}\
1253                   {match_domain{$item}{+ipv4_only_domain_mx}}\
1254                   {::::/0}{}\
1255                }
1256   no_more
1257
1258 postmasterish:
1259   debug_print = "R: postmasterish for $local_part@$domain"
1260   driver = redirect
1261   verify = false
1262   unseen = true
1263   expn = true
1264   local_parts = +postmasterish
1265   domains = +virtual_domains : +bsmtp_domains
1266   data = debian-admin@debian.org
1267   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1268
1269 # This router handles aliasing using a traditional /etc/aliases file.
1270 # If any of your aliases expand to pipes or files, you will need to set
1271 # up a user and a group for these deliveries to run under. You can do
1272 # this by uncommenting the "user" option below (changing the user name
1273 # as appropriate) and adding a "group" option if necessary.
1274
1275 system_aliases:
1276   debug_print = "R: system_aliases for $local_part@$domain"
1277   driver = redirect
1278   allow_defer
1279   allow_fail
1280   data = ${lookup{$local_part}lsearch*{/etc/aliases}}
1281   domains = +local_domains
1282   file_transport = address_file
1283   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1284   pipe_transport = address_pipe
1285   retry_use_local_part
1286
1287 # This router handles forwarding using traditional .forward files.
1288 # It also allows mail filtering when a forward file starts with the 
1289 # string "# Exim filter": to disable filtering, uncomment the "filter" 
1290 # option. The check_ancestor option means that if the forward file 
1291 # generates an address that is an ancestor of the current one, the 
1292 # current one gets passed on instead. This covers the case where A is 
1293 # aliased to B and B has a .forward file pointing to A.
1294
1295 # For standard Debian setup of one group per user, it is acceptable---normal
1296 # even---for .forward to be group writable. If you have everyone in one
1297 # group, you should comment out the "modemask" line. Without it, the Exim
1298 # default of 022 will apply, which is probably what you want.
1299
1300 userforward_verify:
1301   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
1302   driver = redirect
1303   check_ancestor
1304   user = Debian-exim
1305   no_check_local_user
1306   directory_transport = address_directory
1307   domains = +local_domains
1308   # filter - I have disabled filtering to force users to use .forward-foo files
1309   # or procmail. This will make it easier to move mailers in the future
1310   #
1311   # This bit does the qmailesque extension names, foo-bar@ is .forward-foo it
1312   # also checks if the .forward-bar exists, if not then it uses
1313   # .forward-default instead.
1314   file = $home/.forward\
1315          ${if eq{}{$local_part_suffix}{}{\
1316            ${if exists {${home}/.forward${local_part_suffix}} \
1317              {${local_part_suffix}}{-default}}\
1318            }\
1319           }
1320   file_transport = address_file
1321   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1322   local_part_suffix = -*
1323   local_part_suffix_optional
1324   modemask = 002
1325   pipe_transport = address_pipe
1326   reply_transport = address_reply
1327   require_files = $home
1328   router_home_directory = ${lookup passwd{$local_part}{${extract{5}{:}{$value}}}fail}
1329   verify_only
1330
1331 # This is a sendmailesque alias file lookup
1332 virt_aliases:
1333   debug_print = "R: virt_aliases for $local_part@$domain"
1334   driver = redirect
1335   allow_defer
1336   allow_fail
1337   data = ${if exists{\
1338            ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
1339            {${lookup{$local_part}lsearch*{\
1340               ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
1341            }}}}
1342   directory_transport = address_directory
1343   domains = +virtual_domains
1344   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1345   cannot_route_message = Unknown user
1346   group = ${extract{group}{VDOMAINDATA}}
1347   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1348   pipe_transport = address_pipe
1349   qualify_preserve_domain
1350   retry_use_local_part
1351   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1352   transport_home_directory = ${extract{directory}{VDOMAINDATA}}
1353   user = ${extract{user}{VDOMAINDATA}}
1354   
1355 # No direct match, so try doing a regex match if there's an
1356 # aliases.regex
1357 virt_aliases_regex:
1358   debug_print = "R: virt_aliases_regex for $local_part$local_part_suffix@$domain"
1359   driver = redirect
1360   allow_defer
1361   allow_fail
1362   data = ${if exists{\
1363            ${extract{directory}{VDOMAINDATA}{${value}/aliases.regex}}}\
1364            {${lookup{$local_part}nwildlsearch*{\
1365               ${extract{directory}{VDOMAINDATA}{$value/aliases.regex}}\
1366            }}}}
1367   directory_transport = address_directory
1368   domains = +virtual_domains
1369   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1370   cannot_route_message = Unknown user
1371   group = ${extract{group}{VDOMAINDATA}}
1372   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1373   pipe_transport = address_pipe
1374   qualify_preserve_domain
1375   retry_use_local_part
1376   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1377   transport_home_directory = ${extract{directory}{VDOMAINDATA}}
1378   user = ${extract{user}{VDOMAINDATA}}
1379
1380 userforward:
1381   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
1382   driver = redirect
1383   check_ancestor
1384   check_local_user
1385   directory_transport = address_directory
1386   domains = +local_domains
1387   # filter - I have disabled filtering to force users to use .forward-foo files
1388   # or procmail. This will make it easier to move mailers in the future
1389   #
1390   # This bit does the qmailesque extension names, foo-bar@ is .forward-foo it
1391   # also checks if the .forward-bar exists, if not then it uses
1392   # .forward-default instead.
1393   file = $home/.forward\
1394          ${if eq{}{$local_part_suffix}{}{\
1395            ${if exists {${home}/.forward${local_part_suffix}} \
1396              {${local_part_suffix}}{-default}}\
1397            }\
1398           }
1399   file_transport = address_file
1400   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1401   local_part_suffix = -*
1402   local_part_suffix_optional
1403   modemask = 002
1404   pipe_transport = address_pipe
1405   reply_transport = address_reply
1406   require_files = $home
1407   no_verify
1408
1409 # This delivers to procmail
1410 procmail:
1411   debug_print = "R: procmail for $local_part@$domain"
1412   driver = accept
1413   check_local_user
1414   domains = +local_domains
1415   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1416   local_part_suffix = -*
1417   local_part_suffix_optional
1418   no_verify
1419   no_expn
1420   require_files = $local_part:$home/.procmailrc
1421   transport = procmail_pipe
1422   transport_current_directory = $home
1423   
1424 # This driver delivers to the LDAP generated alias file.
1425 ldap_aliases:
1426   debug_print = "R: ldap_aliases for $local_part@$domain"
1427   driver = redirect
1428   allow_defer
1429   allow_fail
1430   data = ${if exists{/var/lib/misc/$primary_hostname/user-forward.db}\
1431              {${lookup{$local_part}dbmnz\
1432                {/var/lib/misc/$primary_hostname/user-forward.db}}}}
1433   domains = +local_domains
1434   file_transport = address_file
1435   local_part_suffix = -*
1436   local_part_suffix_optional
1437   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1438   pipe_transport = address_pipe
1439   retry_use_local_part
1440   
1441 # This director matches local user mailboxes.
1442 localuser:
1443   debug_print = "R: localuser for $local_part@$domain"
1444   driver = accept
1445   check_local_user
1446   domains = +local_domains
1447   local_part_suffix = -*
1448   local_part_suffix_optional
1449   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1450   # Disable if the user has never logged in
1451   require_files = $home
1452   transport = local_delivery
1453   no_more
1454
1455 # Now we begin the Virtual Domain configuration
1456 # Everything before here should apply only to the local domains with a 
1457 # domains= rule
1458
1459 <%- if @is_packagesmaster -%>
1460 # This router delivers for packages.d.o
1461 packages:
1462   debug_print = "R: packages for $local_part@$domain"
1463   driver = redirect
1464   file_transport = address_file
1465   pipe_transport = address_pipe
1466   domains = packages.debian.org
1467   require_files = /srv/packages.debian.org/conf/maintainer
1468   data = ${lookup{$local_part}cdb{/srv/packages.debian.org/conf/maintainer.cdb}}
1469   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1470   transport_home_directory = /srv/packages.debian.org/mail
1471   transport_current_directory = /srv/packages.debian.org/mail
1472   check_ancestor
1473   retry_use_local_part
1474   no_more
1475
1476 <%- end -%>
1477 <%- if @is_rtmaster -%>
1478 # This router delivers for rt.d.o
1479 rt_force_new_verbose:
1480   debug_print = "R: rt for $local_part+new@$domain"
1481   driver = redirect
1482   domains = rt.debian.org
1483   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1484   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1485   local_part_suffix = +new
1486   pipe_transport = rt_pipe
1487   data = "|/usr/bin/rt-mailgate --queue '${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}}' --url https://rt.debian.org/ --ca-file /etc/ssl/ca-debian/ca-certificates.crt --action ${if match{$local_part}{.*-comment.*}{comment}{correspond}}"
1488   headers_remove = Subject
1489   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nRT_SUBJECT"
1490
1491 # FIXME: figure out how to generalize this approach so that all of the following would work
1492 # - rt+NNNN@rt.debian.org          : attach correspondence to ticket (verbose)
1493 # - rt+NNNN-quiesce@rt.debian.org  : attach correspondence to ticket (quiesce)
1494 # - rt+NNNN-<action>@rt.debian.org : attach correspondence to ticket (some action)
1495 # requires modification to custom condition in 'scrips'
1496 rt_force_new_quiesce:
1497   debug_print = "R: rt for $local_part+new-quiesce@$domain"
1498   driver = redirect
1499   domains = rt.debian.org
1500   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1501   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1502   local_part_suffix = +new-quiesce
1503   pipe_transport = rt_pipe
1504   data = "|/usr/bin/rt-mailgate --queue '${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}}' --url https://rt.debian.org/ --ca-file /etc/ssl/ca-debian/ca-certificates.crt --action ${if match{$local_part}{.*-comment.*}{comment}{correspond}}"
1505   headers_remove = Subject
1506   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nX-RT-Mode: quiesce\nRT_SUBJECT"
1507
1508 rt_otherwise:
1509   debug_print = "R: rt for $local_part@$domain"
1510   driver = redirect
1511   domains = rt.debian.org
1512   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1513   local_parts = ${lookup{${sg{$local_part}{-(comment|done)}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1514   local_part_suffix = +*
1515   local_part_suffix_optional
1516   pipe_transport = rt_pipe
1517   data = "|/usr/bin/rt-mailgate --queue '${lookup{${sg{$local_part}{-(comment|done)}{}}}lsearch{RT_QUEUE_MAP}}' --url https://rt.debian.org/ --ca-file /etc/ssl/ca-debian/ca-certificates.crt --extension ticket --action ${if match{$local_part}{.*-comment.*}{comment}{${if match{$local_part}{.*-done.*}{correspond-resolve}{correspond}}}}"
1518   headers_remove = Subject
1519   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nRT_SUBJECT"
1520 <%- end -%>
1521
1522 # Exim fails the router if it can't change to the user/group for delivery
1523 # during verification.  So we have to separate the cases of verifying
1524 # the virts, and delivering to them.  blah.
1525
1526 virt_direct_verify:
1527   debug_print = "R: virt_direct for $local_part@$domain"
1528   driver = redirect
1529   no_check_local_user
1530   user = Debian-exim
1531   allow_filter
1532   modemask = 002
1533   directory_transport = address_directory
1534   domains = +virtual_domains
1535 <%- if @is_trackermaster -%>
1536   local_part_suffix = +*
1537 <%- else -%>
1538   local_part_suffix = -*
1539 <%- end -%>
1540   local_part_suffix_optional
1541   file = $home/.forward-\
1542               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
1543                    {default}}
1544   file_transport = address_file
1545   pipe_transport = address_pipe
1546   reply_transport = address_reply
1547   retry_use_local_part
1548   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1549   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1550   verify_only
1551
1552 # This is a qmailesque deliver into a directory of .forward files
1553 virt_direct:
1554   debug_print = "R: virt_direct for $local_part@$domain"
1555   driver = redirect
1556   allow_filter
1557   allow_fail
1558   allow_defer
1559   no_check_local_user
1560   directory_transport = address_directory
1561   domains = +virtual_domains
1562   file = $home/.forward-\
1563               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
1564                    {default}}
1565   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1566   group = ${extract{group}{VDOMAINDATA}}
1567   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1568   modemask = 002
1569 <%- if @is_trackermaster -%>
1570   local_part_suffix = +*
1571 <%- else -%>
1572   local_part_suffix = -*
1573 <%- end -%>
1574   local_part_suffix_optional
1575   pipe_transport = address_pipe
1576   reply_transport = address_reply
1577   retry_use_local_part
1578   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1579   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1580   no_verify
1581   user = ${extract{user}{VDOMAINDATA}}
1582   #debug_print = .forward-${if exists {${home}/.forward-${local_part}} {${local_part}} {default}}
1583
1584 # This router delivers to the LDAP generated mail-forward file.
1585 # It's only really useful for debian.org
1586 virt_users:
1587   debug_print = "R: virt_users for $local_part@$domain"
1588   driver = redirect
1589   allow_defer
1590   allow_fail
1591   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1592   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1593   user = ${extract{user}{VDOMAINDATA}}
1594   group = ${extract{group}{VDOMAINDATA}}
1595   # Manually construct the forwarding address, preserving the
1596   # local_part_suffix if the remote host is master.
1597   data = ${if and {{exists{${extract{directory}{VDOMAINDATA}{${value}/mail-forward.db}}}}\
1598                      {! eq {${lookup{$local_part}dbmnz\
1599                             {${extract{directory}{VDOMAINDATA}{${value}/mail-forward.db}}}}}\
1600                            {}}}\
1601              {${local_part:${lookup{$local_part}dbmnz\
1602              {${extract{directory}{VDOMAINDATA}{${value}/mail-forward.db}}}}}\
1603              ${if eq {${domain:${lookup{$local_part}dbmnz\
1604              {${extract{directory}{VDOMAINDATA}{${value}/mail-forward.db}}}}}}{master.debian.org}{$local_part_suffix} {}}\
1605              @\
1606              ${domain:${lookup{$local_part}dbmnz\
1607             {${extract{directory}{VDOMAINDATA}{${value}/mail-forward.db}}}}}}}
1608   domains = +virtual_domains
1609   file_transport = address_file
1610   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1611   pipe_transport = address_pipe
1612   local_part_suffix = -*
1613   local_part_suffix_optional
1614   retry_use_local_part
1615
1616 <%- if @is_bugsmx -%>
1617 # This router delivers for bugs.d.o
1618 bugs:
1619   debug_print = "R: bugs for $local_part@$domain"
1620   driver = accept
1621   transport = bugs_pipe
1622   domains = bugs.debian.org
1623   cannot_route_message = Unknown or archived bug
1624   require_files = /srv/bugs.debian.org/mail/run-procmail
1625   no_more
1626   local_parts = ${if match\
1627                   {$local_part}\
1628                   {\N^(\d+)(\d{2})(?:-(?:(?:submit|maintonly|quiet|forwarded|done|close|request|submitter)|(?:unsubscribe|ignore|help|(?:sub(?:scribe|help|yes|approve|reject))|unsubyes|bounce|probe|approve|reject|setlistyes|setlistsilentyes).*))?$\N}\
1629                {${if exists{/srv/bugs.debian.org/spool/db-h/$2/$1$2.summary}\
1630                {$local_part}fail}}fail}
1631 <%- end -%>
1632 ######################################################################
1633 #                      TRANSPORTS CONFIGURATION                      #
1634 ######################################################################
1635 #                       ORDER DOES NOT MATTER                        #
1636 #     Only one appropriate transport is called for each delivery.    #
1637 ######################################################################
1638
1639
1640 begin transports
1641
1642 # This transport is used for local delivery to user mailboxes. On Debian
1643 # systems group mail is used so we can write to the /var/mail
1644 # directory. (The alternative, which most other unixes use, is to deliver
1645 # as the user's own group, into a sticky-bitted directory)
1646 local_delivery:
1647   debug_print = "T: local_delivery for $local_part@$domain"
1648   driver = appendfile
1649   file = /var/mail/${local_part}
1650   group = mail
1651   mode = 0660
1652   no_mode_fail_narrower
1653   return_path_add
1654   
1655 # This transport is used for handling pipe addresses generated by alias
1656 # or .forward files. It has a conventional name, since it is not actually
1657 # mentioned elsewhere in this configuration file. (A different name *can*
1658 # be specified via the "address_pipe_transport" option if you really want
1659 # to.) If the pipe generates any standard output, it is returned to the sender
1660 # of the message as a delivery error. Set return_fail_output instead if you
1661 # want this to happen only when the pipe fails to complete normally.
1662
1663 address_pipe:
1664   debug_print = "T: address_pipe for $local_part@$domain"
1665   driver = pipe
1666   current_directory = ${home}
1667   environment = "EXTENSION=${substr_1:${local_part_suffix}}:\
1668                  EXT=${substr_1:${local_part_suffix}}:\
1669                  LOCAL=${local_part}${local_part_suffix}:\
1670                  RECIPIENT=${local_part}${local_part_suffix}@${domain}"
1671   return_output
1672   return_path_add
1673
1674 # This transport is used for handling file addresses generated by alias
1675 # or .forward files. It has a conventional name, since it is not actually
1676 # mentioned elsewhere in this configuration file.
1677
1678 address_file:
1679   debug_print = "T: address_file for $local_part@$domain"
1680   driver = appendfile
1681   return_path_add
1682
1683 address_file_group:
1684   debug_print = "T: address_file_group for $local_part@$domain"
1685   driver = appendfile
1686   return_path_add
1687   mode = 0660
1688   directory_mode = 0770
1689   mode_fail_narrower = false
1690
1691 # This transport is used for handling file addresses generated by alias
1692 # or .forward files if the path ends in "/", which causes it to be treated
1693 # as a directory name rather than a file name. Each message is then delivered
1694 # to a unique file in the directory. If instead you want all such deliveries to
1695 # be in the "maildir" format that is used by some other mail software,
1696 # uncomment the final option below. If this is done, the directory specified
1697 # in the .forward or alias file is the base maildir directory.
1698 #
1699 # Should you want to be able to specify either maildir or non-maildir
1700 # directory-style deliveries, then you must set up yet another transport,
1701 # called address_directory2. This is used if the path ends in "//" so should
1702 # be the one used for maildir, as the double slash suggests another level
1703 # of directory. In the absence of address_directory2, paths ending in //
1704 # are passed to address_directory.
1705
1706 address_directory:
1707   debug_print = "T: address_directory for $local_part@$domain"
1708   driver = appendfile
1709   check_string = 
1710   maildir_format
1711   message_prefix = ""
1712   message_suffix = ""
1713   return_path_add
1714
1715 # This transport is used for handling autoreplies generated by the filtering
1716 # option of the forwardfile director. It has a conventional name, since it
1717 # is not actually mentioned elsewhere in this configuration file.
1718 address_reply:
1719   debug_print = "T: address_reply for $local_part@$domain"
1720   driver = autoreply
1721
1722 # This transport is used for delivering messages over SMTP connections.
1723
1724 remote_smtp:
1725   debug_print = "T: remote_smtp for $local_part@$domain"
1726   driver = smtp
1727   connect_timeout = 15s
1728   delay_after_cutoff = false
1729   tls_certificate = /etc/exim4/ssl/thishost.crt
1730   tls_privatekey = /etc/exim4/ssl/thishost.key
1731
1732 remote_smtp_single_domain:
1733   debug_print = "T: remote_smtp_single_domain for $local_part@$domain"
1734   driver = smtp
1735   connect_timeout = 15s
1736   delay_after_cutoff = false
1737   no_multi_domain
1738   tls_certificate = /etc/exim4/ssl/thishost.crt
1739   tls_privatekey = /etc/exim4/ssl/thishost.key
1740
1741 <%- if @use_smarthost -%>
1742 remote_smtp_smarthost:
1743   debug_print = "T: remote_smtp_smarthost for $local_part@$domain"
1744   driver = smtp
1745   delay_after_cutoff = false
1746   port = <%= @smarthost_port %>
1747   tls_tempfail_tryclear = false
1748   hosts_require_tls = <%= @smarthost %>
1749   tls_certificate = /etc/exim4/ssl/thishost.crt
1750   tls_privatekey = /etc/exim4/ssl/thishost.key
1751 <%- end -%>
1752 # Send the message to procmail
1753 procmail_pipe:
1754   debug_print = "T: procmail_pipe for $local_part@$domain"
1755   driver = pipe
1756   command = /usr/bin/procmail -a ${substr_1:${local_part_suffix}}
1757   return_path_add
1758   user = ${local_part}
1759
1760 bsmtp:
1761   debug_print = "T: bsmtp for $local_part@$domain"
1762   driver = appendfile
1763   batch_max = 100
1764   file = ${host}
1765   message_prefix = 
1766   message_suffix = 
1767   use_bsmtp
1768   user = ${extract{user}{\
1769                    ${lookup{$domain}partial-lsearch{/etc/exim4/bsmtp}\
1770                      {$value}fail}\
1771                    }}
1772
1773 <%- if @is_bugsmx -%>
1774 bugs_pipe:
1775   debug_print = "T: bugs_pipe for $local_part@$domain"
1776   driver = pipe
1777   command = /srv/bugs.debian.org/mail/run-procmail
1778   environment = "EXTENSION=${substr_1:${local_part_suffix}}:\
1779                  EXT=${substr_1:${local_part_suffix}}:\
1780                  LOCAL=${local_part}${local_part_suffix}:\
1781                  RECIPIENT=${local_part}${local_part_suffix}@${domain}"
1782   return_path_add
1783   return_output
1784   user = debbugs
1785
1786 <%- end -%>
1787 <%- if @is_rtmaster -%>
1788 rt_pipe:
1789   debug_print = "T: rt_pipe for $local_part${local_part_suffix}@$domain"
1790   driver = pipe
1791   return_fail_output
1792   environment = EXTENSION=${substr_1:${local_part_suffix}}
1793   allow_commands = /usr/bin/rt-mailgate
1794
1795 <%- end -%>
1796
1797 ######################################################################
1798 #                      RETRY CONFIGURATION                           #
1799 ######################################################################
1800
1801 # Domain               Error       Retries
1802 # ------               -----       -------
1803
1804 begin retry
1805
1806 ## Note that retry rules specify when an address / host / mail should
1807 ## become eligible for retrying. They do not specify when the retry
1808 ## attempt will actually occur, as this is dependent on queue run
1809 ## frequency and timing.
1810
1811 # For mail to debian.org addresses, this rule starts with
1812 # retries every 10 minutes for 2 hours, then increasing retry intervals,
1813 # starting at 2 hours and increasing each time by a factor of 1.5, up to 16
1814 # hours, then retries every 8 hours until 14 days have passed since the first
1815 # failed delivery.
1816 debian.org             *           F,2h,10m; G,16h,2h,1.5; F,14d,8h
1817
1818 # Bounces should get retried every 10 minutes for up to 2 hours
1819 *                      * senders=: F,2h,10m
1820
1821 # Temporary errors at RCPT TO get retried at 5 minute intervals for
1822 # 2 hours, then 10 minute intervals for 4 hours, and finally at 15
1823 # minute intervals for 4 days. This assumes that the cause of the
1824 # error will get resolved quickly in most cases.
1825 *                      rcpt_4xx    F,2h,5m;  F,4h,10m; F,4d,15m
1826
1827 # For all remaining mails, addresses and hosts, this rule starts with
1828 # retries every 15 minutes for 2 hours, then increasing retry intervals,
1829 # starting at 2 hours and increasing each time by a factor of 1.5, up to 16
1830 # hours, then retries every 8 hours until 4 days have passed since the first
1831 # failed delivery.
1832 *                      *           F,2h,15m; G,16h,2h,1.5; F,4d,8h
1833
1834 # End of Exim 4 configuration