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