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