From 476be24c31ce5feeafc3a17fb941ec65b082db3b Mon Sep 17 00:00:00 2001
From: Zen Fu <zen@systemli.org>
Date: Wed, 5 Mar 2025 17:08:38 -0300
Subject: [PATCH] allow adding virtual aliases to postfix

refs tpo/tpa/tails-sysadmin#18188
---
 manifests/profile/mta.pp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/manifests/profile/mta.pp b/manifests/profile/mta.pp
index 14294db07..2182e9d9d 100644
--- a/manifests/profile/mta.pp
+++ b/manifests/profile/mta.pp
@@ -22,6 +22,9 @@
 # @param extra_params
 #   extra parameters to set in postfix
 #
+# @param virtual_aliases
+#   hash mapping source to target addresses to be added to postfix's virtual_alias map
+#
 class tails::profile::mta (
   String  $myhostname            = $facts['networking']['fqdn'],
   String  $myorigin              = $facts['networking']['fqdn'],
@@ -30,6 +33,7 @@ class tails::profile::mta (
   Boolean $allow_trusted_subnets = true,
   Boolean $monitor               = true,
   Hash    $extra_params          = {},
+  Hash    $virtual_aliases       = {},
 ) {
   if $allow_trusted_subnets {
     $allmynetworks = $mynetworks + lookup('tirewall::trusted_subnets', Array, 'first', [])
@@ -129,6 +133,14 @@ class tails::profile::mta (
     },
   }
 
+  $virtual_aliases.each | String $source, String $target | {
+    concat::fragment { "postfix::map: virtual alias for ${source}":
+      target  => '/etc/postfix/maps/virtual_alias',
+      content => "${source} ${target}",
+      require => Class['postfix'],
+    }
+  }
+
   include tails::profile::rspamd
   if $monitor {
     include monitoring::checkcommands::mailqueue
-- 
GitLab