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