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