Merge branch 'master' of ssh://handel.debian.org/srv/puppet.debian.org/git/dsa-puppet
[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   log_message   = <$sender_address> is blacklisted
820          senders       = ${if exists{/etc/exim4/blacklist}{/etc/exim4/blacklist}{}}
821          message       = We have blacklisted <$sender_address>.  Please stop mailing us
822
823   deny    message  = host $sender_host_address is listed in $dnslist_domain; see $dnslist_text
824           dnslists = ${if match_domain{$domain}{+virtual_domains}\
825                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}\
826                      {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}{$value}{}}}{}}}\
827                      {${lookup{$local_part}lsearch{/etc/exim4/rbllist}{$value}{}} : \
828                      ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rbl}{$value}{}}}}
829           domains       = +handled_domains : +rcpthosts
830           !hosts        = +debianhosts : WHITELIST
831
832   deny    message  = domain $sender_address_domain is listed in $dnslist_domain; see $dnslist_text
833           dnslists = ${if match_domain{$domain}{+virtual_domains}\
834                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}\
835                      {${expand:${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}{$value}{}}}}{}}}\
836                      {${expand:${lookup{$local_part}lsearch{/etc/exim4/rhsbllist}{$value}{}}} : \
837                      ${expand:${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rhsbl}{$value}{}}}}}
838           domains       = +handled_domains : +rcpthosts
839           !hosts        = +debianhosts : WHITELIST
840
841   deny    domains  = +handled_domains : +rcpthosts
842           local_parts   = ${if match_domain{$domain}{+virtual_domains}\
843                            {${if exists {${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}\
844                            {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}{$local_part}{}}}{}}}\
845                            {${lookup{$local_part}lsearch{/etc/exim4/callout_users}{$local_part}{}} : \
846                            ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-callout}{$local_part}{}}}}
847           !hosts   = +debianhosts : WHITELIST
848           !verify  = sender/callout
849
850 <%=
851 out = ""
852 if nodeinfo['mailrelay']
853   out = '
854   accept  domains  = +mailhubdomains
855           endpass
856           message  = unknown user
857           verify   = recipient/callout=30s,defer_ok,use_sender,no_cache
858 '
859 end
860 out
861 %>
862   accept  domains  = +handled_domains
863           endpass
864           message  = unknown user
865           verify   = recipient/defer_ok
866
867   accept  domains  = +rcpthosts
868           endpass
869           message  = unrouteable address
870           verify   = recipient
871
872   accept  hosts         = +debianhosts
873
874   accept  authenticated = *
875
876   deny    message = relay not permitted
877
878 <%=
879 out=''
880 if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty?
881 out='
882 acl_check_mime:
883
884   warn   condition     = ${if <{$message_size}{256000}}
885          condition     = ${if eq {$acl_m_prf}{markup}}
886          set acl_m_srb = ${perl{surblspamcheck}}
887          condition     = ${if eq{$acl_m_srb}{false}{no}{yes}}
888          message       = X-Surbl-Hit: $primary_hostname: $acl_m_srb
889
890   accept condition     = ${if eq {$acl_m_prf}{markup}}
891
892   deny   condition     = ${if <{$message_size}{256000}}
893          set acl_m_srb = ${perl{surblspamcheck}}
894          condition     = ${if eq{$acl_m_srb}{false}{no}{yes}}
895          log_message   = $acl_m_srb
896          message       = $acl_m_srb
897
898   accept
899 '
900 end
901 out
902 %>
903
904 acl_check_predata:
905   deny   condition     = ${if eq{$acl_m_lcl}{localonly}}
906          message       = mail for $acl_m_lrc is only accepted internally
907
908   accept
909
910
911 #!!# ACL that is used after the DATA command
912 check_message:
913   require verify = header_syntax
914           message = Invalid syntax in the header
915
916 <%=
917 out=''
918 if nodeinfo['rtmaster']
919   out='
920   deny    condition = ${if eq {$acl_m_prf}{RTMail}}
921           condition = ${if and{{!match {${lc:$rh_Subject:}} {debian rt}} \
922                                {!match {${lc:$rh_Subject:]}} {\N\[rt.debian.org \N}} \
923                                {!match {$acl_m12}{RTMailRecipientHasSubaddress}}}}
924           message  = messages to the Request Tracker system require a subject tag or a subaddress
925 '
926 end
927 out
928 %>
929 <%=
930 out=''
931 if nodeinfo['packagesqamaster']
932   out='
933   deny    !hosts  = +debianhosts : 217.196.43.134
934           condition = ${if eq {$acl_m_prf}{PTSMail}}
935           condition = ${if def:h_X-PTS-Approved:{false}{true}}
936           message   = messages to the PTS require an X-PTS-Approved header
937 '
938 end
939 out
940 %>
941   deny    condition      = ${if eq {$acl_m_prf}{DBSignedMail}}
942           condition      = ${if and {{!match {$message_body}{PGP MESSAGE}}              \
943                                      {!match {$message_body}{PGP SIGNED MESSAGE}}       \
944                                      {!match {$message_body}{PGP SIGNATURE}}            \
945                                      {!match {$header_content-type:}{multipart/signed}} \
946                                      {!match {$header_content-type:}{pgp}}              \
947                                     }                                                   \
948                             }
949           message        = Mail to this address needs to be PGP-signed
950
951 # RFC 822 and 2822 say that headers must be ASCII.  This kinda emulates
952 # postfix's strict_7bit_headers option, but only checks a few common problem
953 # headers, as there doesn't appear to be an easy way to check them all.
954   deny
955           condition       = ${if or {{match {$rh_Subject:}{[\200-\377]}}\
956                                  {match {$rh_To:}{[\200-\377]}}\
957                                  {match {$rh_From:}{[\200-\377]}}\
958                                  {match {$rh_Cc:}{[\200-\377]}}}{true}{false}}
959           message         = improper use of 8-bit data in message header: message rejected
960
961   deny
962           condition       = ${if match {$rh_Subject:}{[^[:print:]]\{8\}}{true}{false}}
963           message         = Your mailer is not RFC 2047 compliant: message rejected
964
965 <%=
966 out = ""
967 if has_variable?("clamd") && clamd == "true"
968 out = '
969   # FIXME: make blackhole work
970   deny    condition       = ${if eq {$acl_m_prf}{markup}{no}{yes}}
971           demime          = *
972           malware         = */defer_ok
973           message         = malware detected: $malware_name: message rejected
974
975   warn    condition       = ${if eq {$acl_m_prf}{markup}}
976           demime          = *
977           malware         = */defer_ok
978           message         = X-malware detected: $malware_name
979 '
980 end
981 out
982 %>
983 <%=
984 out=''
985 if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty?
986 out='
987   warn   condition     = ${if <{$message_size}{256000}}
988          condition     = ${if eq {$acl_m_prf}{markup}}
989          set acl_m_srb = ${perl{surblspamcheck}}
990          condition     = ${if eq{$acl_m_srb}{false}{no}{yes}}
991          message       = X-Surbl-Hit: $primary_hostname: $acl_m_srb
992
993   accept condition     = ${if eq {$acl_m_prf}{markup}}
994
995   deny   condition     = ${if <{$message_size}{256000}}
996          set acl_m_srb = ${perl{surblspamcheck}}
997          condition     = ${if eq{$acl_m_srb}{false}{no}{yes}}
998          log_message   = $acl_m_srb
999          message       = $acl_m_srb
1000 '
1001 end
1002 out
1003 %>
1004   # Check header_sender except for survey@popcon.d.o
1005   deny    condition    = ${if eq{$acl_m_prf}{PopconMail}{false}{true}}
1006           !verify      = header_sender
1007           message      = No valid sender found in the From:, Sender: and Reply-to: headers
1008
1009 <%=
1010 out = ""
1011 if nodeinfo['packagesmaster']
1012   out = '
1013   deny  message        = Congratulations, you scored $spam_score points.
1014         log_message    = spam: $spam_score points.
1015         condition      = ${if eq {$acl_m_prf}{PackagesMail}}
1016         !authenticated = *
1017         !verify        = certificate
1018         !hosts         = +debianhosts
1019         condition      = ${if <{$message_size}{256000}}
1020         spam           = pkg_user : true
1021         condition      = ${if >{$spam_score_int}{59}}
1022 '
1023 end
1024 out
1025 %>
1026   accept
1027
1028
1029
1030 ######################################################################
1031 #                      REWRITE CONFIGURATION                         #
1032 ######################################################################
1033
1034
1035
1036 begin rewrite
1037
1038 \N^buildd_(.*)@ries\.debian\.org$\N buildd_$1@buildd.debian.org T
1039 \N^buildd_(.*)@klecker\.debian\.org$\N buildd_$1@buildd.debian.org T
1040 *@debian.org ${lookup{$1}cdb{/var/lib/misc/${primary_hostname}/mail-forward.cdb}{$value}fail} T
1041 *@people.debian.org ${lookup{$1}cdb{/var/lib/misc/${primary_hostname}/mail-forward.cdb}{$value}fail} T
1042 #*@${primary_hostname} "${if exists{/etc/exim4/email-addresses}{${lookup{$1}lsearch{/etc/exim4/email-addresses}{$value}fail}}fail}" fFs
1043 m68k@buildd.debian.org m68k-build@nocrew.org Ttrbc
1044
1045
1046 #!!#######################################################!!#
1047 #!!# Here follow routers created from the old routers,   #!!#
1048 #!!# for handling non-local domains.                     #!!#
1049 #!!#######################################################!!#
1050
1051 begin routers
1052
1053
1054
1055 ######################################################################
1056 #                      ROUTERS CONFIGURATION                         #
1057 #                Specifies how addresses are handled                 #
1058 ######################################################################
1059 #                          ORDER DOES MATTER                         #
1060 #     An address is passed to each in turn until it is accepted.     #
1061 ######################################################################
1062
1063 <%=
1064 out = ""
1065 if nodeinfo['mailrelay']
1066   out = '
1067 relay_manualroute:
1068   driver = manualroute
1069   domains = +mailhubdomains
1070   transport = remote_smtp
1071   route_data = ${lookup{$domain}lsearch{/etc/exim4/manualroute}}
1072   require_files = /etc/exim4/manualroute
1073 '
1074 end
1075 out
1076 %>
1077
1078 bsmtp:
1079   debug_print = "R: bsmtp for $local_part@$domain"
1080   driver = manualroute
1081   domains = +bsmtp_domains
1082   require_files = /etc/exim4/bsmtp
1083   route_list = * ${extract{file}{\
1084                    ${lookup{$domain}partial-lsearch{/etc/exim4/bsmtp}\
1085                      {$value}fail}}}
1086   transport = bsmtp
1087
1088 # This router routes to remote hosts over SMTP by explicit IP address,
1089 # given as a "domain literal" in the form [nnn.nnn.nnn.nnn]. The RFCs
1090 # require this facility, which is why it is enabled by default in Exim.
1091 ipliteral:
1092   debug_print = "R: ipliteral for $local_part@$domain"
1093   driver = ipliteral
1094   domains = !+handled_domains
1095   transport = remote_smtp
1096   ignore_target_hosts = +reservedaddrs
1097
1098 <%=
1099 out = ""
1100 if not nodeinfo['smarthost'].empty?
1101 out = '
1102 smarthost:
1103   debug_print = "R: smarthost for $local_part@$domain"
1104   driver = manualroute
1105   domains = !+handled_domains
1106   transport = remote_smtp_smarthost
1107   route_list = * ' + nodeinfo['smarthost'] + '
1108   host_find_failed = defer
1109   same_domain_copy_routing = yes
1110   no_more
1111 '
1112 end
1113 out
1114 %>
1115
1116 # This router routes to remote hosts over SMTP using a DNS lookup.
1117 # Ignore reserved network responses, including localhost.
1118 dnslookup:
1119   debug_print = "R: dnslookup for $local_part@$domain"
1120   driver = dnslookup
1121   domains = !+handled_domains
1122   transport = remote_smtp
1123   ignore_target_hosts = +reservedaddrs
1124   no_more
1125
1126 # This router handles aliasing using a traditional /etc/aliases file.
1127 # If any of your aliases expand to pipes or files, you will need to set
1128 # up a user and a group for these deliveries to run under. You can do
1129 # this by uncommenting the "user" option below (changing the user name
1130 # as appropriate) and adding a "group" option if necessary.
1131
1132 system_aliases:
1133   debug_print = "R: system_aliases for $local_part@$domain"
1134   driver = redirect
1135   allow_defer
1136   allow_fail
1137   data = ${lookup{$local_part}lsearch*{/etc/aliases}}
1138   domains = +local_domains
1139   file_transport = address_file
1140   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1141   pipe_transport = address_pipe
1142   retry_use_local_part
1143
1144 # This router handles forwarding using traditional .forward files.
1145 # It also allows mail filtering when a forward file starts with the 
1146 # string "# Exim filter": to disable filtering, uncomment the "filter" 
1147 # option. The check_ancestor option means that if the forward file 
1148 # generates an address that is an ancestor of the current one, the 
1149 # current one gets passed on instead. This covers the case where A is 
1150 # aliased to B and B has a .forward file pointing to A.
1151
1152 # For standard debian setup of one group per user, it is acceptable---normal
1153 # even---for .forward to be group writable. If you have everyone in one
1154 # group, you should comment out the "modemask" line. Without it, the exim
1155 # default of 022 will apply, which is probably what you want.
1156
1157 userforward_verify:
1158   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
1159   driver = redirect
1160   check_ancestor
1161   user = Debian-exim
1162   no_check_local_user
1163   directory_transport = address_directory
1164   domains = +local_domains
1165   # filter - I have disabled filtering to force users to use .forward-foo files
1166   # or procmail. This will make it easier to move mailers in the future
1167   #
1168   # This bit does the qmailesque extension names, foo-bar@ is .forward-foo it
1169   # also checks if the .forward-bar exists, if not then it uses
1170   # .forward-default instead.
1171   file = $home/.forward\
1172          ${if eq{}{$local_part_suffix}{}{\
1173            ${if exists {${home}/.forward${local_part_suffix}} \
1174              {${local_part_suffix}}{-default}}\
1175            }\
1176           }
1177   file_transport = address_file
1178   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1179   local_part_suffix = -*
1180   local_part_suffix_optional
1181   modemask = 002
1182   pipe_transport = address_pipe
1183   reply_transport = address_reply
1184   require_files = $home
1185   router_home_directory = ${lookup passwd{$local_part}{${extract{5}{:}{$value}}}fail}
1186   verify_only
1187
1188 userforward:
1189   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
1190   driver = redirect
1191   check_ancestor
1192   check_local_user
1193   directory_transport = address_directory
1194   domains = +local_domains
1195   # filter - I have disabled filtering to force users to use .forward-foo files
1196   # or procmail. This will make it easier to move mailers in the future
1197   #
1198   # This bit does the qmailesque extension names, foo-bar@ is .forward-foo it
1199   # also checks if the .forward-bar exists, if not then it uses
1200   # .forward-default instead.
1201   file = $home/.forward\
1202          ${if eq{}{$local_part_suffix}{}{\
1203            ${if exists {${home}/.forward${local_part_suffix}} \
1204              {${local_part_suffix}}{-default}}\
1205            }\
1206           }
1207   file_transport = address_file
1208   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1209   local_part_suffix = -*
1210   local_part_suffix_optional
1211   modemask = 002
1212   pipe_transport = address_pipe
1213   reply_transport = address_reply
1214   require_files = $home
1215   no_verify
1216
1217 # This delivers to procmail
1218 procmail:
1219   debug_print = "R: procmail for $local_part@$domain"
1220   driver = accept
1221   check_local_user
1222   domains = +local_domains
1223   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1224   no_verify
1225   no_expn
1226   require_files = $local_part:$home/.procmailrc
1227   transport = procmail_pipe
1228   transport_current_directory = $home
1229   
1230 # This driver delivers to the LDAP generated alias file.
1231 ldap_aliases:
1232   debug_print = "R: ldap_aliases for $local_part@$domain"
1233   driver = redirect
1234   allow_defer
1235   allow_fail
1236   data = ${if exists{/var/lib/misc/$primary_hostname/mail-forward.cdb}\
1237              {${lookup{$local_part}cdb\
1238                {/var/lib/misc/$primary_hostname/mail-forward.cdb}}}}
1239   domains = +local_domains
1240   file_transport = address_file
1241   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1242   pipe_transport = address_pipe
1243   retry_use_local_part
1244   
1245 # This director matches local user mailboxes.
1246 localuser:
1247   debug_print = "R: localuser for $local_part@$domain"
1248   driver = accept
1249   check_local_user
1250   domains = +local_domains
1251   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1252   # Disable if the user has never logged in
1253   require_files = $home
1254   transport = local_delivery
1255   no_more
1256
1257 # Now we begin the Virtual Domain configuration
1258 # Everything before here should apply only to the local domains with a 
1259 # domains= rule
1260
1261 # exim4 fails the router if it can't change to the user/group for delivery
1262 # during verification.  So we have to seperate the cases of verifying
1263 # the virts, and delivering to them.  blah.
1264 <%=
1265 out = ""
1266 if nodeinfo['packagesmaster']
1267   out = '
1268 # This router delivers for packages.d.o
1269 packages:
1270   debug_print = "R: packages for $local_part@$domain"
1271   driver = redirect
1272   file_transport = address_file
1273   pipe_transport = address_pipe
1274   domains = packages.debian.org
1275   require_files = /org/packages.debian.org/conf/maintainer
1276   data = ${lookup{$local_part}cdb{/org/packages.debian.org/conf/maintainer.cdb}}
1277   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1278   transport_home_directory = /org/packages.debian.org/mail
1279   transport_current_directory = /org/packages.debian.org/mail
1280   check_ancestor
1281   retry_use_local_part
1282   no_more
1283 '
1284 end
1285 out
1286 %>
1287
1288 <%=
1289 out = ""
1290 if nodeinfo['bugsmaster']
1291   out = '
1292 # This router delivers for bugs.d.o
1293 bugs:
1294   debug_print = "R: bugs for $local_part@$domain"
1295   driver = accept
1296   transport = bugs_pipe
1297   domains = bugs.debian.org
1298   cannot_route_message = Unknown or archived bug
1299   require_files = /org/bugs.debian.org/mail/run-procmail
1300   no_more
1301   local_parts = ${if match\
1302                   {$local_part}\
1303                   {\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}\
1304                {${if exists{/org/bugs.debian.org/spool/db-h/$2/$1$2.summary}\
1305                {$local_part}fail}}fail}
1306 '
1307 end
1308 out
1309 %>
1310
1311 <%=
1312 out = ""
1313 if nodeinfo['rtmaster']
1314   out = '
1315 # This router delivers for rt.d.o
1316 rt_force_new_verbose:
1317   debug_print = "R: rt for $local_part+new@$domain"
1318   driver = redirect
1319   domains = rt.debian.org
1320   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1321   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1322   local_part_suffix = +new
1323   pipe_transport = rt_pipe
1324   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}}"
1325   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1326
1327 # FIXME: figure out how to generalize this approach so that all of the following would work
1328 # - rt+NNNN@rt.debian.org          : attach correspondence to ticket (verbose)
1329 # - rt+NNNN-quiesce@rt.debian.org  : attach correspondence to ticket (quiesce)
1330 # - rt+NNNN-<action>@rt.debian.org : attach correspondence to ticket (some action)
1331 # requires modification to custom condition in \'scrips\'
1332 rt_force_new_quiesce:
1333   debug_print = "R: rt for $local_part+new-quiesce@$domain"
1334   driver = redirect
1335   domains = rt.debian.org
1336   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1337   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1338   local_part_suffix = +new-quiesce
1339   pipe_transport = rt_pipe
1340   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}}"
1341   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nX-RT-Mode: quiesce"
1342
1343 rt_otherwise:
1344   debug_print = "R: rt for $local_part@$domain"
1345   driver = redirect
1346   domains = rt.debian.org
1347   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1348   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1349   local_part_suffix = +*
1350   local_part_suffix_optional
1351   pipe_transport = rt_pipe
1352   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}}"
1353   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1354 '
1355 end
1356 out
1357 %>
1358
1359 virt_alias_verify:
1360   debug_print = "R: virt_aliases for $local_part@$domain"
1361   driver = redirect
1362   data = ${if exists{\
1363            ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
1364            {${lookup{$local_part}lsearch*{\
1365               ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
1366            }}}}
1367   directory_transport = address_directory
1368   cannot_route_message = Unknown user
1369   domains = +virtual_domains
1370   file_transport = address_file
1371   pipe_transport = address_pipe
1372   qualify_preserve_domain
1373   retry_use_local_part
1374   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1375   transport_home_directory = ${extract{directory}{VDOMAINDATA}}
1376   verify_only
1377
1378 virt_direct_verify:
1379   debug_print = "R: virt_direct for $local_part@$domain"
1380   driver = redirect
1381   no_check_local_user
1382   user = Debian-exim
1383   allow_filter
1384   modemask = 002
1385   directory_transport = address_directory
1386   domains = +virtual_domains
1387   file = $home/.forward-\
1388               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
1389                    {default}}
1390   file_transport = address_file
1391   pipe_transport = address_pipe
1392   reply_transport = address_reply
1393   retry_use_local_part
1394   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1395   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1396   verify_only
1397
1398 # This is a senmailesque alias file lookup
1399 virt_aliases:
1400   debug_print = "R: virt_aliases for $local_part@$domain"
1401   driver = redirect
1402   allow_defer
1403   allow_fail
1404   data = ${if exists{\
1405            ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
1406            {${lookup{$local_part}lsearch*{\
1407               ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
1408            }}}}
1409   directory_transport = address_directory
1410   domains = +virtual_domains
1411   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1412   cannot_route_message = Unknown user
1413   group = ${extract{group}{VDOMAINDATA}}
1414   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1415   pipe_transport = address_pipe
1416   qualify_preserve_domain
1417   retry_use_local_part
1418   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1419   transport_home_directory = ${extract{directory}{VDOMAINDATA}}
1420   no_verify
1421   user = ${extract{user}{VDOMAINDATA}}
1422   
1423 # This is a qmailesque deliver into a directory of .forward files
1424 virt_direct:
1425   debug_print = "R: virt_direct for $local_part@$domain"
1426   driver = redirect
1427   allow_filter
1428   allow_fail
1429   allow_defer
1430   no_check_local_user
1431   directory_transport = address_directory
1432   domains = +virtual_domains
1433   file = $home/.forward-\
1434               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
1435                    {default}}
1436   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1437   group = ${extract{group}{VDOMAINDATA}}
1438   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1439   modemask = 002
1440   pipe_transport = address_pipe
1441   reply_transport = address_reply
1442   retry_use_local_part
1443   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1444   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1445   no_verify
1446   user = ${extract{user}{VDOMAINDATA}}
1447   #debug_print = .forward-${if exists {${home}/.forward-${local_part}} {${local_part}} {default}}
1448
1449 ######################################################################
1450 #                      TRANSPORTS CONFIGURATION                      #
1451 ######################################################################
1452 #                       ORDER DOES NOT MATTER                        #
1453 #     Only one appropriate transport is called for each delivery.    #
1454 ######################################################################
1455
1456
1457 begin transports
1458
1459 # This transport is used for local delivery to user mailboxes. On debian
1460 # systems group mail is used so we can write to the /var/mail
1461 # directory. (The alternative, which most other unixes use, is to deliver
1462 # as the user's own group, into a sticky-bitted directory)
1463 local_delivery:
1464   driver = appendfile
1465   file = /var/mail/${local_part}
1466   group = mail
1467   mode = 0660
1468   no_mode_fail_narrower
1469   return_path_add
1470   
1471 # This transport is used for handling pipe addresses generated by alias
1472 # or .forward files. It has a conventional name, since it is not actually
1473 # mentioned elsewhere in this configuration file. (A different name *can*
1474 # be specified via the "address_pipe_transport" option if you really want
1475 # to.) If the pipe generates any standard output, it is returned to the sender
1476 # of the message as a delivery error. Set return_fail_output instead if you
1477 # want this to happen only when the pipe fails to complete normally.
1478
1479 address_pipe:
1480   driver = pipe
1481   current_directory = ${home}
1482   environment = "EXTENSION=${substr_1:${local_part_suffix}}:\
1483                  EXT=${substr_1:${local_part_suffix}}:\
1484                  LOCAL=${local_part}${local_part_suffix}:\
1485                  RECIPIENT=${local_part}${local_part_suffix}@${domain}"
1486   return_output
1487   return_path_add
1488
1489 # This transport is used for handling file addresses generated by alias
1490 # or .forward files. It has a conventional name, since it is not actually
1491 # mentioned elsewhere in this configuration file.
1492
1493 address_file:
1494   driver = appendfile
1495   return_path_add
1496
1497 address_file_group:
1498   driver = appendfile
1499   return_path_add
1500   mode = 0660
1501   directory_mode = 0770
1502   mode_fail_narrower = false
1503
1504 # This transport is used for handling file addresses generated by alias
1505 # or .forward files if the path ends in "/", which causes it to be treated
1506 # as a directory name rather than a file name. Each message is then delivered
1507 # to a unique file in the directory. If instead you want all such deliveries to
1508 # be in the "maildir" format that is used by some other mail software,
1509 # uncomment the final option below. If this is done, the directory specified
1510 # in the .forward or alias file is the base maildir directory.
1511 #
1512 # Should you want to be able to specify either maildir or non-maildir
1513 # directory-style deliveries, then you must set up yet another transport,
1514 # called address_directory2. This is used if the path ends in "//" so should
1515 # be the one used for maildir, as the double slash suggests another level
1516 # of directory. In the absence of address_directory2, paths ending in //
1517 # are passed to address_directory.
1518
1519 address_directory:
1520   driver = appendfile
1521   check_string = 
1522   maildir_format
1523   message_prefix = ""
1524   message_suffix = ""
1525   return_path_add
1526
1527 # This transport is used for handling autoreplies generated by the filtering
1528 # option of the forwardfile director. It has a conventional name, since it
1529 # is not actually mentioned elsewhere in this configuration file.
1530 address_reply:
1531   driver = autoreply
1532
1533 # This transport is used for delivering messages over SMTP connections.
1534
1535 remote_smtp:
1536   driver = smtp
1537   connect_timeout = 1m
1538   delay_after_cutoff = false
1539 <%=
1540 out = ""
1541 if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true"
1542   out = "  tls_certificate = /etc/exim4/ssl/thishost.crt
1543   tls_privatekey = /etc/exim4/ssl/thishost.key"
1544 end
1545 out
1546 %>
1547
1548 <%=
1549 out = ""
1550 if not nodeinfo['smarthost'].empty?
1551 out = '
1552 remote_smtp_smarthost:
1553   debug_print = "T: remote_smtp_smarthost for $local_part@$domain"
1554   driver = smtp
1555   delay_after_cutoff = false
1556   port = '
1557   out += nodeinfo['smarthost_port'].to_s + "\n"
1558   if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true"
1559     out += '  tls_tempfail_tryclear = false
1560   hosts_require_tls = ' + nodeinfo['smarthost'] + '
1561   tls_certificate = /etc/exim4/ssl/thishost.crt
1562   tls_privatekey = /etc/exim4/ssl/thishost.key
1563 '
1564   end
1565 end
1566 out
1567 %>
1568
1569 # Send the message to procmail
1570 procmail_pipe:
1571   driver = pipe
1572   command = /usr/bin/procmail -a ${substr_1:${local_part_suffix}}}
1573   return_path_add
1574   user = ${local_part}
1575
1576 bsmtp:
1577   driver = appendfile
1578   batch_max = 100
1579   file = ${host}
1580   message_prefix = 
1581   message_suffix = 
1582   use_bsmtp
1583   user = ${extract{user}{\
1584                    ${lookup{$domain}partial-lsearch{/etc/exim4/bsmtp}\
1585                      {$value}fail}\
1586                    }}
1587
1588 <%=
1589 out = ""
1590 if nodeinfo['bugsmaster']
1591   out = '
1592 bugs_pipe:
1593   driver = pipe
1594   command = /org/bugs.debian.org/mail/run-procmail
1595   environment = "EXTENSION=${substr_1:${local_part_suffix}}:\
1596                  EXT=${substr_1:${local_part_suffix}}:\
1597                  LOCAL=${local_part}${local_part_suffix}:\
1598                  RECIPIENT=${local_part}${local_part_suffix}@${domain}"
1599   return_path_add
1600   return_output
1601   user = debbugs
1602 '
1603 end
1604 out
1605 %>
1606
1607 <%=
1608 out = ""
1609 if nodeinfo['rtmaster']
1610   out = '
1611 rt_pipe:
1612   debug_print = "T: rt_pipe for $local_part${local_part_suffix}@$domain"
1613   driver = pipe
1614   return_fail_output
1615   environment = EXTENSION=${substr_1:${local_part_suffix}}
1616   allow_commands = /usr/bin/rt-mailgate
1617 '
1618 end
1619 out
1620 %>
1621
1622 ######################################################################
1623 #                      RETRY CONFIGURATION                           #
1624 ######################################################################
1625
1626 # This single retry rule applies to all domains and all errors. It specifies
1627 # retries every 15 minutes for 2 hours, then increasing retry intervals,
1628 # starting at 2 hours and increasing each time by a factor of 1.5, up to 16
1629 # hours, then retries every 8 hours until 4 days have passed since the first
1630 # failed delivery.
1631
1632 # Domain               Error       Retries
1633 # ------               -----       -------
1634
1635
1636 begin retry
1637
1638 debian.org             *           F,2h,10m; G,16h,2h,1.5; F,14d,8h
1639 *                      rcpt_4xx    F,2h,5m;  F,4h,10m; F,4d,15m
1640 *                      *           F,2h,15m; G,16h,2h,1.5; F,4d,8h
1641
1642 # End of Exim 4 configuration