]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/exim/templates/eximconf.erb
Move all roles from local.yaml to hiera
[dsa-puppet.git] / modules / exim / templates / eximconf.erb
index 3bd6f90637e5e2a9b00db824794d9ebebf000fa3..b3ef52202e2aab8dea67ccb7509a1fa41dc70733 100644 (file)
@@ -32,7 +32,7 @@
 #           flushing' operations, but should be populated with a list
 #           of trusted machines. Wildcards are not permitted
 #  bsmtp_domains - Domains that we deliver locally via bsmtp
-<%- if nodeinfo['mailrelay'] -%>
+<%- if scope.function_has_role('mailrelay') -%>
 #  mailhubdomains - Domains for which we are the MX, but the mail is relayed
 #           elsewhere.  This is designed for use with small volume or
 #           restricted machines that need to use a smarthost for mail
@@ -76,7 +76,7 @@
 #                    MAIN CONFIGURATION SETTINGS                     #
 ######################################################################
 
-<%- if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('site::nodeinfo')['heavy_exim'] -%>
 perl_startup = do '/etc/exim4/exim_surbl.pl'
 <%- end -%>
 
@@ -87,7 +87,7 @@ perl_startup = do '/etc/exim4/exim_surbl.pl'
 acl_smtp_helo = check_helo
 acl_smtp_rcpt = ${if ={$interface_port}{587} {check_submission}{check_recipient}}
 acl_smtp_data = check_message
-<%- if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('site::nodeinfo')['heavy_exim'] -%>
 acl_smtp_mime = acl_check_mime
 <%- end -%>
 acl_smtp_predata = acl_check_predata
@@ -115,28 +115,28 @@ domainlist bsmtp_domains = ${if exists {/etc/exim4/bsmtp}{partial-lsearch;/etc/e
 
 domainlist handled_domains = +local_domains : +virtual_domains : +bsmtp_domains
 
+domainlist ourself_and_handled = $primary_hostname : +handled_domains
+
 localpartlist local_only_users = lsearch;/etc/exim4/localusers
 
-localpartlist postmasterish = postmaster : abuse : hostmaster : root
+localpartlist postmasterish = postmaster : abuse : hostmaster
 
-hostlist debianhosts = 127.0.0.1 : /var/lib/misc/thishost/debianhosts
+hostlist debianhosts = <; ; 127.0.0.1 ; ::1 ; /var/lib/misc/thishost/debianhosts ; 89.16.166.49 ; 82.195.75.76 ; 2001:41b8:202:deb:bab5:0:52c3:4b4c
 
-hostlist reservedaddrs = <%= nodeinfo['reservedaddrs'] %>
+hostlist reservedaddrs = 0.0.0.0/8 : 127.0.0.0/8 : 10.0.0.0/8 : 169.254.0.0/16 : 172.16.0.0/12 : 192.0.0.0/24 : 192.168.0.0/16 : 224.0.0.0/4 : 240.0.0.0/5 : 248.0.0.0/5
 
-<%- if nodeinfo['mailrelay'] -%>
+<%- if scope.function_has_role('mailrelay') -%>
 # Domains we relay for; that is domains that aren't considered local but we 
 # accept mail for them.
 domainlist mailhubdomains = lsearch;/etc/exim4/manualroute
 
 <%- end -%>
-<%- if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true" -%>
 tls_certificate = /etc/exim4/ssl/thishost.crt
 tls_privatekey = /etc/exim4/ssl/thishost.key
 tls_try_verify_hosts = *
 tls_verify_certificates = /etc/exim4/ssl/ca.crt
 tls_crl = /etc/exim4/ssl/ca.crl
 
-<%- end -%>
 # The setting below causes Exim to do a reverse DNS lookup on all incoming
 # IP calls, in order to get the true host name. If you feel this is too
 # expensive, you can specify the networks for which a lookup is done, or
@@ -169,7 +169,7 @@ timeout_frozen_after=14d
 message_size_limit = 100M
 message_logs = false
 smtp_accept_max_per_host = ${if match_ip {$sender_host_address}{+debianhosts}{0}{7}}
-<%- if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('site::nodeinfo')['heavy_exim'] -%>
 smtp_accept_max = 300
 smtp_accept_queue = 200
 smtp_accept_queue_per_connection = 50
@@ -188,15 +188,21 @@ check_spool_space  = 20M
 
 delay_warning =
 
-<%- if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('site::nodeinfo')['heavy_exim'] -%>
+message_body_visible = 5000
 queue_run_max = 50
 deliver_queue_load_max = 50
 queue_only_load = 35
 smtp_load_reserve = 20
 <%- else -%>
 queue_run_max = 5
+<%- if scope.lookupvar('::processorcount').to_s != 'undefined' -%>
+deliver_queue_load_max = <%= [scope.lookupvar('::processorcount').to_i,2].max * 5 %>
+queue_only_load = <%= [scope.lookupvar('::processorcount').to_i,2].max * 4 %>
+<%- else -%>
 deliver_queue_load_max = 10
-queue_only_load = 5
+queue_only_load = 8
+<%- end -%>
 <%- end -%>
 queue_list_requires_admin = false
 
@@ -209,16 +215,16 @@ ports = []
 out = "daemon_smtp_ports = "
 ports << 25
 
-if nodeinfo['bugsmaster'] or nodeinfo['bugsmx']
+if scope.function_has_role('bugsmaster') or scope.function_has_role('bugsmx')
   ports << 587
 end
 
-if not nodeinfo['mail_port'].to_s.empty?
-  ports << nodeinfo['mail_port']
+if not scope.lookupvar('site::nodeinfo')['mail_port'].to_s.empty?
+  ports << scope.lookupvar('site::nodeinfo')['mail_port']
 end
 
-if nodeinfo['mailrelay']
-  ports << nodeinfo['smarthost_port']
+if scope.function_has_role('mailrelay')
+  ports << scope.lookupvar('site::nodeinfo')['smarthost_port']
 end
 
 out += ports.uniq.sort.join(" : ")
@@ -229,9 +235,7 @@ admin_groups = adm
 remote_sort_domains = *.debian.org:*.debian.net
 
 pipelining_advertise_hosts = !*
-<%- if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true" -%>
 tls_advertise_hosts = *
-<%- end -%>
 smtp_enforce_sync = true
 
 log_selector = +tls_cipher +tls_peerdn +queue_time +deliver_time +smtp_connection +smtp_incomplete_transaction +smtp_confirmation
@@ -247,16 +251,16 @@ received_header_text = Received: ${if def:sender_rcvhost {from $sender_rcvhost\n
 # macro definitions.
 # Do not wrap!
 VDOMAINDATA = ${lookup{$domain}partial-lsearch{/etc/exim4/virtualdomains}{$value}}
-WHITELIST = ${if match_domain{$domain}{+virtual_domains}{\
-               ${if exists {/srv/$domain/mail/whitelist}{\
-                ${lookup{$local_part}lsearch{/srv/$domain/mail/whitelist}{$value}{}}\
-                }{}}\
-               }{${lookup{$local_part}lsearch{/etc/exim4/whitelist}{$value}{}} : ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-whitelist}{$value}{}}}}
+WHITELIST = ${if match_domain{$domain}{+virtual_domains}\
+            {${if exists {${extract{directory}{VDOMAINDATA}{${value}/whitelist}}}\
+            {${lookup{$local_part}lsearch{${extract{directory}{VDOMAINDATA}{${value}/whitelist}}}{$value}{}}}{}}}\
+            {/etc/exim4/whitelist} } : \
+            ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-whitelist}{$value}{}}
 GREYLIST_LOCAL_PARTS = ${if match_domain{$domain}{+virtual_domains}\
-                      {${if exists {${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}\
-                      {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}{$local_part}{}}}{}}}\
-                      {${lookup{$local_part}lsearch{/etc/exim4/grey_users}{$local_part}{}} : \
-                      ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-greylist}{$local_part}{}}}}
+                       {${if exists {${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}\
+                       {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/grey_users}}}{$local_part}{}}}{}}}\
+                       {${lookup{$local_part}lsearch{/etc/exim4/grey_users}{$local_part}{}}}} : \
+                       ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-greylist}{$local_part}{}}
 RT_QUEUE_MAP = /srv/rt.debian.org/mail/rt_queue_map
 
 ######################################################################
