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