From abba39ab3c6e567823448576899d067c3a1de8e9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Pialasse Date: Fri, 20 Dec 2024 00:36:26 -0500 Subject: [PATCH] * Fri Dec 20 2024 Jean-Philippe Pialasse 1.0-7.sme - fix catch-all behaviour [SME: 12382] myorigin now is hostname in case email sent outside by deamon generic rewrite occurs --- createlinks | 1 + .../templates/etc/postfix/generic/10myorigin | 2 ++ .../templates/etc/postfix/main.cf/32myorigin | 7 ++++++- .../etc/postfix/main.cf/45recipients | 4 ++-- .../etc/postfix/main.cf/50mydestination | 2 +- .../postfix/main.cf/64luser_relay_catchall | 8 +++----- .../templates/etc/postfix/main.cf/65heloname | 2 +- .../etc/postfix/main.cf/86smtp_generic_maps | 2 ++ .../templates/etc/postfix/virtual/05system | 1 - .../templates/etc/postfix/virtual/06user | 19 ++++++++++++++++++- .../etc/postfix/virtual/95unknownusers | 3 ++- root/sbin/e-smith/systemd/postfix-pre | 5 +++++ root/sbin/e-smith/systemd/postfix-reload | 5 +++++ smeserver-postfix.spec | 7 ++++++- 14 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 root/etc/e-smith/templates/etc/postfix/generic/10myorigin create mode 100644 root/etc/e-smith/templates/etc/postfix/main.cf/86smtp_generic_maps diff --git a/createlinks b/createlinks index 83fd6f1..d17f26b 100644 --- a/createlinks +++ b/createlinks @@ -14,6 +14,7 @@ foreach (qw( transport virtual sasl_passwd + generic )) { templates2events("/etc/postfix/$_", qw( diff --git a/root/etc/e-smith/templates/etc/postfix/generic/10myorigin b/root/etc/e-smith/templates/etc/postfix/generic/10myorigin new file mode 100644 index 0000000..ba8718c --- /dev/null +++ b/root/etc/e-smith/templates/etc/postfix/generic/10myorigin @@ -0,0 +1,2 @@ +#change myorigin to local domain for outgoing emails +@{$SystemName} @{$DomainName} diff --git a/root/etc/e-smith/templates/etc/postfix/main.cf/32myorigin b/root/etc/e-smith/templates/etc/postfix/main.cf/32myorigin index bbaea63..d2d17db 100644 --- a/root/etc/e-smith/templates/etc/postfix/main.cf/32myorigin +++ b/root/etc/e-smith/templates/etc/postfix/main.cf/32myorigin @@ -1,2 +1,7 @@ -myorigin = $mydomain +{ +# do not put a domain that will be used to recieve emails there +# if you do so you will lose email with the virtual rewriting process. +# this will complete local sent email and virtual right hands +}# do not put real domain there to avoid loop, or catch-all issues +myorigin = $myhostname append_at_myorigin = yes diff --git a/root/etc/e-smith/templates/etc/postfix/main.cf/45recipients b/root/etc/e-smith/templates/etc/postfix/main.cf/45recipients index 95cefc5..a9d4596 100644 --- a/root/etc/e-smith/templates/etc/postfix/main.cf/45recipients +++ b/root/etc/e-smith/templates/etc/postfix/main.cf/45recipients @@ -1,5 +1,5 @@ { # qmail compatibility - instead of + # default empty -} -recipient_delimiter = - +}recipient_delimiter = - +expand_owner_alias = yes diff --git a/root/etc/e-smith/templates/etc/postfix/main.cf/50mydestination b/root/etc/e-smith/templates/etc/postfix/main.cf/50mydestination index c69bae7..6a63907 100644 --- a/root/etc/e-smith/templates/etc/postfix/main.cf/50mydestination +++ b/root/etc/e-smith/templates/etc/postfix/main.cf/50mydestination @@ -1,5 +1,5 @@ # SME Primary domain and host: looks up all recipients in /etc/passwd and /etc/aliases -mydestination = $myhostname $mydomain $myhostname.$mydomain localhost.$mydomain localhost { +mydestination = $myorigin $myhostname $mydomain $myhostname.$mydomain localhost.$mydomain localhost { $OUT = " "; my $i = 0; use esmith::DomainsDB; diff --git a/root/etc/e-smith/templates/etc/postfix/main.cf/64luser_relay_catchall b/root/etc/e-smith/templates/etc/postfix/main.cf/64luser_relay_catchall index a161c89..26dde4c 100644 --- a/root/etc/e-smith/templates/etc/postfix/main.cf/64luser_relay_catchall +++ b/root/etc/e-smith/templates/etc/postfix/main.cf/64luser_relay_catchall @@ -1,7 +1,5 @@ { # we use the value of EmailUnknownUser (default to returntosender) - # this option night ignore all virtual_maps entries... like pseudonyms and groups in case of virtual domain - # see /etc/e-smith/templates//etc/postfix/virtual/95unknownusers - #return "# we bounce all unknown address $EmailUnknownUser not set or equal to returntosender " unless (defined $EmailUnknownUser and $EmailUnknownUser ne 'returntosender'); - #$OUT ="luser_relay = $EmailUnknownUser"; -}# if enabled, we catch all unknown users in virtual + return "# we bounce all unknown address $EmailUnknownUser not set or equal to returntosender " unless (defined $EmailUnknownUser and $EmailUnknownUser ne 'returntosender'); + $OUT ="luser_relay = $EmailUnknownUser"; +} diff --git a/root/etc/e-smith/templates/etc/postfix/main.cf/65heloname b/root/etc/e-smith/templates/etc/postfix/main.cf/65heloname index 233ae61..05a86b4 100644 --- a/root/etc/e-smith/templates/etc/postfix/main.cf/65heloname +++ b/root/etc/e-smith/templates/etc/postfix/main.cf/65heloname @@ -1 +1 @@ -smtp_helo_name = { $qpsmtpd{HeloHost} || '$myhostname'} +smtp_helo_name = { $qpsmtpd{HeloHost} || '$mydomain' } diff --git a/root/etc/e-smith/templates/etc/postfix/main.cf/86smtp_generic_maps b/root/etc/e-smith/templates/etc/postfix/main.cf/86smtp_generic_maps new file mode 100644 index 0000000..6ec4bf7 --- /dev/null +++ b/root/etc/e-smith/templates/etc/postfix/main.cf/86smtp_generic_maps @@ -0,0 +1,2 @@ +# rewrite addresse of outgoing emails +smtp_generic_maps = hash:/etc/postfix/generic diff --git a/root/etc/e-smith/templates/etc/postfix/virtual/05system b/root/etc/e-smith/templates/etc/postfix/virtual/05system index f8194b7..afcd349 100644 --- a/root/etc/e-smith/templates/etc/postfix/virtual/05system +++ b/root/etc/e-smith/templates/etc/postfix/virtual/05system @@ -15,7 +15,6 @@ root admin for my $acct ($adb->get_all_by_prop(type=>"system")) { - next if ($acct->key eq "admin"); next if ($acct->key eq "alias"); next if ($acct->key eq "shared"); next if ($acct->key eq "root"); diff --git a/root/etc/e-smith/templates/etc/postfix/virtual/06user b/root/etc/e-smith/templates/etc/postfix/virtual/06user index f5c5ac9..f054e1c 100644 --- a/root/etc/e-smith/templates/etc/postfix/virtual/06user +++ b/root/etc/e-smith/templates/etc/postfix/virtual/06user @@ -1,2 +1,19 @@ # SME users -# not needed postfix will map all system users directly +{ + my $dms = $DelegateMailServer; + + return "# DelegateMailServer is set" if ($dms && ($dms !~ /^\s*$/)); + + $OUT = ""; + + use esmith::AccountsDB; + + my $adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB"; + + for my $user ($adb->users) + { + #next unless ($pseudo->key =~ /@/); <== aliase to emails or catch-all @domain.com are ok + $OUT .= $user->key . "\t\t\t".$user->key."\n"; + } +} + diff --git a/root/etc/e-smith/templates/etc/postfix/virtual/95unknownusers b/root/etc/e-smith/templates/etc/postfix/virtual/95unknownusers index 81688f9..480ef15 100644 --- a/root/etc/e-smith/templates/etc/postfix/virtual/95unknownusers +++ b/root/etc/e-smith/templates/etc/postfix/virtual/95unknownusers @@ -1,7 +1,8 @@ { + return "" ; #not used # as we might have virtualdomains we prefer this over luser_relay return "# we bounce all unknown address $EmailUnknownUser not set or equal to returntosender " unless (defined $EmailUnknownUser and $EmailUnknownUser ne 'returntosender'); - $OUT = ""; + $OUT = "catch-all"; my $i = 0; use esmith::DomainsDB; my $ddb = esmith::DomainsDB->open_ro; diff --git a/root/sbin/e-smith/systemd/postfix-pre b/root/sbin/e-smith/systemd/postfix-pre index 2eddf84..db4ce00 100755 --- a/root/sbin/e-smith/systemd/postfix-pre +++ b/root/sbin/e-smith/systemd/postfix-pre @@ -2,10 +2,15 @@ /usr/sbin/e-smith/expand-template /etc/postfix/virtual /usr/sbin/e-smith/expand-template /etc/postfix/sasl_passwd /usr/sbin/e-smith/expand-template /etc/postfix/transport +/usr/sbin/e-smith/expand-template /etc/postfix/generic +/usr/sbin/e-smith/expand-template /etc/postfix/main.cf +/usr/sbin/e-smith/expand-template /etc/postfix/master.cf # sensitive file, we want to be sure. touch /etc/postfix/sasl_passwd.db chmod 0600 /etc/postfix/sasl_passwd.db chown root:root /etc/postfix/sasl_passwd.db +/usr/sbin/postmap /etc/aliases /usr/sbin/postmap /etc/postfix/virtual /usr/sbin/postmap /etc/postfix/sasl_passwd /usr/sbin/postmap /etc/postfix/transport +/usr/sbin/postmap /etc/postfix/generic diff --git a/root/sbin/e-smith/systemd/postfix-reload b/root/sbin/e-smith/systemd/postfix-reload index 6363a06..81a87b8 100755 --- a/root/sbin/e-smith/systemd/postfix-reload +++ b/root/sbin/e-smith/systemd/postfix-reload @@ -2,11 +2,16 @@ /usr/sbin/e-smith/expand-template /etc/postfix/virtual /usr/sbin/e-smith/expand-template /etc/postfix/sasl_passwd /usr/sbin/e-smith/expand-template /etc/postfix/transport +/usr/sbin/e-smith/expand-template /etc/postfix/generic +#TODO /usr/sbin/e-smith/expand-template /etc/postfix/main.cf +#TODO /usr/sbin/e-smith/expand-template /etc/postfix/master.cf # sensitive file, we want to be sure. touch /etc/postfix/sasl_passwd.db chmod 0600 /etc/postfix/sasl_passwd.db chown root:root /etc/postfix/sasl_passwd.db +/usr/sbin/postmap /etc/aliases /usr/sbin/postmap /etc/postfix/virtual /usr/sbin/postmap /etc/postfix/sasl_passwd /usr/sbin/postmap /etc/postfix/transport +/usr/sbin/postmap /etc/postfix/generic /usr/sbin/postfix reload diff --git a/smeserver-postfix.spec b/smeserver-postfix.spec index 9089d59..1c751a3 100644 --- a/smeserver-postfix.spec +++ b/smeserver-postfix.spec @@ -1,6 +1,6 @@ %define name smeserver-postfix %define version 1.0 -%define release 6 +%define release 7 Summary: This is what smeserver-postfix does. Name: %{name} Version: %{version} @@ -24,6 +24,11 @@ AutoReqProv: no Koozali SME Server wrapper to configure postfix %changelog +* Fri Dec 20 2024 Jean-Philippe Pialasse 1.0-7.sme +- fix catch-all behaviour [SME: 12382] + myorigin now is hostname + in case email sent outside by deamon generic rewrite occurs + * Sun Dec 15 2024 Jean-Philippe Pialasse 1.0-6.sme - add mini-qmail as Message delivery agent [SME: 12737] few other fixes; +x on needed executable files