@@ -288,30 +292,37 @@ acl_getprofile:
           hosts          = !+debianhosts
           set acl_m_rprf = localonly
 
+<%- if scope.function_has_role('mailrelay') -%>
+  warn    local_parts    = +local_only_users
+          domains        = +mailhubdomains
+          hosts          = !+debianhosts
+          set acl_m_rprf = localonly
+
+<%- end -%>
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
 
-<%- if nodeinfo['rtmaster'] -%>
+<%- if scope.function_has_role('rtmaster') -%>
   warn    domains        = rt.debian.org
           set acl_m_rprf = RTMail
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
 
 <%- end -%>
-<%- if nodeinfo['bugsmx'] -%>
+<%- if scope.function_has_role('bugsmaster') or scope.function_has_role('bugsmx') -%>
   warn    domains        = bugs.debian.org
           set acl_m_rprf = BugsMail
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
 
 <%- end -%>
-<%- if nodeinfo['packagesmaster'] -%>
+<%- if scope.function_has_role('packagesmaster') -%>
   warn    domains        = packages.debian.org
           set acl_m_rprf = PackagesMail
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
 
 <%- end -%>
-<%- if nodeinfo['packagesqamaster'] -%>
+<%- if scope.function_has_role('packagesqamaster') -%>
   warn    recipients     = owner@packages.qa.debian.org : postmaster@packages.qa.debian.org
           set acl_m_rprf = PTSOwner
 
@@ -338,7 +349,6 @@ acl_getprofile:
   warn    domains        = +virtual_domains
           condition      = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction}}}}
           condition      = ${if eq{${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction}}}{$value}{}}}{markup}}
-          log_message    = $local_part@$domain: markup
           set acl_m_rprf = markup
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
@@ -346,7 +356,6 @@ acl_getprofile:
   warn    domains        = +virtual_domains
           condition      = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction}}}}
           condition      = ${if eq{${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction}}}{$value}{}}}{blackhole}}
-          log_message    = $local_part@$domain: blackhole
           set acl_m_rprf = blackhole
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
@@ -354,7 +363,6 @@ acl_getprofile:
   warn    domains        = +virtual_domains
           condition      = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction.cdb}}}}
           condition      = ${if eq{${lookup{$local_part}cdb{${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction.cdb}}}{$value}{}}}{markup}}
