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