Named variables for postgrey
[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_c1
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_localonly:
285   accept  local_parts   = +local_only_users
286           domains       = +local_domains
287           hosts         = !+debianhosts
288
289   deny
290
291 check_helo:
292
293   warn    set acl_c1    = 0
294
295 <%= 
296 out = ""
297 if nodeinfo['mailrelay']
298   out = "  accept  verify   = certificate"
299 end
300 out
301 %>
302
303   # These are in HELO acl so that they are only run once.  They increment a counter,
304   # so we don't want it to increment per rcpt to.
305
306   warn    dnslists       = list.dnswl.org&0.0.0.3
307           log_message    = Hit on list.dnswl.org for $sender_host_address
308           set acl_c1     = ${eval:$acl_c1-30}
309
310   warn    dnslists       = list.dnswl.org&0.0.0.2
311           log_message    = Hit on list.dnswl.org for $sender_host_address
312           set acl_c1     = ${eval:$acl_c1-20}
313
314   warn    dnslists       = list.dnswl.org
315           log_message    = Hit on list.dnswl.org for $sender_host_address
316           set acl_c1     = ${eval:$acl_c1-10}
317
318   warn    condition      = ${if isip {$sender_helo_name}{true}{false}}
319           log_message    = remote host used IP address in HELO/EHLO greeting
320           set acl_c1     = ${eval:$acl_c1+20}
321
322   warn    !hosts         = +debianhosts
323           condition      = ${if eq{$host_lookup_failed}{1}}
324           set acl_c1     = ${eval:$acl_c1+20}
325
326   warn    !hosts         = +debianhosts
327           condition      = ${if eq{$host_lookup_failed}{0}}
328           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}}
329           set acl_c1     = ${eval:$acl_c1+20}
330
331   warn    !hosts         = +debianhosts
332           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}}
333           set acl_c1     = ${eval:$acl_c1+20}
334
335   warn    !hosts         = +debianhosts
336           dnslists       = dul.dnsbl.sorbs.net
337           set acl_c1     = ${eval:$acl_c1+15}
338
339   # If the sender's helo name is empty, the message will be rejected later
340   # because the helo is empty.  If the rDNS lookup failed, we are already
341   # going to greylist them, so no sense worrying about it here.  Finally,
342   # if rDNS does not match helo name (both lower cased first), greylist.
343
344   warn    !hosts         = +debianhosts
345           condition      = ${if eq {$host_lookup_failed}{1}{no}{yes}}
346           condition      = ${if def:sender_helo_name {yes}{no}}
347           condition      = ${if eq {${lc:$sender_helo_name}}{${lc:$sender_host_name}}{no}{yes}}
348           log_message    = HELO doesn't match rDNS
349           set acl_c1     = ${eval:$acl_c1+8}
350
351   # Regexes of doom
352   # matches 098325879 - looks fishy
353
354   warn condition        = ${if and { \
355                                      { !match{$sender_helo_name}{\N^\[.+\]$\N} } \
356                                      { !match{$sender_helo_name}{\N^(?i)((?=[^-])[a-z0-9-]*[a-z0-9]\.)+[a-z]{2,6}$\N} } \
357                                     } \
358                             }
359        log_message      = non-FQDN HELO
360        set acl_c1       = ${eval:$acl_c1+12}
361
362   # Matches DOMAIN99.com - looks bad
363
364   warn condition       = ${if match {$sender_helo_name}{\N^[A-Z]+[A-Z0-9\-]+\.[A-Za-z0-9]+$\N}}
365        log_message     = SHOUTING HELO
366        set acl_c1      = ${eval:$acl_c1+7}
367
368   # Random HELO (run of 7 consonants) (constructed by viruses).  We purposefully
369   # skip matching on machines named .*smtp.*, since that's 4 already.  This is a fairly
370   # naive test, so it's not worth much
371
372   warn condition       = ${if match {${lc:$sender_helo_name}}{smtp}{no}{yes}}
373        condition       = ${if match {${lc:$sender_helo_name}}{\N^[a-z0-9]+\.[a-z]+$\N}}
374        condition       = ${if match {${lc:$sender_helo_name}}{\N.*[bcdfghjklmnpqrstvwxz]{7,}.*\.[a-z]+$\N}}
375        log_message     = random HELO
376        set acl_c1      = ${eval:$acl_c1+5}
377
378   # Implicit, but simpler to just say it
379   accept
380
381 #!!# ACL that is used after the RCPT command on the submission port
382 check_submission:
383
384   # Accept if the source is local SMTP (i.e. not over TCP/IP).
385   # We do this by testing for an empty sending host field.
386   accept  hosts = : 127.0.0.1
387
388 <%= 
389 out = ""
390 if nodeinfo['mailrelay']
391   out = "  accept  verify   = certificate"
392 end
393 out
394 %>
395
396   # Defer after too many bad RCPT TO's.  Legit MTAs will retry later.
397   # This is a rough pass at preventing addres harvesting or other mail blasts.
398
399   defer  log_message   = Too many bad recipients ${eval:$rcpt_fail_count} out of $rcpt_count
400          message       = Too many bad recipients, try again later
401          condition     = ${if > {${eval:$rcpt_fail_count}}{3}{yes}{no}}
402
403   defer
404           ratelimit      = 5 / 60m / per_rcpt / $sender_host_address
405           !hosts         = +debianhosts
406           message        = sorry, only 5 reports per hour for submission
407
408   accept  domains  = +local_domains
409           hosts    = +debianhosts
410           endpass
411           message  = unknown user
412           verify   = recipient
413
414 <%=
415 out = ""
416 if nodeinfo['mailrelay']
417   out = '
418   accept  domains  = +mailhubdomains
419           endpass
420           message  = unknown user
421           verify   = recipient/callout=30s,defer_ok,use_sender,no_cache
422 '
423 end
424 out
425 %>
426
427   accept  domains  = +submission_domains
428           endpass
429           message  = unknown user
430           verify   = recipient
431
432   deny    message = relay not permitted
433
434 #!!# ACL that is used after the RCPT command
435 check_recipient:
436
437 <%=
438 out = ""
439 if nodeinfo['mailrelay']
440   out = "  accept  verify   = certificate"
441 end
442 out
443 %>
444
445   # Defer after too many bad RCPT TO's.  Legit MTAs will retry later.
446   # This is a rough pass at preventing addres harvesting or other mail blasts.
447
448   defer  log_message   = Too many bad recipients ${eval:$rcpt_fail_count} out of $rcpt_count
449          message       = Too many bad recipients, try again later
450          !hosts        = +debianhosts
451          condition     = ${if > {${eval:$rcpt_fail_count}}{3}{yes}{no}}
452
453   # Dump spambots that are so stupid they say helo as our IP address
454
455   drop !hosts          = +debianhosts
456        condition       = ${if eq {$sender_helo_name}{$interface_address}{yes}{no}}
457        message         = HELO mismatch Forged HELO for ($sender_helo_name)
458
459   # Also for spambots that say helo as us or one of our domains
460
461   drop !hosts          = +debianhosts
462        condition       = ${if match_domain{$sender_helo_name}{$primary_hostname:+handled_domains}}
463        condition       = ${if !match{$sender_host_name}{${rxquote:$sender_helo_name}\N$\N}}
464        message         = HELO mismatch Forged HELO for ($sender_helo_name)
465
466   # This logic gives you a list of commonly forged domains in helo to reject against
467
468   warn set acl_m2      = ${lookup{$sender_helo_name} \
469                            nwildlsearch{/etc/exim4/helo-check} \
470                           {${if eq{$value}{}{$sender_helo_name}{$value}}}{}}
471
472   # This is a failsafe in case DNS fails - we defer instead of hard reject if they 
473   # say helo as a name in the list but we can't look them up
474
475   defer !hosts         = +debianhosts
476         condition      = ${if eq{$acl_m2}{}{no}{yes}}
477         condition      = ${if eq{$sender_host_name}{}{yes}{no}}
478         condition      = ${if eq{$host_lookup_failed}{1}{no}{yes}}
479         message        = Access temporarily denied. Resolve failed PTR for $sender_host_address
480
481   # If DNS works, go ahead and reject them
482
483   drop !hosts          = +debianhosts
484        condition       = ${if and { {!eq{$acl_m2}{}}{!match{$sender_host_name}{${rxquote:$acl_m2}\N$\N}}}{yes}{no}}
485         message        = HELO mismatch Forged HELO for ($sender_helo_name)
486
487   # disabled accounts don't even get local mail.
488   deny    local_parts   = lsearch;/var/lib/misc/$primary_hostname/mail-disable
489           domains       = +local_domains
490           message       = ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-disable}{$value}}
491
492   deny    domains       = +virtual_domains
493           local_parts   = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/localonly}}}\
494                                       {${extract{directory}{VDOMAINDATA}{${value}/localonly}}}\
495                                       {}}
496           hosts         = !+debianhosts
497           message       = mail for <$local_part@$domain> only accepted from debian.org machines
498   # Accept if the source is local SMTP (i.e. not over TCP/IP).
499   # We do this by testing for an empty sending host field.
500   accept  hosts = :
501   
502   deny    domains       = +handled_domains
503           local_parts   = ^[.] : ^.*[@%!/|]
504   
505   deny    domains       = !+handled_domains
506           local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
507
508 # forwards mail to @d.o address, even if it's a bounce from master, no reply
509 # from source address; rejecting all mail now.
510   deny    recipients    = mendoza@debian.org
511           hosts         = 65.110.39.147 : 64.39.31.15
512           message       = <mendoza@kenny.linuxsis.net> cannot forward here while mailer-daemon mail is not caught
513
514   deny    condition     = ${lookup{$sender_address_local_part}lsearch{/etc/exim4/localusers}{true}}
515           sender_domains= +local_domains : debian.org : debian.net : debian.com
516           hosts         = !+debianhosts
517           message       = mail from <$sender_address> not allowed externally
518
519   deny    condition     = ${if match_domain{$sender_address_domain}{+virtual_domains}{1}{0}}
520           condition     = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/neversenders}}}{1}{0}}
521           condition     = ${if match_local_part {$sender_address_local_part}{${extract{directory}{VDOMAINDATA}{${value}/neversenders}}}{1}{0}}
522           message       = no mail should ever come from <$sender_address>
523
524   warn    condition     = ${if eq{$acl_m6}{}}
525           acl           = acl_localonly
526           set acl_m6    = localonly
527           set acl_m7    = ${if eq{$acl_m7}{}{$local_part@$domain}{$acl_m7, $local_part@$domain}}
528
529   warn    condition     = ${if eq{$acl_m6}{}}
530           !acl          = acl_localonly
531           set acl_m6    = normal
532
533   defer   condition     = ${if eq{$acl_m6}{localonly}}
534           !acl          = acl_localonly
535           log_message   = Only one profile at a time, please
536
537   defer   condition     = ${if eq{$acl_m6}{normal}}
538           acl           = acl_localonly
539           log_message   = Only one profile at a time, please
540
541 <%=
542 out=''
543 if 0 == 1:
544 out='
545   deny    message  = address $sender_host_address is listed in $dnslist_domain; $dnslist_text
546           hosts    = !+debianhosts
547           dnslists = rbl.debian.net : rbl.debian.net/$sender_address_domain
548 '
549 end
550 out
551 %>
552
553   deny    !recipients = survey@popcon.debian.org
554           !verify = sender
555
556   defer   !hosts         = +debianhosts
557           condition      = ${if >{${eval:$acl_c1}}{0}}
558           ratelimit      = 10 / 60m / per_rcpt / $sender_host_address
559           message        = slow down (no reverse dns, mismatched ehlo, dialup, or in blacklists)
560 <%=
561 out = ""
562 if has_variable?("policydweight") && policydweight == "true"
563 out = '
564   # Check with policyd-weight - this only works with a version after etch\'s,
565   # sadly.  etch\'s version attempts to hold the socket open, since that\'s what
566   # postfix expects.  Exim, on the other hand, expects the remote side to close
567   # the socket when it\'s finished sending data, so it see each transaction as
568   # an incomplete read.  I\'m sure there\'s a way we could force exim to do
569   # something sick and clever to force either the interpretation or the socket
570   # closure, but I\'m fairly sure it\'s now worth it, since the backport of
571   # policyd-weight is trivial.
572   warn  !hosts         = +debianhosts
573         set acl_m_pw   = ${readsocket{inet:127.0.0.1:12525}\
574                           {request=smtpd_access_policy\n\
575                            protocol_state=RCPT\n\
576                            protocol_name=${uc:$received_protocol}\n\
577                            helo_name=$sender_helo_name\n\
578                            queue_id=$message_exim_id\n\
579                            sender=$sender_address\n\
580                            recipient=$local_part@$domain\n\
581                            recipient_count=$rcpt_count\n\
582                            client_address=$sender_host_address\n\
583                            client_name=$sender_host_name\n\
584                            reverse_client_name=$sender_host_name\n\
585                            instance=$sender_host_address.$sender_address.$sender_helo_name\n\n}\
586                           {20s}{\n}{socket failure}}
587
588   # Defer on socket error
589   defer !hosts         = +debianhosts
590         condition      = ${if eq{$acl_m_pw}{socket failure}{yes}{no}}
591         message        = Cannot connect to policyd-weight. Please try again later.
592
593   # Set proposed action to $acl_m_act and message to $acl_m_mes
594   warn  !hosts         = +debianhosts
595         set acl_m_mes  = ${extract{action}{$acl_m_pw}}
596         set acl_m_act  = ${sg{$acl_m_pw}{\Naction=[^ ]+ (.*)\n\n\N}{\$1}}
597
598   # Add X-policyd-weight header line to message
599   warn  !hosts         = +debianhosts
600         message        = $acl_m_mes
601         condition      = ${if eq{$acl_m_act}{PREPEND}{yes}{no}}
602
603   # Write log message, if policyd-weight can\'t run checks
604   warn  !hosts         = +debianhosts
605         log_message    = policyd-weight message: $acl_m_mes
606         condition      = ${if eq{$acl_m_act}{DUNNO}{yes}{no}}
607
608   # Deny mails which policyd-weight thinks are spam
609   deny  !hosts         = +debianhosts
610         message        = policyd-weight said: $acl_m_mes
611         condition      = ${if eq{$acl_m_act}{550}{yes}{no}}
612
613   # Defer messages when policyd-weight suggests so.
614   defer  !hosts         = +debianhosts
615          message        = policyd-weight said: $acl_m_mes
616          condition      = ${if eq{$acl_m_act}{450}{yes}{no}}
617 '
618 end
619 out
620 %>
621   warn    recipients = survey@popcon.debian.org
622           set acl_m1 = PopconMail
623
624 <%=
625 out=''
626 if nodeinfo['rtmaster']
627   out='
628   warn    domains  = rt.debian.org
629           set acl_m1 = RTMail
630           set acl_m12 = ${if def:acl_m12 {$acl_m12} {${if or{{match{$local_part}{\N[^+]+\+\d+\N}}{match{$local_part}{\N[^+]+\+new\N}}} {RTMailRecipientHasSubaddress}}}}
631 '
632 end
633 out
634 %>
635 <%=
636 out=''
637 if nodeinfo['packagesqamaster']
638   out='
639   warn    domains  = packages.qa.debian.org
640           set acl_m1 = PTSMail
641
642   warn    recipients = owner@packages.qa.debian.org : postmaster@packages.qa.debian.org
643           set acl_m1 = PTSOwner
644
645   warn    senders  = :
646           domains  = packages.qa.debian.org
647           condition = ${if match{$local_part}{\N^bounces+\N}}
648           set acl_m1 = PTSListBounce
649 '
650 end
651 out
652 %>
653   warn    recipients = change@db.debian.org : changes@db.debian.org : chpasswd@db.debian.org : ping@db.debian.org : recommend@nm.debian.org
654           set acl_m1 = DBSignedMail
655
656 <%=
657 out = ""
658 if has_variable?("greylistd") && greylistd == "true"
659   out = '
660   defer
661     message  = $sender_host_address is not yet authorized to deliver mail from <$sender_address> to <$local_part@$domain>.
662     log_message = greylisted.
663     local_parts    = ${if match_domain{$domain}{+virtual_domains}\
664                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}\
665                      {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}{$local_part}{}}}{}}}\
666                      {${lookup{$local_part}lsearch{/etc/exim4/grey_users}{$local_part}{}} : \
667                      ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-greylist}{$local_part}{}}}}
668     !senders       = :
669     !hosts         = : +debianhosts : WHITELIST : \
670                      ${if exists {/etc/greylistd/whitelist-hosts}\
671                                  {/etc/greylistd/whitelist-hosts}{}} : \
672                      ${if exists {/var/lib/greylistd/whitelist-hosts}\
673                                  {/var/lib/greylistd/whitelist-hosts}{}} 
674     !authenticated = *
675     domains        = +handled_domains : +rcpthosts
676     condition      = ${readsocket{/var/run/greylistd/socket}\
677                                  {--grey \
678                                   $sender_host_address \
679                                   $sender_address \
680                                   $local_part@$domain}\
681                                  {5s}{}{false}}
682 '
683 elsif has_variable?("postgrey") && postgrey == "true"
684   out = '
685   # next three are greylisting, inspired by http://www.bebt.de/blog/debian/archives/2006/07/30/T06_12_27/index.html
686   # this adds acl_m_grey if there isn\'t one (so unique per message)
687   warn
688     !senders       = :
689     !hosts         = : +debianhosts : WHITELIST
690     condition      = ${if def:acl_m_grey {no}{yes}}
691     set acl_m_grey = $pid.$tod_epoch.$sender_host_port
692
693   # and defers the message if postgrey thinks it should be defered ...
694   defer
695     !senders       = :
696     !hosts         = : +debianhosts : WHITELIST
697     !authenticated = *
698     domains        = +handled_domains : +rcpthosts
699     local_parts    = GREYLIST_LOCAL_PARTS
700     set acl_m_pgr  = request=smtpd_access_policy\n\
701                      protocol_state=RCPT\n\
702                      protocol_name=${uc:$received_protocol}\n\
703                      instance=${acl_m_grey}\n\
704                      helo_name=${sender_helo_name}\n\
705                      client_address=${substr_-3:${mask:$sender_host_address/24}}\n\
706                      client_name=${sender_host_name}\n\
707                      sender=${sender_address}\n\
708                      recipient=$local_part@$domain\n\n
709     set acl_m_pgr  = ${sg{\
710                          ${readsocket{/var/run/postgrey/socket}{$acl_m_pgr}\
711                                {5s}{}{action=DUNNO}}\
712                      }{action=}{}}
713     message        = ${sg{$acl_m_pgr}{^\\\\w+\\\\s*}{}}
714     log_message    = greylisted.
715     condition      = ${if eq{${uc:${substr{0}{5}{$acl_m_pgr}}}}{DEFER}}
716
717  # ... or adds a header with information about how long the delay was
718  warn
719     !senders       = :
720     !hosts         = : +debianhosts : WHITELIST
721     !authenticated = *
722     domains        = +handled_domains : +rcpthosts
723     local_parts    = GREYLIST_LOCAL_PARTS
724     condition      = ${if eq{${uc:${substr_0_7:$acl_m_pgr}}}{PREPEND}}
725     message        = ${sg{$acl_m_pgr}{^\\\\w+\\\\s*}{}}
726 '
727 end
728 out
729 %>
730
731   accept  local_parts   = postmaster
732           domains       = +handled_domains : +rcpthosts
733
734   deny   log_message   = <$sender_address> is blacklisted
735          senders       = ${if exists{/etc/exim4/blacklist}{/etc/exim4/blacklist}{}}
736          message       = We have blacklisted <$sender_address>.  Please stop mailing us
737
738   deny    message  = host $sender_host_address is listed in $dnslist_domain; see $dnslist_text
739           dnslists = ${if match_domain{$domain}{+virtual_domains}\
740                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}\
741                      {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}{$value}{}}}{}}}\
742                      {${lookup{$local_part}lsearch{/etc/exim4/rbllist}{$value}{}} : \
743                      ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rbl}{$value}{}}}}
744           domains       = +handled_domains : +rcpthosts
745           !hosts        = +debianhosts : WHITELIST
746
747   deny    message  = domain $sender_address_domain is listed in $dnslist_domain; see $dnslist_text
748           dnslists = ${if match_domain{$domain}{+virtual_domains}\
749                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}\
750                      {${expand:${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}{$value}{}}}}{}}}\
751                      {${expand:${lookup{$local_part}lsearch{/etc/exim4/rhsbllist}{$value}{}}} : \
752                      ${expand:${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rhsbl}{$value}{}}}}}
753           domains       = +handled_domains : +rcpthosts
754           !hosts        = +debianhosts : WHITELIST
755
756   deny    domains  = +handled_domains : +rcpthosts
757           local_parts   = ${if match_domain{$domain}{+virtual_domains}\
758                            {${if exists {${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}\
759                            {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}{$local_part}{}}}{}}}\
760                            {${lookup{$local_part}lsearch{/etc/exim4/callout_users}{$local_part}{}} : \
761                            ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-callout}{$local_part}{}}}}
762           !hosts   = +debianhosts : WHITELIST
763           !verify  = sender/callout
764
765 <%=
766 out = ""
767 if nodeinfo['mailrelay']
768   out = '
769   accept  domains  = +mailhubdomains
770           endpass
771           message  = unknown user
772           verify   = recipient/callout=30s,defer_ok,use_sender,no_cache
773 '
774 end
775 out
776 %>
777   accept  domains  = +handled_domains
778           endpass
779           message  = unknown user
780           verify   = recipient/defer_ok
781
782   accept  domains  = +rcpthosts
783           endpass
784           message  = unrouteable address
785           verify   = recipient
786
787   accept  hosts         = +debianhosts
788
789   accept  authenticated = *
790
791   deny    message = relay not permitted
792
793 <%=
794 out=''
795 if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty?
796 out='
797 acl_check_mime:
798
799   deny   condition     = ${if <{$message_size}{256000}}
800          set acl_m_srb = ${perl{surblspamcheck}}
801          condition     = ${if eq{$acl_m_srb}{false}{no}{yes}}
802          log_message   = $acl_m_srb
803          message       = $acl_m_srb
804
805   accept
806 '
807 end
808 out
809 %>
810
811 acl_check_predata:
812   deny   condition     = ${if eq{$acl_m6}{localonly}}
813          message       = mail for $acl_m7 is only accepted internally
814
815   accept
816
817
818 #!!# ACL that is used after the DATA command
819 check_message:
820   require verify = header_syntax
821           message = Invalid syntax in the header
822
823 <%=
824 out=''
825 if nodeinfo['rtmaster']
826   out='
827   deny    condition = ${if eq {$acl_m1}{RTMail}}
828           condition = ${if and{{!match {${lc:$rh_Subject:}} {debian rt}} \
829                                {!match {${lc:$rh_Subject:]}} {\N\[rt.debian.org \N}} \
830                                {!match {$acl_m12}{RTMailRecipientHasSubaddress}}}}
831           message  = messages to the Request Tracker system require a subject tag or a subaddress
832 '
833 end
834 out
835 %>
836 <%=
837 out=''
838 if nodeinfo['packagesqamaster']
839   out='
840   deny    !hosts  = +debianhosts : 217.196.43.134
841           condition = ${if eq {$acl_m1}{PTSMail}}
842           condition = ${if def:h_X-PTS-Approved:{false}{true}}
843           message   = messages to the PTS require an X-PTS-Approved header
844 '
845 end
846 out
847 %>
848   deny    condition      = ${if match {$message_body}{\Nhttp:\/\/[a-z\.-]+\/video1?.exe\N}}
849           message        = Blackisted URI found in body
850
851   deny    condition      = ${if eq {$acl_m1}{DBSignedMail}}
852           condition      = ${if and {{!match {$message_body}{PGP MESSAGE}}              \
853                                      {!match {$message_body}{PGP SIGNED MESSAGE}}       \
854                                      {!match {$message_body}{PGP SIGNATURE}}            \
855                                      {!match {$header_content-type:}{multipart/signed}} \
856                                      {!match {$header_content-type:}{pgp}}              \
857                                     }                                                   \
858                             }
859           message        = Mail to this address needs to be PGP-signed
860
861 # RFC 822 and 2822 say that headers must be ASCII.  This kinda emulates
862 # postfix's strict_7bit_headers option, but only checks a few common problem
863 # headers, as there doesn't appear to be an easy way to check them all.
864   deny
865           condition       = ${if or {{match {$rh_Subject:}{[\200-\377]}}\
866                                  {match {$rh_To:}{[\200-\377]}}\
867                                  {match {$rh_From:}{[\200-\377]}}\
868                                  {match {$rh_Cc:}{[\200-\377]}}}{true}{false}}
869           message         = improper use of 8-bit data in message header: message rejected
870
871   deny
872           condition       = ${if match {$rh_Subject:}{[^[:print:]]\{8\}}{true}{false}}
873           message         = Your mailer is not RFC 2047 compliant: message rejected
874
875 <%=
876 out = ""
877 if has_variable?("clamd") && clamd == "true"
878 out = '
879   deny    
880           demime          = *
881           malware         = */defer_ok
882           message         = malware detected: $malware_name: message rejected
883 '
884 end
885 out
886 %>
887 <%=
888 out=''
889 if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty?
890 out='
891   deny   condition     = ${if <{$message_size}{256000}}
892          set acl_m_srb = ${perl{surblspamcheck}}
893          condition     = ${if eq{$acl_m_srb}{false}{no}{yes}}
894          log_message   = $acl_m_srb
895          message       = $acl_m_srb
896 '
897 end
898 out
899 %>
900   # Check header_sender except for survey@popcon.d.o
901   deny    condition = ${if eq{$acl_m1}{PopconMail}{false}{true}}
902           !verify = header_sender
903           message = No valid sender found in the From:, Sender: and Reply-to: headers
904
905   accept
906
907
908
909 ######################################################################
910 #                      REWRITE CONFIGURATION                         #
911 ######################################################################
912
913
914
915 begin rewrite
916
917 \N^buildd_(.*)@ries\.debian\.org$\N buildd_$1@buildd.debian.org T
918 \N^buildd_(.*)@klecker\.debian\.org$\N buildd_$1@buildd.debian.org T
919 *@debian.org ${lookup{$1}cdb{/var/lib/misc/${primary_hostname}/mail-forward.cdb}{$value}fail} T
920 *@people.debian.org ${lookup{$1}cdb{/var/lib/misc/${primary_hostname}/mail-forward.cdb}{$value}fail} T
921 #*@${primary_hostname} "${if exists{/etc/exim4/email-addresses}{${lookup{$1}lsearch{/etc/exim4/email-addresses}{$value}fail}}fail}" fFs
922 m68k@buildd.debian.org m68k-build@nocrew.org Ttrbc
923
924
925 #!!#######################################################!!#
926 #!!# Here follow routers created from the old routers,   #!!#
927 #!!# for handling non-local domains.                     #!!#
928 #!!#######################################################!!#
929
930 begin routers
931
932
933
934 ######################################################################
935 #                      ROUTERS CONFIGURATION                         #
936 #                Specifies how addresses are handled                 #
937 ######################################################################
938 #                          ORDER DOES MATTER                         #
939 #     An address is passed to each in turn until it is accepted.     #
940 ######################################################################
941
942 <%=
943 out = ""
944 if nodeinfo['mailrelay']
945   out = '
946 relay_manualroute:
947   driver = manualroute
948   domains = +mailhubdomains
949   transport = remote_smtp
950   route_data = ${lookup{$domain}lsearch{/etc/exim4/manualroute}}
951   require_files = /etc/exim4/manualroute
952 '
953 end
954 out
955 %>
956
957 bsmtp:
958   debug_print = "R: bsmtp for $local_part@$domain"
959   driver = manualroute
960   domains = !+local_domains
961   require_files = /etc/exim4/bsmtp
962   route_list = * ${extract{file}{\
963                    ${lookup{$domain}partial-lsearch{/etc/exim4/bsmtp}\
964                      {$value}fail}}}
965   transport = bsmtp
966
967 # This router routes to remote hosts over SMTP by explicit IP address,
968 # given as a "domain literal" in the form [nnn.nnn.nnn.nnn]. The RFCs
969 # require this facility, which is why it is enabled by default in Exim.
970 ipliteral:
971   debug_print = "R: ipliteral for $local_part@$domain"
972   driver = ipliteral
973   domains = !+handled_domains
974   transport = remote_smtp
975   ignore_target_hosts = +reservedaddrs
976
977 <%=
978 out = ""
979 if not nodeinfo['smarthost'].empty?
980 out = '
981 smarthost:
982   debug_print = "R: smarthost for $local_part@$domain"
983   driver = manualroute
984   domains = !+handled_domains
985   transport = remote_smtp_smarthost
986   route_list = * ' + nodeinfo['smarthost'] + '
987   host_find_failed = defer
988   same_domain_copy_routing = yes
989   no_more
990 '
991 end
992 out
993 %>
994
995 # This router routes to remote hosts over SMTP using a DNS lookup.
996 # Ignore reserved network responses, including localhost.
997 dnslookup:
998   debug_print = "R: dnslookup for $local_part@$domain"
999   driver = dnslookup
1000   domains = !+handled_domains
1001   transport = remote_smtp
1002   ignore_target_hosts = +reservedaddrs
1003   no_more
1004
1005 # This router handles aliasing using a traditional /etc/aliases file.
1006 # If any of your aliases expand to pipes or files, you will need to set
1007 # up a user and a group for these deliveries to run under. You can do
1008 # this by uncommenting the "user" option below (changing the user name
1009 # as appropriate) and adding a "group" option if necessary.
1010
1011 system_aliases:
1012   debug_print = "R: system_aliases for $local_part@$domain"
1013   driver = redirect
1014   allow_defer
1015   allow_fail
1016   data = ${lookup{$local_part}lsearch*{/etc/aliases}}
1017   domains = +local_domains
1018   file_transport = address_file
1019   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1020   pipe_transport = address_pipe
1021   retry_use_local_part
1022
1023 # This router handles forwarding using traditional .forward files.
1024 # It also allows mail filtering when a forward file starts with the 
1025 # string "# Exim filter": to disable filtering, uncomment the "filter" 
1026 # option. The check_ancestor option means that if the forward file 
1027 # generates an address that is an ancestor of the current one, the 
1028 # current one gets passed on instead. This covers the case where A is 
1029 # aliased to B and B has a .forward file pointing to A.
1030
1031 # For standard debian setup of one group per user, it is acceptable---normal
1032 # even---for .forward to be group writable. If you have everyone in one
1033 # group, you should comment out the "modemask" line. Without it, the exim
1034 # default of 022 will apply, which is probably what you want.
1035
1036 userforward_verify:
1037   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
1038   driver = redirect
1039   check_ancestor
1040   user = Debian-exim
1041   no_check_local_user
1042   directory_transport = address_directory
1043   domains = +local_domains
1044   # filter - I have disabled filtering to force users to use .forward-foo files
1045   # or procmail. This will make it easier to move mailers in the future
1046   #
1047   # This bit does the qmailesque extension names, foo-bar@ is .forward-foo it
1048   # also checks if the .forward-bar exists, if not then it uses
1049   # .forward-default instead.
1050   file = $home/.forward\
1051          ${if eq{}{$local_part_suffix}{}{\
1052            ${if exists {${home}/.forward${local_part_suffix}} \
1053              {${local_part_suffix}}{-default}}\
1054            }\
1055           }
1056   file_transport = address_file
1057   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1058   local_part_suffix = -*
1059   local_part_suffix_optional
1060   modemask = 002
1061   pipe_transport = address_pipe
1062   reply_transport = address_reply
1063   require_files = $home
1064   router_home_directory = ${lookup passwd{$local_part}{${extract{5}{:}{$value}}}fail}
1065   verify_only
1066
1067 userforward:
1068   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
1069   driver = redirect
1070   check_ancestor
1071   check_local_user
1072   directory_transport = address_directory
1073   domains = +local_domains
1074   # filter - I have disabled filtering to force users to use .forward-foo files
1075   # or procmail. This will make it easier to move mailers in the future
1076   #
1077   # This bit does the qmailesque extension names, foo-bar@ is .forward-foo it
1078   # also checks if the .forward-bar exists, if not then it uses
1079   # .forward-default instead.
1080   file = $home/.forward\
1081          ${if eq{}{$local_part_suffix}{}{\
1082            ${if exists {${home}/.forward${local_part_suffix}} \
1083              {${local_part_suffix}}{-default}}\
1084            }\
1085           }
1086   file_transport = address_file
1087   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1088   local_part_suffix = -*
1089   local_part_suffix_optional
1090   modemask = 002
1091   pipe_transport = address_pipe
1092   reply_transport = address_reply
1093   require_files = $home
1094   no_verify
1095
1096 # This delivers to procmail
1097 procmail:
1098   debug_print = "R: procmail for $local_part@$domain"
1099   driver = accept
1100   check_local_user
1101   domains = +local_domains
1102   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1103   no_verify
1104   no_expn
1105   require_files = $local_part:$home/.procmailrc
1106   transport = procmail_pipe
1107   transport_current_directory = $home
1108   
1109 # This driver delivers to the LDAP generated alias file.
1110 ldap_aliases:
1111   debug_print = "R: ldap_aliases for $local_part@$domain"
1112   driver = redirect
1113   allow_defer
1114   allow_fail
1115   data = ${if exists{/var/lib/misc/$primary_hostname/mail-forward.cdb}\
1116              {${lookup{$local_part}cdb\
1117                {/var/lib/misc/$primary_hostname/mail-forward.cdb}}}}
1118   domains = +local_domains
1119   file_transport = address_file
1120   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1121   pipe_transport = address_pipe
1122   retry_use_local_part
1123   
1124 # This director matches local user mailboxes.
1125 localuser:
1126   debug_print = "R: localuser for $local_part@$domain"
1127   driver = accept
1128   check_local_user
1129   domains = +local_domains
1130   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1131   # Disable if the user has never logged in
1132   require_files = $home
1133   transport = local_delivery
1134   no_more
1135
1136 # Now we begin the Virtual Domain configuration
1137 # Everything before here should apply only to the local domains with a 
1138 # domains= rule
1139
1140 # exim4 fails the router if it can't change to the user/group for delivery
1141 # during verification.  So we have to seperate the cases of verifying
1142 # the virts, and delivering to them.  blah.
1143 <%=
1144 out = ""
1145 if nodeinfo['packagesmaster']
1146   out = '
1147 # This router delivers for packages.d.o
1148 packages:
1149   debug_print = "R: packages for $local_part@$domain"
1150   driver = redirect
1151   file_transport = address_file
1152   pipe_transport = address_pipe
1153   domains = packages.debian.org
1154   require_files = /org/packages.debian.org/conf/maintainer
1155   data = ${lookup{$local_part}cdb{/org/packages.debian.org/conf/maintainer.cdb}}
1156   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1157   transport_home_directory = /org/packages.debian.org/mail
1158   transport_current_directory = /org/packages.debian.org/mail
1159   check_ancestor
1160   retry_use_local_part
1161   no_more
1162 '
1163 end
1164 out
1165 %>
1166
1167 <%=
1168 out = ""
1169 if nodeinfo['bugsmaster']
1170   out = '
1171 # This router delivers for bugs.d.o
1172 bugs:
1173   debug_print = "R: bugs for $local_part@$domain"
1174   driver = accept
1175   transport = bugs_pipe
1176   domains = bugs.debian.org
1177   cannot_route_message = Unknown or archived bug
1178   require_files = /org/bugs.debian.org/mail/run-procmail
1179   no_more
1180   local_parts = ${if match\
1181                   {$local_part}\
1182                   {\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}\
1183                {${if exists{/org/bugs.debian.org/spool/db-h/$2/$1$2.summary}\
1184                {$local_part}fail}}fail}
1185 '
1186 end
1187 out
1188 %>
1189
1190 <%=
1191 out = ""
1192 if nodeinfo['rtmaster']
1193   out = '
1194 # This router delivers for rt.d.o
1195 rt_force_new_verbose:
1196   debug_print = "R: rt for $local_part+new@$domain"
1197   driver = redirect
1198   domains = rt.debian.org
1199   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1200   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1201   local_part_suffix = +new
1202   pipe_transport = rt_pipe
1203   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}}"
1204   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1205
1206 # FIXME: figure out how to generalize this approach so that all of the following would work
1207 # - rt+NNNN@rt.debian.org          : attach correspondence to ticket (verbose)
1208 # - rt+NNNN-quiesce@rt.debian.org  : attach correspondence to ticket (quiesce)
1209 # - rt+NNNN-<action>@rt.debian.org : attach correspondence to ticket (some action)
1210 # requires modification to custom condition in \'scrips\'
1211 rt_force_new_quiesce:
1212   debug_print = "R: rt for $local_part+new-quiesce@$domain"
1213   driver = redirect
1214   domains = rt.debian.org
1215   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1216   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1217   local_part_suffix = +new-quiesce
1218   pipe_transport = rt_pipe
1219   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}}"
1220   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nX-RT-Mode: quiesce"
1221
1222 rt_otherwise:
1223   debug_print = "R: rt for $local_part@$domain"
1224   driver = redirect
1225   domains = rt.debian.org
1226   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1227   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1228   local_part_suffix = +*
1229   local_part_suffix_optional
1230   pipe_transport = rt_pipe
1231   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}}"
1232   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1233 '
1234 end
1235 out
1236 %>
1237
1238 virt_alias_verify:
1239   debug_print = "R: virt_aliases for $local_part@$domain"
1240   driver = redirect
1241   data = ${if exists{\
1242            ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
1243            {${lookup{$local_part}lsearch*{\
1244               ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
1245            }}}}
1246   directory_transport = address_directory
1247   cannot_route_message = Unknown user
1248   domains = +virtual_domains
1249   file_transport = address_file
1250   pipe_transport = address_pipe
1251   qualify_preserve_domain
1252   retry_use_local_part
1253   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1254   transport_home_directory = ${extract{directory}{VDOMAINDATA}}
1255   verify_only
1256
1257 virt_direct_verify:
1258   debug_print = "R: virt_direct for $local_part@$domain"
1259   driver = redirect
1260   no_check_local_user
1261   user = Debian-exim
1262   allow_filter
1263   modemask = 002
1264   directory_transport = address_directory
1265   domains = +virtual_domains
1266   file = $home/.forward-\
1267               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
1268                    {default}}
1269   file_transport = address_file
1270   pipe_transport = address_pipe
1271   reply_transport = address_reply
1272   retry_use_local_part
1273   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1274   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1275   verify_only
1276
1277 # This is a senmailesque alias file lookup
1278 virt_aliases:
1279   debug_print = "R: virt_aliases for $local_part@$domain"
1280   driver = redirect
1281   allow_defer
1282   allow_fail
1283   data = ${if exists{\
1284            ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
1285            {${lookup{$local_part}lsearch*{\
1286               ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
1287            }}}}
1288   directory_transport = address_directory
1289   domains = +virtual_domains
1290   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1291   cannot_route_message = Unknown user
1292   group = ${extract{group}{VDOMAINDATA}}
1293   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1294   pipe_transport = address_pipe
1295   qualify_preserve_domain
1296   retry_use_local_part
1297   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1298   transport_home_directory = ${extract{directory}{VDOMAINDATA}}
1299   no_verify
1300   user = ${extract{user}{VDOMAINDATA}}
1301   
1302 # This is a qmailesque deliver into a directory of .forward files
1303 virt_direct:
1304   debug_print = "R: virt_direct for $local_part@$domain"
1305   driver = redirect
1306   allow_filter
1307   allow_fail
1308   allow_defer
1309   no_check_local_user
1310   directory_transport = address_directory
1311   domains = +virtual_domains
1312   file = $home/.forward-\
1313               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
1314                    {default}}
1315   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1316   group = ${extract{group}{VDOMAINDATA}}
1317   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1318   modemask = 002
1319   pipe_transport = address_pipe
1320   reply_transport = address_reply
1321   retry_use_local_part
1322   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1323   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1324   no_verify
1325   user = ${extract{user}{VDOMAINDATA}}
1326   #debug_print = .forward-${if exists {${home}/.forward-${local_part}} {${local_part}} {default}}
1327
1328 ######################################################################
1329 #                      TRANSPORTS CONFIGURATION                      #
1330 ######################################################################
1331 #                       ORDER DOES NOT MATTER                        #
1332 #     Only one appropriate transport is called for each delivery.    #
1333 ######################################################################
1334
1335
1336 begin transports
1337
1338 # This transport is used for local delivery to user mailboxes. On debian
1339 # systems group mail is used so we can write to the /var/mail
1340 # directory. (The alternative, which most other unixes use, is to deliver
1341 # as the user's own group, into a sticky-bitted directory)
1342 local_delivery:
1343   driver = appendfile
1344   file = /var/mail/${local_part}
1345   group = mail
1346   mode = 0660
1347   no_mode_fail_narrower
1348   return_path_add
1349   
1350 # This transport is used for handling pipe addresses generated by alias
1351 # or .forward files. It has a conventional name, since it is not actually
1352 # mentioned elsewhere in this configuration file. (A different name *can*
1353 # be specified via the "address_pipe_transport" option if you really want
1354 # to.) If the pipe generates any standard output, it is returned to the sender
1355 # of the message as a delivery error. Set return_fail_output instead if you
1356 # want this to happen only when the pipe fails to complete normally.
1357
1358 address_pipe:
1359   driver = pipe
1360   current_directory = ${home}
1361   environment = "EXTENSION=${substr_1:${local_part_suffix}}:\
1362                  EXT=${substr_1:${local_part_suffix}}:\
1363                  LOCAL=${local_part}${local_part_suffix}:\
1364                  RECIPIENT=${local_part}${local_part_suffix}@${domain}"
1365   return_output
1366   return_path_add
1367
1368 # This transport is used for handling file addresses generated by alias
1369 # or .forward files. It has a conventional name, since it is not actually
1370 # mentioned elsewhere in this configuration file.
1371
1372 address_file:
1373   driver = appendfile
1374   return_path_add
1375
1376 address_file_group:
1377   driver = appendfile
1378   return_path_add
1379   mode = 0660
1380   directory_mode = 0770
1381   mode_fail_narrower = false
1382
1383 # This transport is used for handling file addresses generated by alias
1384 # or .forward files if the path ends in "/", which causes it to be treated
1385 # as a directory name rather than a file name. Each message is then delivered
1386 # to a unique file in the directory. If instead you want all such deliveries to
1387 # be in the "maildir" format that is used by some other mail software,
1388 # uncomment the final option below. If this is done, the directory specified
1389 # in the .forward or alias file is the base maildir directory.
1390 #
1391 # Should you want to be able to specify either maildir or non-maildir
1392 # directory-style deliveries, then you must set up yet another transport,
1393 # called address_directory2. This is used if the path ends in "//" so should
1394 # be the one used for maildir, as the double slash suggests another level
1395 # of directory. In the absence of address_directory2, paths ending in //
1396 # are passed to address_directory.
1397
1398 address_directory:
1399   driver = appendfile
1400   check_string = 
1401   maildir_format
1402   message_prefix = ""
1403   message_suffix = ""
1404   return_path_add
1405
1406 # This transport is used for handling autoreplies generated by the filtering
1407 # option of the forwardfile director. It has a conventional name, since it
1408 # is not actually mentioned elsewhere in this configuration file.
1409 address_reply:
1410   driver = autoreply
1411
1412 # This transport is used for delivering messages over SMTP connections.
1413
1414 remote_smtp:
1415   driver = smtp
1416   connect_timeout = 1m
1417   delay_after_cutoff = false
1418 <%=
1419 out = ""
1420 if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true"
1421   out = "  tls_certificate = /etc/exim4/ssl/thishost.crt
1422   tls_privatekey = /etc/exim4/ssl/thishost.key"
1423 end
1424 out
1425 %>
1426
1427 <%=
1428 out = ""
1429 if not nodeinfo['smarthost'].empty?
1430 out = '
1431 remote_smtp_smarthost:
1432   debug_print = "T: remote_smtp_smarthost for $local_part@$domain"
1433   driver = smtp
1434   delay_after_cutoff = false
1435   port = '
1436   out += nodeinfo['smarthost_port'].to_s + "\n"
1437   if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true"
1438     out += '  tls_tempfail_tryclear = false
1439   hosts_require_tls = ' + nodeinfo['smarthost'] + '
1440   tls_certificate = /etc/exim4/ssl/thishost.crt
1441   tls_privatekey = /etc/exim4/ssl/thishost.key
1442 '
1443   end
1444 end
1445 out
1446 %>
1447
1448 # Send the message to procmail
1449 procmail_pipe:
1450   driver = pipe
1451   command = /usr/bin/procmail -a ${substr_1:${local_part_suffix}}}
1452   return_path_add
1453   user = ${local_part}
1454
1455 bsmtp:
1456   driver = appendfile
1457   batch_max = 100
1458   file = ${host}
1459   message_prefix = 
1460   message_suffix = 
1461   use_bsmtp
1462   user = ${extract{user}{\
1463                    ${lookup{$domain}partial-lsearch{/etc/exim4/bsmtp}\
1464                      {$value}fail}\
1465                    }}
1466
1467 <%=
1468 out = ""
1469 if nodeinfo['bugsmaster']
1470   out = '
1471 bugs_pipe:
1472   driver = pipe
1473   command = /org/bugs.debian.org/mail/run-procmail
1474   environment = "EXTENSION=${substr_1:${local_part_suffix}}:\
1475                  EXT=${substr_1:${local_part_suffix}}:\
1476                  LOCAL=${local_part}${local_part_suffix}:\
1477                  RECIPIENT=${local_part}${local_part_suffix}@${domain}"
1478   return_path_add
1479   return_output
1480   user = debbugs
1481 '
1482 end
1483 out
1484 %>
1485
1486 <%=
1487 out = ""
1488 if nodeinfo['rtmaster']
1489   out = '
1490 rt_pipe:
1491   debug_print = "T: rt_pipe for $local_part${local_part_suffix}@$domain"
1492   driver = pipe
1493   return_fail_output
1494   environment = EXTENSION=${substr_1:${local_part_suffix}}
1495   allow_commands = /usr/bin/rt-mailgate
1496 '
1497 end
1498 out
1499 %>
1500
1501 ######################################################################
1502 #                      RETRY CONFIGURATION                           #
1503 ######################################################################
1504
1505 # This single retry rule applies to all domains and all errors. It specifies
1506 # retries every 15 minutes for 2 hours, then increasing retry intervals,
1507 # starting at 2 hours and increasing each time by a factor of 1.5, up to 16
1508 # hours, then retries every 8 hours until 4 days have passed since the first
1509 # failed delivery.
1510
1511 # Domain               Error       Retries
1512 # ------               -----       -------
1513
1514
1515 begin retry
1516
1517 debian.org             *           F,2h,10m; G,16h,2h,1.5; F,14d,8h
1518 *                      * senders=: F,2h,10m
1519 *                      rcpt_4xx    F,2h,5m;  F,4h,10m; F,4d,15m
1520 *                      *           F,2h,15m; G,16h,2h,1.5; F,4d,8h
1521
1522 # End of Exim 4 configuration