-          log_message    = $local_part@$domain: markup
           set acl_m_rprf = markup
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
@@ -362,21 +370,18 @@ acl_getprofile:
   warn    domains        = +virtual_domains
           condition      = ${if exists {${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction.cdb}}}}
           condition      = ${if eq{${lookup{$local_part}cdb{${extract{directory}{VDOMAINDATA}{${value}/contentinspectionaction.cdb}}}{$value}{}}}{blackhole}}
-          log_message    = $local_part@$domain: blackhole
           set acl_m_rprf = blackhole
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
 
   warn    domains        = +local_domains
           condition      = ${if eq{${lookup{$local_part}cdb{/var/lib/misc/${primary_hostname}/mail-contentinspectionaction.cdb}{$value}{}}}{markup}}
-          log_message    = $local_part@$domain: markup
           set acl_m_rprf = markup
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
 
   warn    domains        = +local_domains
           condition      = ${if eq{${lookup{$local_part}cdb{/var/lib/misc/${primary_hostname}/mail-contentinspectionaction.cdb}{$value}{}}}{blackhole}}
-          log_message    = $local_part@$domain: blackhole
           set acl_m_rprf = blackhole
 
   accept  condition      = ${if eq {$acl_m_rprf}{}{no}{yes}}
@@ -389,11 +394,11 @@ check_helo:
 
   warn    set acl_c_scr    = 0
 
-<%- if nodeinfo['mailrelay'] -%>
+<%- if scope.function_has_role('mailrelay') -%>
   accept  verify   = certificate
 
 <%- end -%>
-<%- if nodeinfo['smarthost'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo')['smarthost'].empty? -%>
   # These are in HELO acl so that they are only run once.  They increment a counter,
   # so we don't want it to increment per rcpt to.
 
@@ -483,9 +488,9 @@ check_submission:
 
   # Accept if the source is local SMTP (i.e. not over TCP/IP).
   # We do this by testing for an empty sending host field.
-  accept  hosts = : 127.0.0.1
+  accept  hosts = +debianhosts
 
-<%- if nodeinfo['mailrelay'] -%>
+<%- if scope.function_has_role('mailrelay') -%>
   accept  verify   = certificate
 
 <%- end -%>
@@ -506,7 +511,7 @@ check_submission:
           endpass
          verify   = recipient
 
-<%- if nodeinfo['mailrelay'] -%>
+<%- if scope.function_has_role('mailrelay') -%>
   accept  domains  = +mailhubdomains
           endpass
          verify   = recipient/callout=30s,defer_ok,use_sender,no_cache
@@ -521,19 +526,21 @@ check_submission:
 #!!# ACL that is used after the RCPT command
 check_recipient:
 
-<%- if nodeinfo['mailrelay'] -%>
+<%- if scope.function_has_role('mailrelay') -%>
   accept  verify   = certificate
 
 <%- end -%>
+  accept  hosts = <; ::1 ; 127.0.0.1 ; @
   warn    acl           = acl_getprofile
           condition     = ${if eq{$acl_m_prf}{}}
           set acl_m_prf = $acl_m_rprf
 
   defer   condition     = ${if eq{$acl_m_prf}{$acl_m_rprf}{no}{yes}}
+          message       = Different profile, please retry
           log_message   = Only one profile at a time, please
 
   # Defer after too many bad RCPT TO's.  Legit MTAs will retry later.
-  # This is a rough pass at preventing addres harvesting or other mail blasts.
+  # This is a rough pass at preventing address harvesting or other mail blasts.
 
   defer  log_message   = Too many bad recipients ${eval:$rcpt_fail_count} out of $rcpt_count
          !acl          = acl_spamlovers
@@ -552,7 +559,7 @@ check_recipient:
 
   drop   !hosts        = +debianhosts
          !acl          = acl_spamlovers
-         condition     = ${if match_domain{$sender_helo_name}{$primary_hostname:+handled_domains}}
+         condition     = ${if match_domain{$sender_helo_name}{+ourself_and_handled}}
          condition     = ${if !match{$sender_host_name}{${rxquote:$sender_helo_name}\N$\N}}
          message       = HELO mismatch Forged HELO for ($sender_helo_name)
 
@@ -632,13 +639,7 @@ check_recipient:
   warn    condition     = ${if eq{$acl_m_prf}{localonly}}
           set acl_m_lrc = ${if eq{$acl_m_lrc}{}{$local_part@$domain}{$acl_m_lrc, $local_part@$domain}}
 
-<%- if 0 == 1 -%>
-  deny    message  = address $sender_host_address is listed in $dnslist_domain; $dnslist_text
-         hosts    = !+debianhosts
-          dnslists = rbl.debian.net : rbl.debian.net/$sender_address_domain
-
-<%- end -%>
-<%- if nodeinfo['packagesmaster'] -%>
+<%- if scope.function_has_role('packagesmaster') -%>
   warn    condition      = ${if eq {$acl_m_prf}{PackagesMail}}
           condition      = ${if eq {$sender_address}{$local_part@$domain}}
           message        = X-Packages-FromTo-Same: yes
@@ -716,9 +717,12 @@ check_recipient:
          condition      = ${if eq{$acl_m_act}{450}{yes}{no}}
 
 <%- end -%>
-<%- if nodeinfo['rtmaster'] -%>
+<%- if scope.function_has_role('rtmaster') -%>
   warn    condition     = ${if eq{$acl_m_prf}{RTMail}}
-          set acl_m12   = ${if def:acl_m12 {$acl_m12} {${if or{{match{$local_part}{\N[^+]+\+\d+\N}}{match{$local_part}{\N[^+]+\+new\N}}} {RTMailRecipientHasSubaddress}}}}
+          set acl_m12   = ${if def:acl_m12 {$acl_m12} {${if or{{match{$local_part}{\N[^+]+\+\d+\N}}{match{$local_part}{\N[^+]+\+new\N}}{match{$local_part}{3520}}{match{$local_part}{3645}}} {RTMailRecipientHasSubaddress}}}}
+  # temporary hack because weasel screwed up and gave people an rt-3520@ address, which doesn't really work normally.  and rt-3645
+  #set acl_m12  = ${if def:acl_m12 {$acl_m12} {${if or{{match{$local_part}{\N[^+]+\+\d+\N}}{match{$local_part}{\N[^+]+\+new\N}}} {RTMailRecipientHasSubaddress}}}}
+
 
 <%- end -%>
 <%- if has_variable?("greylistd") && greylistd == "true" -%>
@@ -794,7 +798,7 @@ check_recipient:
 
 <%- end -%>
   accept  local_parts   = +postmasterish
-          domains       = +handled_domains
+          domains       = +virtual_domains : +bsmtp_domains
 
   deny    hosts        = ${if exists{/etc/exim4/host_blacklist}{/etc/exim4/host_blacklist}{}}
           message      = I'm terribly sorry, but it seems you have been blacklisted
@@ -804,13 +808,13 @@ check_recipient:
          senders       = ${if exists{/etc/exim4/blacklist}{/etc/exim4/blacklist}{}}
          message       = We have blacklisted <$sender_address>.  Please stop mailing us
 
-<%- if nodeinfo['smarthost'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo')['smarthost'].empty? -%>
   deny    message  = host $sender_host_address is listed in $dnslist_domain; see $dnslist_text
           dnslists = ${if match_domain{$domain}{+virtual_domains}\
                     {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}\
                     {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}{$value}{}}}{}}}\
