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