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