-                    {${lookup{$local_part}lsearch{/etc/exim4/rbllist}{$value}{}} : \
-                    ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rbl}{$value}{}}}}
+                    {${lookup{$local_part}lsearch{/etc/exim4/rbllist}{$value}{}}}} : \
+                    ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rbl}{$value}{}}
          domains       = +handled_domains
          !hosts        = +debianhosts : WHITELIST
 
@@ -819,23 +823,24 @@ check_recipient:
           dnslists = ${if match_domain{$domain}{+virtual_domains}\
                     {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}\
                     {${expand:${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/rhsbllist}}}{$value}{}}}}{}}}\
-                    {${expand:${lookup{$local_part}lsearch{/etc/exim4/rhsbllist}{$value}{}}} : \
-                    ${expand:${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rhsbl}{$value}{}}}}}
+                    {${expand:${lookup{$local_part}lsearch{/etc/exim4/rhsbllist}{$value}{}}}}} : \
+                    ${expand:${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-rhsbl}{$value}{}}}
          domains       = +handled_domains
          !hosts        = +debianhosts : WHITELIST
 
-<%- if nodeinfo['smarthost'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo')['smarthost'].empty? -%>
   deny    domains  = +handled_domains
-          local_parts   = ${if match_domain{$domain}{+virtual_domains}\
-                          {${if exists {${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}\
-                          {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}{$local_part}{}}}{}}}\
-                          {${lookup{$local_part}lsearch{/etc/exim4/callout_users}{$local_part}{}} : \
-                          ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-callout}{$local_part}{}}}}
+          local_parts = ${if match_domain{$domain}{+virtual_domains}\
+                        {${if exists {${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}\
+                        {${lookup{$local_part}lsearch*{${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}{$local_part}{}}}{}}}\
+                        {${lookup{$local_part}lsearch{/etc/exim4/callout_users}{$local_part}{}}}} : \
+                        ${lookup{$local_part}lsearch{/var/lib/misc/$primary_hostname/mail-callout}{$local_part}{}}
           !hosts   = +debianhosts : WHITELIST
          !verify  = sender/callout=90s,maxwait=300s
+         message  = "Sender verification failed: $acl_verify_message"
 
 <%- end -%>
-<%- if nodeinfo['mailrelay'] -%>
+<%- if scope.function_has_role('mailrelay') -%>
   accept  domains  = +mailhubdomains
           endpass
          verify   = recipient/callout=30s,defer_ok,use_sender,no_cache
@@ -851,9 +856,12 @@ check_recipient:
 
   deny    message = relay not permitted
 
-<%- if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('site::nodeinfo')['heavy_exim'] -%>
 acl_check_mime:
 
+ accept  verify        = certificate
+ accept  hosts         = +debianhosts
+
  discard condition     = ${if <{$message_size}{256000}}
          condition     = ${if eq {$acl_m_prf}{blackhole}}
          set acl_m_srb = ${perl{surblspamcheck}}
@@ -886,7 +894,12 @@ acl_check_predata:
 
 #!!# ACL that is used after the DATA command
 check_message:
-<%- if nodeinfo['rtmaster'] -%>
+
+  # Some people put from hostmaster@something.debian.org in the From
+  # header.  Take their crack pipe away.
+  drop   condition = ${if match{${lc:$h_From:}}{\Npostmaster@([^.]+\.)?debian\.org\N}}
+
+<%- if scope.function_has_role('rtmaster') -%>
   deny    condition = ${if eq {$acl_m_prf}{RTMail}}
           condition = ${if and{{!match {${lc:$rh_Subject:}} {debian rt}} \
                                {!match {${lc:$rh_Subject:]}} {\N\[rt.debian.org \N}} \
@@ -894,8 +907,8 @@ check_message:
           message  = messages to the Request Tracker system require a subject tag or a subaddress
 
 <%- end -%>
-<%- if nodeinfo['packagesqamaster'] -%>
-  deny    !hosts  = +debianhosts : 217.196.43.134
+<%- if scope.function_has_role('packagesqamaster') -%>
+  deny    !hosts  = +debianhosts : 5.153.231.21
           condition = ${if eq {$acl_m_prf}{PTSMail}}
           condition = ${if def:h_X-PTS-Approved:{false}{true}}
           message   = messages to the PTS require an X-PTS-Approved header
@@ -911,11 +924,12 @@ check_message:
                             }
           message        = Mail to this address needs to be PGP-signed
 
-  accept verify  = certificate
+  accept  verify    = certificate
+  accept  hosts     = +debianhosts
 
   deny    condition = ${if eq {$acl_m_prf}{PopconMail}{no}{yes}}
           !verify   = header_syntax
-          message   = Invalid syntax in the header
+          message   = Invalid header syntax: $acl_verify_message
 
 # RFC 822 and 2822 say that headers must be ASCII.  This kinda emulates
 # postfix's strict_7bit_headers option, but only checks a few common problem
@@ -951,7 +965,7 @@ check_message:
           message         = X-malware detected: $malware_name
 
 <%- end -%>
-<%- if nodeinfo.has_key?('heavy_exim') and not nodeinfo['heavy_exim'].empty? -%>
+<%- if scope.lookupvar('site::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('site::nodeinfo')['heavy_exim'] -%>
  discard condition     = ${if <{$message_size}{256000}}
          condition     = ${if eq {$acl_m_prf}{blackhole}}
          set acl_m_srb = ${perl{surblspamcheck}}
@@ -978,7 +992,7 @@ check_message:
           !verify      = header_sender
           message      = No valid sender found in the From:, Sender: and Reply-to: headers
 
-<%- if nodeinfo['packagesmaster'] -%>
+<%- if scope.function_has_role('packagesmaster') -%>
   deny  message        = Congratulations, you scored $spam_score points.
         log_message    = spam: $spam_score points.
         condition      = ${if eq {$acl_m_prf}{PackagesMail}}
@@ -1002,8 +1016,7 @@ check_message:
 
 begin rewrite
 
-\N^buildd_(.*)@ries\.debian\.org$\N buildd_$1@buildd.debian.org T
-\N^buildd_(.*)@klecker\.debian\.org$\N buildd_$1@buildd.debian.org T
+\N^buildd_(.*)@franck\.debian\.org$\N buildd_$1@buildd.debian.org T
 *@debian.org ${lookup{$1}cdb{/var/lib/misc/${primary_hostname}/mail-forward.cdb}{$value}fail} T
 *@people.debian.org ${lookup{$1}cdb{/var/lib/misc/${primary_hostname}/mail-forward.cdb}{$value}fail} T
 #*@${primary_hostname} "${if exists{/etc/exim4/email-addresses}{${lookup{$1}lsearch{/etc/exim4/email-addresses}{$value}fail}}fail}" fFs
@@ -1027,7 +1040,7 @@ begin routers
 #     An address is passed to each in turn until it is accepted.     #
 ######################################################################
 
-<%- if nodeinfo['mailrelay'] -%>
+<%- if scope.function_has_role('mailrelay') -%>
 relay_manualroute:
   driver = manualroute
   domains = +mailhubdomains
@@ -1058,22 +1071,18 @@ ipliteral:
 
 <%=
 out = ""
-if not nodeinfo['smarthost'].empty?
-out = '
+if not scope.lookupvar('site::nodeinfo')['smarthost'].empty?
+out = "
 smarthost:
-  debug_print = "R: smarthost for $local_part@$domain"
+  debug_print = \"R: smarthost for $local_part@$domain\"
   driver = manualroute
   domains = !+handled_domains
   transport = remote_smtp_smarthost
-  route_list = * ' + nodeinfo['smarthost']
-  if nodeinfo['smarthost'] == 'mailout.debian.org'
-    out += '/MX'
-  end
-  out += '
+  route_list = * #{scope.lookupvar('site::nodeinfo')['smarthost']}
   host_find_failed = defer
   same_domain_copy_routing = yes
   no_more
-'
+"
 end
 out
 %>
@@ -1095,7 +1104,7 @@ postmasterish:
   unseen = true
   expn = true
   local_parts = +postmasterish
-  domains = +handled_domains
+  domains = +virtual_domains : +bsmtp_domains
   data = debian-admin@debian.org
   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
 
@@ -1161,6 +1170,55 @@ userforward_verify:
   router_home_directory = ${lookup passwd{$local_part}{${extract{5}{:}{$value}}}fail}
   verify_only
 
+# This is a senmailesque alias file lookup
+virt_aliases:
+  debug_print = "R: virt_aliases for $local_part@$domain"
+  driver = redirect
+  allow_defer
+  allow_fail
+  data = ${if exists{\
+           ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
+          {${lookup{$local_part}lsearch*{\
+              ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
+          }}}}
+  directory_transport = address_directory
+  domains = +virtual_domains
+  file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
+  cannot_route_message = Unknown user
+  group = ${extract{group}{VDOMAINDATA}}
+  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
+  pipe_transport = address_pipe
+  qualify_preserve_domain
+  retry_use_local_part
+  transport_current_directory = ${extract{directory}{VDOMAINDATA}}
+  transport_home_directory = ${extract{directory}{VDOMAINDATA}}
+  user = ${extract{user}{VDOMAINDATA}}
+  
+# No direct match, so try doing a regex match if there's an
+# aliases.regex
+virt_aliases_regex:
+  debug_print = "R: virt_aliases_regex for $local_part$local_part_suffix@$domain"
+  driver = redirect
+  allow_defer
+  allow_fail
+  data = ${if exists{\
+           ${extract{directory}{VDOMAINDATA}{${value}/aliases.regex}}}\
+          {${lookup{$local_part}nwildlsearch*{\
+              ${extract{directory}{VDOMAINDATA}{$value/aliases.regex}}\
+          }}}}
+  directory_transport = address_directory
+  domains = +virtual_domains
+  file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
+  cannot_route_message = Unknown user
+  group = ${extract{group}{VDOMAINDATA}}
+  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
+  pipe_transport = address_pipe
+  qualify_preserve_domain
+  retry_use_local_part
+  transport_current_directory = ${extract{directory}{VDOMAINDATA}}
+  transport_home_directory = ${extract{directory}{VDOMAINDATA}}
+  user = ${extract{user}{VDOMAINDATA}}
+
 userforward:
   debug_print = "R: userforward for $local_part${local_part_suffix}@$domain"
   driver = redirect
@@ -1211,11 +1269,13 @@ ldap_aliases:
   driver = redirect
   allow_defer
   allow_fail
-  data = ${if exists{/var/lib/misc/$primary_hostname/mail-forward.cdb}\
+  data = ${if exists{/var/lib/misc/$primary_hostname/user-forward.cdb}\
              {${lookup{$local_part}cdb\
-              {/var/lib/misc/$primary_hostname/mail-forward.cdb}}}}
+              {/var/lib/misc/$primary_hostname/user-forward.cdb}}}}
   domains = +local_domains
   file_transport = address_file
+  local_part_suffix = -*
+  local_part_suffix_optional
   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
   pipe_transport = address_pipe
   retry_use_local_part
@@ -1226,6 +1286,8 @@ localuser:
   driver = accept
   check_local_user
   domains = +local_domains
+  local_part_suffix = -*
+  local_part_suffix_optional
   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
   # Disable if the user has never logged in
   require_files = $home
@@ -1236,7 +1298,7 @@ localuser:
 # Everything before here should apply only to the local domains with a 
 # domains= rule
 
-<%- if nodeinfo['packagesmaster'] -%>
+<%- if scope.function_has_role('packagesmaster') -%>
 # This router delivers for packages.d.o
 packages:
   debug_print = "R: packages for $local_part@$domain"
@@ -1244,43 +1306,17 @@ packages:
   file_transport = address_file
   pipe_transport = address_pipe
   domains = packages.debian.org
-  require_files = /org/packages.debian.org/conf/maintainer
-  data = ${lookup{$local_part}cdb{/org/packages.debian.org/conf/maintainer.cdb}}
+  require_files = /srv/packages.debian.org/conf/maintainer
+  data = ${lookup{$local_part}cdb{/srv/packages.debian.org/conf/maintainer.cdb}}
   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
-  transport_home_directory = /org/packages.debian.org/mail
-  transport_current_directory = /org/packages.debian.org/mail
+  transport_home_directory = /srv/packages.debian.org/mail
+  transport_current_directory = /srv/packages.debian.org/mail
   check_ancestor
   retry_use_local_part
   no_more
 
 <%- end -%>
-<%=
-out = ""
-if nodeinfo['bugsmaster'] or nodeinfo['bugsmx']
-  domain = 'bugs.debian.org'
-  if nodeinfo['bugsmaster']
-    domain = 'bugs-master.debian.org'
-  end
-  out = '
-# This router delivers for bugs.d.o
-bugs:
-  debug_print = "R: bugs for $local_part@$domain"
-  driver = accept
-  transport = bugs_pipe
-  domains = ' + domain + '
-  cannot_route_message = Unknown or archived bug
-  require_files = /org/bugs.debian.org/mail/run-procmail
-  no_more
-  local_parts = ${if match\
-                  {$local_part}\
-                  {\N^(\d+)(\d{2})(?:-(?:(?:submit|maintonly|quiet|forwarded|done|close|request|submitter)|(?:unsubscribe|ignore|help|(?:sub(?:scribe|help|yes|approve|reject))|unsubyes|bounce|probe|approve|reject|setlistyes|setlistsilentyes).*))?$\N}\
-               {${if exists{/org/bugs.debian.org/spool/db-h/$2/$1$2.summary}\
-              {$local_part}fail}}fail}
-'
-end
-out
-%>
-<%- if nodeinfo['rtmaster'] -%>
+<%- if scope.function_has_role('rtmaster') -%>
 # This router delivers for rt.d.o
 rt_force_new_verbose:
   debug_print = "R: rt for $local_part+new@$domain"
@@ -1291,7 +1327,8 @@ rt_force_new_verbose:
   local_part_suffix = +new
   pipe_transport = rt_pipe
   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}}"
-  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
+  headers_remove = Subject
+  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nSubject: ${if and {{first_delivery}{match {$h_subject:}{(?i)(.*?)\\\\[?debian rt\\\\]?[:\\s]*(.*)}}} {$1$2}{$h_subject:}}"
 
 # FIXME: figure out how to generalize this approach so that all of the following would work
 # - rt+NNNN@rt.debian.org          : attach correspondence to ticket (verbose)
@@ -1307,20 +1344,21 @@ rt_force_new_quiesce:
   local_part_suffix = +new-quiesce
   pipe_transport = rt_pipe
   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}}"
