Revert "And another acl for exim"+1
[mirror/dsa-puppet.git] / modules / exim / templates / eximconf.erb
1 ##
2 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
3 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
4 ##
5
6 # This is the main exim4 configuration file based on the 28.08.05 version by
7 # ametzler
8
9 # The configuration file uses a set of rules to generate an
10 # acceptable mail environment for debian.org machines. It deviates
11 # considerably from what could be considered a standard exim configuration.
12
13 # This configuration file brings in the necessary information from
14 # other databases stored in /etc/exim/ and the files distributed by ud-ldap
15
16 # This file is independent of the local host, it should not be changed
17 # per machine. primary_hostname is used in all places that require per-host 
18 # settings.
19
20 # The configuration files in /etc/exim are as follows:
21 #  locals - This is a list of domains that are considered local. A local
22 #           domain is essential one that deliveries to /var/mail
23 #           will be attempted. The users available for local delivery
24 #           comes from /etc/passwd and /etc/aliases. Wildcards are not
25 #           permitted.
26 #  virtualdomains - This is a list of all virtual domains. A virtual domain
27 #           is much like a local domain, execpt that the delivery location
28 #           and allowed set of users is controlled by a virtual domain
29 #           alias file and not /etc/passwd. Wildcards are permitted
30 #  rcpthosts - recipient hosts or relay domains. This is a list of
31 #           all hosts that we mail exchange for. All domains that list
32 #           this host in their MX records should be listed here. Wildcards
33 #           are permitted.
34 #  relayhosts - Hostnames that can send any arbitarily addressed mail to
35 #           us. This is primarily only usefull for emergancy 'queue
36 #           flushing' operations, but should be populated with a list
37 #           of trusted machines. Wildcards are not permitted
38 <%=
39 out = ""
40 if nodeinfo['mailrelay']
41   out = '
42 #  mailhubdomains - Domains for which we are the MX, but the mail is relayed
43 #           elsewhere.  This is designed for use with small volume or
44 #           restricted machines that need to use a smarthost for mail
45 #           traffic.  We will relay for them based on ssl cert validation
46 #           but we need to teach exim how to route the mail to them.  This is
47 #           that list.
48 '
49 end
50 out
51 %>
52 # Exim's wildcard mechanism is a bit odd in that to say "any address in
53 # debian.org including debian.org" you must use two patterns,
54 #   *.debian.org
55 #   debian.org
56 # Also you can only place a * before a . and as the first char in a string.
57 # Wildcards always match last so they may be used as a catchall.
58
59 # Further details can be found in each of the files.
60
61 # Usefull exim commands:
62 #  exim4 -qf  - Try sending all messages right now, including frozen ones
63 #  exim4 -bt foo@blah - Write what exim would do if it saw the address
64 #                      Great for testing virtual domains and forward files
65
66 # Special Features for users:
67 # .forward-foo - is understood as an extension address for bar-foo@cow.com
68 # .forward-default - is understood to be a catch all for bar-*@cow.com
69 # .procmailrc - with no .forward file invokes procmail for delivery
70 #               automatically.
71
72 # For virtual domains the first lookup is done against a linear text
73 # database called 'aliases', then .forward files are consulted. Exim
74 # filtering is available for these .forward files only. .forward-default
75 # is the universal catch all for everything not handled.
76
77 # Heuristic check (none bad enough to cause a hard reject, but in aggregate
78 # will trigger things like rcpt to rate limiting or possibly a reject if
79 # enough hits are triggered.
80 #
81 # value is stored in acl_c1
82
83 ######################################################################
84 #                    MAIN CONFIGURATION SETTINGS                     #
85 ######################################################################
86
87 <%=
88 out=''
89 if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty?
90   out = "
91 perl_startup = do '/etc/exim4/exim_surbl.pl'
92 "
93 end
94 out
95 %>
96
97 # These options specify the Access Control Lists (ACLs) that
98 # are used for incoming SMTP messages - after the RCPT and DATA
99 # commands, respectively.
100
101 acl_smtp_helo = check_helo
102 acl_smtp_rcpt = ${if ={$interface_port}{587} {check_submission}{check_recipient}}
103 acl_smtp_data = check_message
104
105 # 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 <%=
515 out=''
516 if 0 == 1:
517 out='
518   deny    message  = address $sender_host_address is listed in $dnslist_domain; $dnslist_text
519           hosts    = !+debianhosts
520           dnslists = rbl.debian.net : rbl.debian.net/$sender_address_domain
521 '
522 end
523 out
524 %>
525
526   deny    !recipients = survey@popcon.debian.org
527           !verify = sender
528
529   defer   !hosts         = +debianhosts
530           condition      = ${if >{${eval:$acl_c1}}{0}}
531           ratelimit      = 10 / 60m / per_rcpt / $sender_host_address
532           message        = slow down (no reverse dns, mismatched ehlo, dialup, or in blacklists)
533 <%=
534 out = ""
535 if has_variable?("policydweight") && policydweight == "true"
536 out = '
537   # Check with policyd-weight - this only works with a version after etch\'s,
538   # sadly.  etch\'s version attempts to hold the socket open, since that\'s what
539   # postfix expects.  Exim, on the other hand, expects the remote side to close
540   # the socket when it\'s finished sending data, so it see each transaction as
541   # an incomplete read.  I\'m sure there\'s a way we could force exim to do
542   # something sick and clever to force either the interpretation or the socket
543   # closure, but I\'m fairly sure it\'s now worth it, since the backport of
544   # policyd-weight is trivial.
545   warn  !hosts         = +debianhosts
546         set acl_m9     = ${readsocket{inet:127.0.0.1:12525}\
547                           {request=smtpd_access_policy\n\
548                            protocol_state=RCPT\n\
549                            protocol_name=${uc:$received_protocol}\n\
550                            helo_name=$sender_helo_name\n\
551                            queue_id=$message_exim_id\n\
552                            sender=$sender_address\n\
553                            recipient=$local_part@$domain\n\
554                            recipient_count=$rcpt_count\n\
555                            client_address=$sender_host_address\n\
556                            client_name=$sender_host_name\n\
557                            reverse_client_name=$sender_host_name\n\
558                            instance=$sender_host_address.$sender_address.$sender_helo_name\n\n}\
559                           {20s}{\n}{socket failure}}
560
561   # Defer on socket error
562   defer !hosts         = +debianhosts
563         condition      = ${if eq{$acl_m9}{socket failure}{yes}{no}}
564         message        = Cannot connect to policyd-weight. Please try again later.
565
566   # Set proposed action to $acl_m8 and message to $acl_m7
567   warn  !hosts         = +debianhosts
568         set acl_m8     = ${extract{action}{$acl_m9}}
569         set acl_m7     = ${sg{$acl_m9}{\Naction=[^ ]+ (.*)\n\n\N}{\$1}}
570
571   # Add X-policyd-weight header line to message
572   warn  !hosts         = +debianhosts
573         message        = $acl_m7
574         condition      = ${if eq{$acl_m8}{PREPEND}{yes}{no}}
575
576   # Write log message, if policyd-weight can\'t run checks
577   warn  !hosts         = +debianhosts
578         log_message    = policyd-weight message: $acl_m7
579         condition      = ${if eq{$acl_m8}{DUNNO}{yes}{no}}
580
581   # Deny mails which policyd-weight thinks are spam
582   deny  !hosts         = +debianhosts
583         message        = policyd-weight said: $acl_m7
584         condition      = ${if eq{$acl_m8}{550}{yes}{no}}
585
586   # Defer messages when policyd-weight suggests so.
587   defer  !hosts         = +debianhosts
588          message        = policyd-weight said: $acl_m7
589          condition      = ${if eq{$acl_m8}{450}{yes}{no}}
590 '
591 end
592 out
593 %>
594   warn    recipients = survey@popcon.debian.org
595           set acl_m1 = PopconMail
596
597 <%=
598 out=''
599 if nodeinfo['rtmaster']
600   out='
601   warn    domains  = rt.debian.org
602           set acl_m1 = RTMail
603           set acl_m12 = ${if def:acl_m12 {$acl_m12} {${if or{{match{$local_part}{[^+]+\\+\\d+}}{match{$local_part}{[^+]+\\+new}}} {RTMailRecipientHasSubaddress}}}}
604 '
605 end
606 out
607 %>
608 <%=
609 out=''
610 if nodeinfo['packagesmaster']
611   out='
612   warn    domains  = packages.qa.debian.org
613           set acl_m1 = PTSMail
614
615   warn    recipients = owner@packages.qa.debian.org : postmaster@packages.qa.debian.org
616           set acl_m1 = PTSOwner
617
618   warn    senders  = :
619           domains  = packages.qa.debian.org
620           condition = ${if match{$local_part}{\N^bounces+\N}}
621           set acl_m1 = PTSListBounce
622 '
623 end
624 out
625 %>
626   warn    recipients = change@db.debian.org : changes@db.debian.org : chpasswd@db.debian.org : ping@db.debian.org : recommend@nm.debian.org
627           set acl_m1 = DBSignedMail
628
629 <%=
630 out = ""
631 if has_variable?("greylistd") && greylistd == "true"
632   out = '
633   defer
634     message  = $sender_host_address is not yet authorized to deliver mail from <$sender_address> to <$local_part@$domain>.
635     log_message = greylisted.
636     local_parts    = ${if match_domain{$domain}{+virtual_domains}\
637                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}\
638                      {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}{$local_part}{}}}{}}}\
639                      {${lookup{$local_part}lsearch{/etc/exim4/grey_users}{$local_part}{}} : \
640                      ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-greylist}{$local_part}{}}}}
641     !senders       = :
642     !hosts         = : +debianhosts : WHITELIST : \
643                      ${if exists {/etc/greylistd/whitelist-hosts}\
644                                  {/etc/greylistd/whitelist-hosts}{}} : \
645                      ${if exists {/var/lib/greylistd/whitelist-hosts}\
646                                  {/var/lib/greylistd/whitelist-hosts}{}} 
647     !authenticated = *
648     domains        = +handled_domains : +rcpthosts
649     condition      = ${readsocket{/var/run/greylistd/socket}\
650                                  {--grey \
651                                   $sender_host_address \
652                                   $sender_address \
653                                   $local_part@$domain}\
654                                  {5s}{}{false}}
655 '
656 elsif has_variable?("postgrey") && postgrey == "true"
657   out = '
658   # next three are greylisting, inspired by http://www.bebt.de/blog/debian/archives/2006/07/30/T06_12_27/index.html
659   # this adds acl_m4 if there isn\'t one (so unique per message)
660   warn
661     !senders       = :
662     !hosts         = : +debianhosts : WHITELIST
663     condition      = ${if def:acl_m4 {no}{yes}}
664     set acl_m4     = $pid.$tod_epoch.$sender_host_port
665
666   # and defers the message if postgrey thinks it should be defered ...
667   defer
668     !senders       = :
669     !hosts         = : +debianhosts : WHITELIST
670     !authenticated = *
671     domains        = +handled_domains : +rcpthosts
672     local_parts    = GREYLIST_LOCAL_PARTS
673     set acl_m3     = request=smtpd_access_policy\n\
674                      protocol_state=RCPT\n\
675                      protocol_name=${uc:$received_protocol}\n\
676                      instance=${acl_m4}\n\
677                      helo_name=${sender_helo_name}\n\
678                      client_address=${substr_-3:${mask:$sender_host_address/24}}\n\
679                      client_name=${sender_host_name}\n\
680                      sender=${sender_address}\n\
681                      recipient=$local_part@$domain\n\n
682     set acl_m3     = ${sg{\
683                          ${readsocket{/var/run/postgrey/socket}{$acl_m3}\
684                                {5s}{}{action=DUNNO}}\
685                      }{action=}{}}
686     message        = ${sg{$acl_m3}{^\\\\w+\\\\s*}{}}
687     log_message    = greylisted.
688     condition      = ${if eq{${uc:${substr{0}{5}{$acl_m3}}}}{DEFER}}
689
690  # ... or adds a header with information about how long the delay was
691  warn
692     !senders       = :
693     !hosts         = : +debianhosts : WHITELIST
694     !authenticated = *
695     domains        = +handled_domains : +rcpthosts
696     local_parts    = GREYLIST_LOCAL_PARTS
697     condition      = ${if eq{${uc:${substr_0_7:$acl_m3}}}{PREPEND}}
698     message        = ${sg{$acl_m3}{^\\\\w+\\\\s*}{}}
699 '
700 end
701 out
702 %>
703
704   accept  local_parts   = postmaster
705           domains       = +handled_domains : +rcpthosts
706
707   deny   log_message   = <$sender_address> is blacklisted
708          senders       = ${if exists{/etc/exim4/blacklist}{/etc/exim4/blacklist}{}}
709          message       = We have blacklisted <$sender_address>.  Please stop mailing us
710
711   deny    message  = host $sender_host_address is listed in $dnslist_domain; see $dnslist_text
712           dnslists = ${if match_domain{$domain}{+virtual_domains}\
713                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}\
714                      {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}{$value}{}}}{}}}\
715                      {${lookup{$local_part}lsearch{/etc/exim4/rbllist}{$value}{}} : \
716                      ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rbl}{$value}{}}}}
717           domains       = +handled_domains : +rcpthosts
718           !hosts        = +debianhosts : WHITELIST
719
720   deny    message  = domain $sender_address_domain is listed in $dnslist_domain; see $dnslist_text
721           dnslists = ${if match_domain{$domain}{+virtual_domains}\
722                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}\
723                      {${expand:${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}{$value}{}}}}{}}}\
724                      {${expand:${lookup{$local_part}lsearch{/etc/exim4/rhsbllist}{$value}{}}} : \
725                      ${expand:${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rhsbl}{$value}{}}}}}
726           domains       = +handled_domains : +rcpthosts
727           !hosts        = +debianhosts : WHITELIST
728
729   deny    domains  = +handled_domains : +rcpthosts
730           local_parts   = ${if match_domain{$domain}{+virtual_domains}\
731                            {${if exists {${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}\
732                            {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}{$local_part}{}}}{}}}\
733                            {${lookup{$local_part}lsearch{/etc/exim4/callout_users}{$local_part}{}} : \
734                            ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-callout}{$local_part}{}}}}
735           !hosts   = +debianhosts : WHITELIST
736           !verify  = sender/callout
737
738 <%=
739 out = ""
740 if nodeinfo['mailrelay']
741   out = '
742   accept  domains  = +mailhubdomains
743           endpass
744           message  = unknown user
745           verify   = recipient/callout=30s,defer_ok,use_sender,no_cache
746 '
747 end
748 out
749 %>
750   accept  domains  = +handled_domains
751           endpass
752           message  = unknown user
753           verify   = recipient/defer_ok
754
755   accept  domains  = +rcpthosts
756           endpass
757           message  = unrouteable address
758           verify   = recipient
759
760   accept  hosts         = +debianhosts
761
762   accept  authenticated = *
763
764   deny    message = relay not permitted
765
766 #!!# ACL that is used after the DATA command
767 check_message:
768   require verify = header_syntax
769           message = Invalid syntax in the header
770
771 <%=
772 out=''
773 if nodeinfo['rtmaster']
774   out='
775   deny    condition = ${if eq {$acl_m1}{RTMail}}
776           condition = ${if and{{!match {${lc:$rh_Subject:}} {debian rt}} \
777                                {!match {${lc:$rh_Subject:]}} {\\[rt.debian.org }} \
778                                {!match {$acl_m12}{RTMailRecipientHasSubaddress}}}}
779           message  = messages to the Request Tracker system require a subject tag or a subaddress
780 '
781 end
782 out
783 %>
784 <%=
785 out=''
786 if nodeinfo['packagesmaster']
787   out='
788   deny    !hosts  = +debianhosts : 217.196.43.134
789           condition = ${if eq {$acl_m1}{PTSMail}}
790           condition = ${if def:h_X-PTS-Approved:{false}{true}}
791           message   = messages to the PTS require an X-PTS-Approved header
792 '
793 end
794 out
795 %>
796   deny    condition      = ${if match {$message_body}{\Nhttp:\/\/[a-z\.-]+\/video1?.exe\N}}
797           message        = Blackisted URI found in body
798
799   deny    condition      = ${if eq {$acl_m1}{DBSignedMail}}
800           condition      = ${if and {{!match {$message_body}{PGP MESSAGE}}              \
801                                      {!match {$message_body}{PGP SIGNED MESSAGE}}       \
802                                      {!match {$message_body}{PGP SIGNATURE}}            \
803                                      {!match {$header_content-type:}{multipart/signed}} \
804                                      {!match {$header_content-type:}{pgp}}              \
805                                     }                                                   \
806                             }
807           message        = Mail to this address needs to be PGP-signed
808
809 # RFC 822 and 2822 say that headers must be ASCII.  This kinda emulates
810 # postfix's strict_7bit_headers option, but only checks a few common problem
811 # headers, as there doesn't appear to be an easy way to check them all.
812   deny
813           condition       = ${if or {{match {$rh_Subject:}{[\200-\377]}}\
814                                  {match {$rh_To:}{[\200-\377]}}\
815                                  {match {$rh_From:}{[\200-\377]}}\
816                                  {match {$rh_Cc:}{[\200-\377]}}}{true}{false}}
817           message         = improper use of 8-bit data in message header: message rejected
818
819   deny
820           condition       = ${if match {$rh_Subject:}{[^[:print:]]\{8\}}{true}{false}}
821           message         = Your mailer is not RFC 2047 compliant: message rejected
822
823 <%=
824 out = ""
825 if has_variable?("clamd") && clamd == "true"
826 out = '
827   deny    
828           demime          = *
829           malware         = */defer_ok
830           message         = malware detected: $malware_name: message rejected
831 '
832 end
833 out
834 %>
835
836   deny    spam            = $value/defer_ok
837           domains         = +handled_domains : +rcpthosts
838           message         = message got a spam score of $spam_score
839           local_parts     = ${if exists {/etc/exim4/sa_users}\
840                              {${if match_domain{$domain}{+virtual_domains}\
841                              {${lookup{$local_part@$domain}nwildlsearch{/etc/exim4/sa_users}{$local_part}{}}}\
842                              {${lookup{$local_part}lsearch{/etc/exim4/sa_users}{$local_part}{}}}}}}
843
844 <%=
845 out=''
846 if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty?
847 out='
848   deny   condition     = ${if <{$message_size}{256000}}
849          set acl_m5    = ${perl{surblspamcheck}}
850          condition     = ${if eq{$acl_m5}{false}{no}{yes}}
851          log_message   = $acl_m5
852 '
853 end
854 out
855 %>
856   # Check header_sender except for survey@popcon.d.o
857   deny    condition = ${if eq{$acl_m1}{PopconMail}{false}{true}}
858           !verify = header_sender
859           message = No valid sender found in the From:, Sender: and Reply-to: headers
860
861   accept
862
863
864
865 ######################################################################
866 #                      REWRITE CONFIGURATION                         #
867 ######################################################################
868
869
870
871 begin rewrite
872
873 \N^buildd_(.*)@ries\.debian\.org$\N buildd_$1@buildd.debian.org T
874 \N^buildd_(.*)@klecker\.debian\.org$\N buildd_$1@buildd.debian.org T
875 *@debian.org ${lookup{$1}cdb{/var/lib/misc/${primary_hostname}/mail-forward.cdb}{$value}fail} T
876 *@people.debian.org ${lookup{$1}cdb{/var/lib/misc/${primary_hostname}/mail-forward.cdb}{$value}fail} T
877 #*@${primary_hostname} "${if exists{/etc/exim4/email-addresses}{${lookup{$1}lsearch{/etc/exim4/email-addresses}{$value}fail}}fail}" fFs
878 m68k@buildd.debian.org m68k-build@nocrew.org Ttrbc
879
880
881 #!!#######################################################!!#
882 #!!# Here follow routers created from the old routers,   #!!#
883 #!!# for handling non-local domains.                     #!!#
884 #!!#######################################################!!#
885
886 begin routers
887
888
889
890 ######################################################################
891 #                      ROUTERS CONFIGURATION                         #
892 #                Specifies how addresses are handled                 #
893 ######################################################################
894 #                          ORDER DOES MATTER                         #
895 #     An address is passed to each in turn until it is accepted.     #
896 ######################################################################
897
898 <%=
899 out = ""
900 if nodeinfo['mailrelay']
901   out = '
902 relay_manualroute:
903   driver = manualroute
904   domains = +mailhubdomains
905   transport = remote_smtp
906   route_data = ${lookup{$domain}lsearch{/etc/exim4/manualroute}}
907   require_files = /etc/exim4/manualroute
908 '
909 end
910 out
911 %>
912
913 bsmtp:
914   debug_print = "R: bsmtp for $local_part@$domain"
915   driver = manualroute
916   domains = !+local_domains
917   require_files = /etc/exim4/bsmtp
918   route_list = * ${extract{file}{\
919                    ${lookup{$domain}partial-lsearch{/etc/exim4/bsmtp}\
920                      {$value}fail}}}
921   transport = bsmtp
922
923 # This router routes to remote hosts over SMTP by explicit IP address,
924 # given as a "domain literal" in the form [nnn.nnn.nnn.nnn]. The RFCs
925 # require this facility, which is why it is enabled by default in Exim.
926 ipliteral:
927   debug_print = "R: ipliteral for $local_part@$domain"
928   driver = ipliteral
929   domains = !+handled_domains
930   transport = remote_smtp
931   ignore_target_hosts = +reservedaddrs
932
933 <%=
934 out = ""
935 if not nodeinfo['smarthost'].empty?
936 out = '
937 smarthost:
938   debug_print = "R: smarthost for $local_part@$domain"
939   driver = manualroute
940   domains = !+handled_domains
941   transport = remote_smtp_smarthost
942   route_list = * ' + nodeinfo['smarthost'] + '
943   host_find_failed = defer
944   same_domain_copy_routing = yes
945   no_more
946 '
947 end
948 out
949 %>
950
951 # This router routes to remote hosts over SMTP using a DNS lookup.
952 # Ignore reserved network responses, including localhost.
953 dnslookup:
954   debug_print = "R: dnslookup for $local_part@$domain"
955   driver = dnslookup
956   domains = !+handled_domains
957   transport = remote_smtp
958   ignore_target_hosts = +reservedaddrs
959   no_more
960
961 # This router handles aliasing using a traditional /etc/aliases file.
962 # If any of your aliases expand to pipes or files, you will need to set
963 # up a user and a group for these deliveries to run under. You can do
964 # this by uncommenting the "user" option below (changing the user name
965 # as appropriate) and adding a "group" option if necessary.
966
967 system_aliases:
968   debug_print = "R: system_aliases for $local_part@$domain"
969   driver = redirect
970   allow_defer
971   allow_fail
972   data = ${lookup{$local_part}lsearch*{/etc/aliases}}
973   domains = +local_domains
974   file_transport = address_file
975   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
976   pipe_transport = address_pipe
977   retry_use_local_part
978
979 # This router handles forwarding using traditional .forward files.
980 # It also allows mail filtering when a forward file starts with the 
981 # string "# Exim filter": to disable filtering, uncomment the "filter" 
982 # option. The check_ancestor option means that if the forward file 
983 # generates an address that is an ancestor of the current one, the 
984 # current one gets passed on instead. This covers the case where A is 
985 # aliased to B and B has a .forward file pointing to A.
986
987 # For standard debian setup of one group per user, it is acceptable---normal
988 # even---for .forward to be group writable. If you have everyone in one
989 # group, you should comment out the "modemask" line. Without it, the exim
990 # default of 022 will apply, which is probably what you want.
991
992 userforward_verify:
993   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
994   driver = redirect
995   check_ancestor
996   user = Debian-exim
997   no_check_local_user
998   directory_transport = address_directory
999   domains = +local_domains
1000   # filter - I have disabled filtering to force users to use .forward-foo files
1001   # or procmail. This will make it easier to move mailers in the future
1002   #
1003   # This bit does the qmailesque extension names, foo-bar@ is .forward-foo it
1004   # also checks if the .forward-bar exists, if not then it uses
1005   # .forward-default instead.
1006   file = $home/.forward\
1007          ${if eq{}{$local_part_suffix}{}{\
1008            ${if exists {${home}/.forward${local_part_suffix}} \
1009              {${local_part_suffix}}{-default}}\
1010            }\
1011           }
1012   file_transport = address_file
1013   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1014   local_part_suffix = -*
1015   local_part_suffix_optional
1016   modemask = 002
1017   pipe_transport = address_pipe
1018   reply_transport = address_reply
1019   require_files = $home
1020   router_home_directory = ${lookup passwd{$local_part}{${extract{5}{:}{$value}}}fail}
1021   verify_only
1022
1023 userforward:
1024   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
1025   driver = redirect
1026   check_ancestor
1027   check_local_user
1028   directory_transport = address_directory
1029   domains = +local_domains
1030   # filter - I have disabled filtering to force users to use .forward-foo files
1031   # or procmail. This will make it easier to move mailers in the future
1032   #
1033   # This bit does the qmailesque extension names, foo-bar@ is .forward-foo it
1034   # also checks if the .forward-bar exists, if not then it uses
1035   # .forward-default instead.
1036   file = $home/.forward\
1037          ${if eq{}{$local_part_suffix}{}{\
1038            ${if exists {${home}/.forward${local_part_suffix}} \
1039              {${local_part_suffix}}{-default}}\
1040            }\
1041           }
1042   file_transport = address_file
1043   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1044   local_part_suffix = -*
1045   local_part_suffix_optional
1046   modemask = 002
1047   pipe_transport = address_pipe
1048   reply_transport = address_reply
1049   require_files = $home
1050   no_verify
1051
1052 # This delivers to procmail
1053 procmail:
1054   debug_print = "R: procmail for $local_part@$domain"
1055   driver = accept
1056   check_local_user
1057   domains = +local_domains
1058   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1059   no_verify
1060   no_expn
1061   require_files = $local_part:$home/.procmailrc
1062   transport = procmail_pipe
1063   transport_current_directory = $home
1064   
1065 # This driver delivers to the LDAP generated alias file.
1066 ldap_aliases:
1067   debug_print = "R: ldap_aliases for $local_part@$domain"
1068   driver = redirect
1069   allow_defer
1070   allow_fail
1071   data = ${if exists{/var/lib/misc/$primary_hostname/mail-forward.cdb}\
1072              {${lookup{$local_part}cdb\
1073                {/var/lib/misc/$primary_hostname/mail-forward.cdb}}}}
1074   domains = +local_domains
1075   file_transport = address_file
1076   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1077   pipe_transport = address_pipe
1078   retry_use_local_part
1079   
1080 # This director matches local user mailboxes.
1081 localuser:
1082   debug_print = "R: localuser for $local_part@$domain"
1083   driver = accept
1084   check_local_user
1085   domains = +local_domains
1086   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1087   # Disable if the user has never logged in
1088   require_files = $home
1089   transport = local_delivery
1090   no_more
1091
1092 # Now we begin the Virtual Domain configuration
1093 # Everything before here should apply only to the local domains with a 
1094 # domains= rule
1095
1096 # exim4 fails the router if it can't change to the user/group for delivery
1097 # during verification.  So we have to seperate the cases of verifying
1098 # the virts, and delivering to them.  blah.
1099 <%=
1100 out = ""
1101 if nodeinfo['packagesmaster']
1102   out = '
1103 # This router delivers for packages.d.o
1104 packages:
1105   debug_print = "R: packages for $local_part@$domain"
1106   driver = redirect
1107   file_transport = address_file
1108   pipe_transport = address_pipe
1109   domains = packages.debian.org
1110   require_files = /org/packages.debian.org/conf/maintainer
1111   data = ${lookup{$local_part}cdb{/org/packages.debian.org/conf/maintainer.cdb}}
1112   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1113   transport_home_directory = /org/packages.debian.org/mail
1114   transport_current_directory = /org/packages.debian.org/mail
1115   check_ancestor
1116   retry_use_local_part
1117   no_more
1118 '
1119 end
1120 out
1121 %>
1122
1123 <%=
1124 out = ""
1125 if nodeinfo['bugsmaster']
1126   out = '
1127 # This router delivers for bugs.d.o
1128 bugs:
1129   debug_print = "R: bugs for $local_part@$domain"
1130   driver = accept
1131   transport = bugs_pipe
1132   domains = bugs.debian.org
1133   cannot_route_message = Unknown or archived bug
1134   require_files = /org/bugs.debian.org/mail/run-procmail
1135   no_more
1136   local_parts = ${if match\
1137                   {$local_part}\
1138                   {\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}\
1139                {${if exists{/org/bugs.debian.org/spool/db-h/$2/$1$2.summary}\
1140                {$local_part}fail}}fail}
1141 '
1142 end
1143 out
1144 %>
1145
1146 <%=
1147 out = ""
1148 if nodeinfo['rtmaster']
1149   out = '
1150 # This router delivers for rt.d.o
1151 rt_force_new_verbose:
1152   debug_print = "R: rt for $local_part+new@$domain"
1153   driver = redirect
1154   domains = rt.debian.org
1155   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1156   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1157   local_part_suffix = +new
1158   pipe_transport = rt_pipe
1159   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}}"
1160   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1161
1162 # FIXME: figure out how to generalize this approach so that all of the following would work
1163 # - rt+NNNN@rt.debian.org          : attach correspondence to ticket (verbose)
1164 # - rt+NNNN-quiesce@rt.debian.org  : attach correspondence to ticket (quiesce)
1165 # - rt+NNNN-<action>@rt.debian.org : attach correspondence to ticket (some action)
1166 # requires modification to custom condition in \'scrips\'
1167 rt_force_new_quiesce:
1168   debug_print = "R: rt for $local_part+new-quiesce@$domain"
1169   driver = redirect
1170   domains = rt.debian.org
1171   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1172   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1173   local_part_suffix = +new-quiesce
1174   pipe_transport = rt_pipe
1175   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}}"
1176   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nX-RT-Mode: quiesce"
1177
1178 rt_otherwise:
1179   debug_print = "R: rt for $local_part@$domain"
1180   driver = redirect
1181   domains = rt.debian.org
1182   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
1183   local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
1184   local_part_suffix = +*
1185   local_part_suffix_optional
1186   pipe_transport = rt_pipe
1187   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}}"
1188   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1189 '
1190 end
1191 out
1192 %>
1193
1194 virt_alias_verify:
1195   debug_print = "R: virt_aliases for $local_part@$domain"
1196   driver = redirect
1197   data = ${if exists{\
1198            ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
1199            {${lookup{$local_part}lsearch*{\
1200               ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
1201            }}}}
1202   directory_transport = address_directory
1203   cannot_route_message = Unknown user
1204   domains = +virtual_domains
1205   file_transport = address_file
1206   pipe_transport = address_pipe
1207   qualify_preserve_domain
1208   retry_use_local_part
1209   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1210   transport_home_directory = ${extract{directory}{VDOMAINDATA}}
1211   verify_only
1212
1213 virt_direct_verify:
1214   debug_print = "R: virt_direct for $local_part@$domain"
1215   driver = redirect
1216   no_check_local_user
1217   user = Debian-exim
1218   allow_filter
1219   modemask = 002
1220   directory_transport = address_directory
1221   domains = +virtual_domains
1222   file = $home/.forward-\
1223               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
1224                    {default}}
1225   file_transport = address_file
1226   pipe_transport = address_pipe
1227   reply_transport = address_reply
1228   retry_use_local_part
1229   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1230   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1231   verify_only
1232
1233 # This is a senmailesque alias file lookup
1234 virt_aliases:
1235   debug_print = "R: virt_aliases for $local_part@$domain"
1236   driver = redirect
1237   allow_defer
1238   allow_fail
1239   data = ${if exists{\
1240            ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
1241            {${lookup{$local_part}lsearch*{\
1242               ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
1243            }}}}
1244   directory_transport = address_directory
1245   domains = +virtual_domains
1246   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1247   cannot_route_message = Unknown user
1248   group = ${extract{group}{VDOMAINDATA}}
1249   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1250   pipe_transport = address_pipe
1251   qualify_preserve_domain
1252   retry_use_local_part
1253   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1254   transport_home_directory = ${extract{directory}{VDOMAINDATA}}
1255   no_verify
1256   user = ${extract{user}{VDOMAINDATA}}
1257   
1258 # This is a qmailesque deliver into a directory of .forward files
1259 virt_direct:
1260   debug_print = "R: virt_direct for $local_part@$domain"
1261   driver = redirect
1262   allow_filter
1263   allow_fail
1264   allow_defer
1265   no_check_local_user
1266   directory_transport = address_directory
1267   domains = +virtual_domains
1268   file = $home/.forward-\
1269               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
1270                    {default}}
1271   file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
1272   group = ${extract{group}{VDOMAINDATA}}
1273   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
1274   modemask = 002
1275   pipe_transport = address_pipe
1276   reply_transport = address_reply
1277   retry_use_local_part
1278   router_home_directory = ${extract{directory}{VDOMAINDATA}}
1279   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
1280   no_verify
1281   user = ${extract{user}{VDOMAINDATA}}
1282   #debug_print = .forward-${if exists {${home}/.forward-${local_part}} {${local_part}} {default}}
1283
1284 ######################################################################
1285 #                      TRANSPORTS CONFIGURATION                      #
1286 ######################################################################
1287 #                       ORDER DOES NOT MATTER                        #
1288 #     Only one appropriate transport is called for each delivery.    #
1289 ######################################################################
1290
1291
1292 begin transports
1293
1294 # This transport is used for local delivery to user mailboxes. On debian
1295 # systems group mail is used so we can write to the /var/mail
1296 # directory. (The alternative, which most other unixes use, is to deliver
1297 # as the user's own group, into a sticky-bitted directory)
1298 local_delivery:
1299   driver = appendfile
1300   file = /var/mail/${local_part}
1301   group = mail
1302   mode = 0660
1303   no_mode_fail_narrower
1304   return_path_add
1305   
1306 # This transport is used for handling pipe addresses generated by alias
1307 # or .forward files. It has a conventional name, since it is not actually
1308 # mentioned elsewhere in this configuration file. (A different name *can*
1309 # be specified via the "address_pipe_transport" option if you really want
1310 # to.) If the pipe generates any standard output, it is returned to the sender
1311 # of the message as a delivery error. Set return_fail_output instead if you
1312 # want this to happen only when the pipe fails to complete normally.
1313
1314 address_pipe:
1315   driver = pipe
1316   current_directory = ${home}
1317   environment = "EXTENSION=${substr_1:${local_part_suffix}}:\
1318                  EXT=${substr_1:${local_part_suffix}}:\
1319                  LOCAL=${local_part}${local_part_suffix}:\
1320                  RECIPIENT=${local_part}${local_part_suffix}@${domain}"
1321   return_output
1322   return_path_add
1323
1324 # This transport is used for handling file addresses generated by alias
1325 # or .forward files. It has a conventional name, since it is not actually
1326 # mentioned elsewhere in this configuration file.
1327
1328 address_file:
1329   driver = appendfile
1330   return_path_add
1331
1332 address_file_group:
1333   driver = appendfile
1334   return_path_add
1335   mode = 0660
1336   directory_mode = 0770
1337   mode_fail_narrower = false
1338
1339 # This transport is used for handling file addresses generated by alias
1340 # or .forward files if the path ends in "/", which causes it to be treated
1341 # as a directory name rather than a file name. Each message is then delivered
1342 # to a unique file in the directory. If instead you want all such deliveries to
1343 # be in the "maildir" format that is used by some other mail software,
1344 # uncomment the final option below. If this is done, the directory specified
1345 # in the .forward or alias file is the base maildir directory.
1346 #
1347 # Should you want to be able to specify either maildir or non-maildir
1348 # directory-style deliveries, then you must set up yet another transport,
1349 # called address_directory2. This is used if the path ends in "//" so should
1350 # be the one used for maildir, as the double slash suggests another level
1351 # of directory. In the absence of address_directory2, paths ending in //
1352 # are passed to address_directory.
1353
1354 address_directory:
1355   driver = appendfile
1356   check_string = 
1357   maildir_format
1358   message_prefix = ""
1359   message_suffix = ""
1360   return_path_add
1361
1362 # This transport is used for handling autoreplies generated by the filtering
1363 # option of the forwardfile director. It has a conventional name, since it
1364 # is not actually mentioned elsewhere in this configuration file.
1365 address_reply:
1366   driver = autoreply
1367
1368 # This transport is used for delivering messages over SMTP connections.
1369
1370 remote_smtp:
1371   driver = smtp
1372   connect_timeout = 1m
1373 <%=
1374 out = ""
1375 if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true"
1376   out = "  tls_certificate = /etc/exim4/ssl/thishost.crt
1377   tls_privatekey = /etc/exim4/ssl/thishost.key"
1378 end
1379 out
1380 %>
1381
1382 <%=
1383 out = ""
1384 if not nodeinfo['smarthost'].empty?
1385 out = '
1386 remote_smtp_smarthost:
1387   debug_print = "T: remote_smtp_smarthost for $local_part@$domain"
1388   driver = smtp
1389   port = '
1390   out += nodeinfo['smarthost_port'].to_s + "\n"
1391   if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true"
1392     out += '  tls_tempfail_tryclear = false
1393   hosts_require_tls = ' + nodeinfo['smarthost'] + '
1394   tls_certificate = /etc/exim4/ssl/thishost.crt
1395   tls_privatekey = /etc/exim4/ssl/thishost.key
1396 '
1397   end
1398 end
1399 out
1400 %>
1401
1402 # Send the message to procmail
1403 procmail_pipe:
1404   driver = pipe
1405   command = /usr/bin/procmail -a ${substr_1:${local_part_suffix}}}
1406   return_path_add
1407   user = ${local_part}
1408
1409 bsmtp:
1410   driver = appendfile
1411   batch_max = 100
1412   file = ${host}
1413   message_prefix = 
1414   message_suffix = 
1415   use_bsmtp
1416   user = ${extract{user}{\
1417                    ${lookup{$domain}partial-lsearch{/etc/exim4/bsmtp}\
1418                      {$value}fail}\
1419                    }}
1420
1421 <%=
1422 out = ""
1423 if nodeinfo['bugsmaster']
1424   out = '
1425 bugs_pipe:
1426   driver = pipe
1427   command = /org/bugs.debian.org/mail/run-procmail
1428   environment = "EXTENSION=${substr_1:${local_part_suffix}}:\
1429                  EXT=${substr_1:${local_part_suffix}}:\
1430                  LOCAL=${local_part}${local_part_suffix}:\
1431                  RECIPIENT=${local_part}${local_part_suffix}@${domain}"
1432   return_path_add
1433   return_output
1434   user = debbugs
1435 '
1436 end
1437 out
1438 %>
1439
1440 <%=
1441 out = ""
1442 if nodeinfo['rtmaster']
1443   out = '
1444 rt_pipe:
1445   debug_print = "T: rt_pipe for $local_part${local_part_suffix}@$domain"
1446   driver = pipe
1447   return_fail_output
1448   environment = EXTENSION=${substr_1:${local_part_suffix}}
1449   allow_commands = /usr/bin/rt-mailgate
1450 '
1451 end
1452 out
1453 %>
1454
1455 ######################################################################
1456 #                      RETRY CONFIGURATION                           #
1457 ######################################################################
1458
1459 # This single retry rule applies to all domains and all errors. It specifies
1460 # retries every 15 minutes for 2 hours, then increasing retry intervals,
1461 # starting at 2 hours and increasing each time by a factor of 1.5, up to 16
1462 # hours, then retries every 8 hours until 4 days have passed since the first
1463 # failed delivery.
1464
1465 # Domain               Error       Retries
1466 # ------               -----       -------
1467
1468
1469 begin retry
1470
1471 debian.org             *           F,2h,10m; G,16h,2h,1.5; F,14d,8h
1472 *                      * senders=: F,2h,10m
1473 *                      rcpt_4xx    F,2h,5m;  F,4h,10m; F,4d,15m
1474 *                      *           F,2h,15m; G,16h,2h,1.5; F,4d,8h
1475
1476 # End of Exim 4 configuration