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