-  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nX-RT-Mode: quiesce"
+  headers_remove = Subject
+  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nX-RT-Mode: quiesce\nSubject: ${if and {{first_delivery}{match {$h_subject:}{(?i)(.*?)\\\\[?debian rt\\\\]?[:\\s]*(.*)}}} {$1$2}{$h_subject:}}"
 
 rt_otherwise:
   debug_print = "R: rt for $local_part@$domain"
   driver = redirect
   domains = rt.debian.org
   require_files = /usr/bin/rt-mailgate : RT_QUEUE_MAP
-  local_parts = ${lookup{${sg{$local_part}{-comment}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
+  local_parts = ${lookup{${sg{$local_part}{-(comment|done)}{}}}lsearch{RT_QUEUE_MAP}{$local_part}{}}
   local_part_suffix = +*
   local_part_suffix_optional
   pipe_transport = rt_pipe
-  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}}"
-  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
-
+  data = "|/usr/bin/rt-mailgate --queue '${lookup{${sg{$local_part}{-(comment|done)}{}}}lsearch{RT_QUEUE_MAP}}' --url https://rt.debian.org/ --extension ticket --action ${if match{$local_part}{.*-comment.*}{comment}{${if match{$local_part}{.*-done.*}{correspond-resolve}{correspond}}}}"
+  headers_remove = Subject
+  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}\nSubject: ${if and {{first_delivery}{match {$h_subject:}{(?i)(.*?)\\\\[?debian rt\\\\]?[:\\s]*(.*)}}} {$1$2}{$h_subject:}}"
 <%- end -%>
 
 # exim4 fails the router if it can't change to the user/group for delivery
