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