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