@@ -1336,6 +1374,8 @@ virt_direct_verify:
   modemask = 002
   directory_transport = address_directory
   domains = +virtual_domains
+  local_part_suffix = -*
+  local_part_suffix_optional
   file = $home/.forward-\
               ${if exists {${home}/.forward-${local_part}}{${local_part}}\
                   {default}}
@@ -1347,30 +1387,6 @@ virt_direct_verify:
   transport_current_directory = ${extract{directory}{VDOMAINDATA}}
   verify_only
 
-# This is a senmailesque alias file lookup
-virt_aliases:
-  debug_print = "R: virt_aliases for $local_part@$domain"
-  driver = redirect
-  allow_defer
-  allow_fail
-  data = ${if exists{\
-           ${extract{directory}{VDOMAINDATA}{${value}/aliases}}}\
-          {${lookup{$local_part}lsearch*{\
-              ${extract{directory}{VDOMAINDATA}{$value/aliases}}\
-          }}}}
-  directory_transport = address_directory
-  domains = +virtual_domains
-  file_transport = ${if eq {${extract{group_writable}{VDOMAINDATA}}}{true}{address_file_group}{address_file}}
-  cannot_route_message = Unknown user
-  group = ${extract{group}{VDOMAINDATA}}
-  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
-  pipe_transport = address_pipe
-  qualify_preserve_domain
-  retry_use_local_part
-  transport_current_directory = ${extract{directory}{VDOMAINDATA}}
-  transport_home_directory = ${extract{directory}{VDOMAINDATA}}
-  user = ${extract{user}{VDOMAINDATA}}
-  
 # This is a qmailesque deliver into a directory of .forward files
 virt_direct:
   debug_print = "R: virt_direct for $local_part@$domain"
