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