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