@@ -1388,6 +1404,8 @@ virt_direct:
   group = ${extract{group}{VDOMAINDATA}}
   headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
   modemask = 002
+  local_part_suffix = -*
+  local_part_suffix_optional
   pipe_transport = address_pipe
   reply_transport = address_reply
   retry_use_local_part
@@ -1397,6 +1415,64 @@ virt_direct:
   user = ${extract{user}{VDOMAINDATA}}
   #debug_print = .forward-${if exists {${home}/.forward-${local_part}} {${local_part}} {default}}
 
+# This router delivers to the LDAP generated mail-forward file.
+# It's only really useful for debian.org
+virt_users:
+  debug_print = "R: virt_users for $local_part@$domain"
+  driver = redirect
+  allow_defer
+  allow_fail
+  router_home_directory = ${extract{directory}{VDOMAINDATA}}
+  transport_current_directory = ${extract{directory}{VDOMAINDATA}}
+  user = ${extract{user}{VDOMAINDATA}}
+  group = ${extract{group}{VDOMAINDATA}}
+  # Manually construct the forwarding address, preserving the
+  # local_part_suffix if the remote host is master.
+  data = ${if and {{exists{${extract{directory}{VDOMAINDATA}{${value}/mail-forward.cdb}}}}\
+                     {! eq {${lookup{$local_part}cdb\
+                            {${extract{directory}{VDOMAINDATA}{${value}/mail-forward.cdb}}}}}\
+                           {}}}\
+             {${local_part:${lookup{$local_part}cdb\
+             {${extract{directory}{VDOMAINDATA}{${value}/mail-forward.cdb}}}}}\
+             ${if eq {${domain:${lookup{$local_part}cdb\
+             {${extract{directory}{VDOMAINDATA}{${value}/mail-forward.cdb}}}}}}{master.debian.org}{$local_part_suffix} {}}\
+             @\
+             ${domain:${lookup{$local_part}cdb\
+            {${extract{directory}{VDOMAINDATA}{${value}/mail-forward.cdb}}}}}}}
+  domains = +virtual_domains
+  file_transport = address_file
+  headers_add = "Delivered-To: ${local_part}${local_part_suffix}@${domain}"
+  pipe_transport = address_pipe
+  local_part_suffix = -*
+  local_part_suffix_optional
+  retry_use_local_part
+
+<%=
+out = ""
+if scope.function_has_role('bugsmaster') or scope.function_has_role('bugsmx')
+  domain = 'bugs.debian.org'
+  if scope.function_has_role('bugsmaster')
+    domain = 'bugs-master.debian.org'
+  end
+  out = '
+# This router delivers for bugs.d.o
+bugs:
+  debug_print = "R: bugs for $local_part@$domain"
+  driver = accept
+  transport = bugs_pipe
+  domains = ' + domain + '
+  cannot_route_message = Unknown or archived bug
+  require_files = /org/bugs.debian.org/mail/run-procmail
+  no_more
+  local_parts = ${if match\
+                  {$local_part}\
+                  {\N^(\d+)(\d{2})(?:-(?:(?:submit|maintonly|quiet|forwarded|done|close|request|submitter)|(?:unsubscribe|ignore|help|(?:sub(?:scribe|help|yes|approve|reject))|unsubyes|bounce|probe|approve|reject|setlistyes|setlistsilentyes).*))?$\N}\
+               {${if exists{/org/bugs.debian.org/spool/db-h/$2/$1$2.summary}\
+              {$local_part}fail}}fail}
+'
+end
+out
+%>
 ######################################################################
 #                      TRANSPORTS CONFIGURATION                      #
 ######################################################################
@@ -1485,37 +1561,33 @@ address_reply:
 
 remote_smtp:
   driver = smtp
-  connect_timeout = 1m
+  connect_timeout = 15s
   delay_after_cutoff = false
-<%- if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true" -%>
   tls_certificate = /etc/exim4/ssl/thishost.crt
   tls_privatekey = /etc/exim4/ssl/thishost.key
-<%- end -%>
 
 <%=
 out = ""
-if not nodeinfo['smarthost'].empty?
+if not scope.lookupvar('site::nodeinfo')['smarthost'].empty?
 out = '
 remote_smtp_smarthost:
   debug_print = "T: remote_smtp_smarthost for $local_part@$domain"
   driver = smtp
   delay_after_cutoff = false
   port = '
-  out += nodeinfo['smarthost_port'].to_s + "\n"
-  if has_variable?("exim_ssl_certs") && exim_ssl_certs == "true"
-    out += '  tls_tempfail_tryclear = false
-  hosts_require_tls = ' + nodeinfo['smarthost'] + '
+  out += scope.lookupvar('site::nodeinfo')['smarthost_port'].to_s + "\n"
+  out += '  tls_tempfail_tryclear = false
+  hosts_require_tls = ' + scope.lookupvar('site::nodeinfo')['smarthost'] + '
   tls_certificate = /etc/exim4/ssl/thishost.crt
   tls_privatekey = /etc/exim4/ssl/thishost.key
 '
-  end
 end
 out
 %>
 # Send the message to procmail
 procmail_pipe:
   driver = pipe
-  command = /usr/bin/procmail -a ${substr_1:${local_part_suffix}}}
+  command = /usr/bin/procmail -a ${substr_1:${local_part_suffix}}
   return_path_add
   user = ${local_part}
 
@@ -1531,7 +1603,7 @@ bsmtp:
                     {$value}fail}\
                   }}
 
-<%- if nodeinfo['bugsmaster'] or nodeinfo['bugsmx'] -%>
+<%- if scope.function_has_role('bugsmaster') or scope.function_has_role('bugsmx') -%>
 bugs_pipe:
   driver = pipe
   command = /org/bugs.debian.org/mail/run-procmail
@@ -1544,7 +1616,7 @@ bugs_pipe:
   user = debbugs
 
 <%- end -%>
-<%- if nodeinfo['rtmaster'] -%>
+<%- if scope.function_has_role('rtmaster') -%>
 rt_pipe:
   debug_print = "T: rt_pipe for $local_part${local_part_suffix}@$domain"
   driver = pipe