public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [PATCH pmg-api] fix #3991: record changes to the smtp-welcomelist and reload postfix
Date: Fri, 13 Mar 2026 21:13:34 +0100	[thread overview]
Message-ID: <20260313201338.18613-1-s.ivanov@proxmox.com> (raw)

adding an entry to the postfix welcomelist needs a reload of postfix,
in order to become effective immediately.

the writer sub already reflects if a change happened in its return
value, we simply did not track that when deciding if postfix needs
reloading.

PMG::RuleDB::reload_ruledb is called with an argument only for the
smtp-welcomelist (which is a special case of ruledb object), for
regular objects it's called without (the API calls are generated in
all cases via PMG::RuleDB::Object::register_api).

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/PMG/Config.pm  | 13 ++++++++-----
 src/PMG/DBTools.pm |  3 ++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm
index 495fe702..1ded3bac 100644
--- a/src/PMG/Config.pm
+++ b/src/PMG/Config.pm
@@ -1837,10 +1837,13 @@ sub rewrite_postfix_welcomelist {
         }
     }
 
-    $write_smtp_welcomelist->("/etc/postfix/senderaccess", $fromlist);
-    $write_smtp_welcomelist->("/etc/postfix/rcptaccess", $tolist);
-    $write_smtp_welcomelist->("/etc/postfix/clientaccess", $clientlist);
-    $write_smtp_welcomelist->("/etc/postfix/postscreen_access", $clientlist, 'permit');
+    my $changes = 0;
+    $changes ||= $write_smtp_welcomelist->("/etc/postfix/senderaccess", $fromlist);
+    $changes ||= $write_smtp_welcomelist->("/etc/postfix/rcptaccess", $tolist);
+    $changes ||= $write_smtp_welcomelist->("/etc/postfix/clientaccess", $clientlist);
+    $changes ||= $write_smtp_welcomelist->("/etc/postfix/postscreen_access", $clientlist, 'permit');
+
+    return $changes;
 }
 
 # rewrite /etc/postfix/*
@@ -1868,7 +1871,7 @@ sub rewrite_config_postfix {
     postmap_tls_policy();
     postmap_tls_inbound_domains();
 
-    rewrite_postfix_welcomelist($rulecache) if $rulecache;
+    $changes ||= rewrite_postfix_welcomelist($rulecache) if $rulecache;
 
     # make sure aliases.db is up to date
     system('/usr/bin/newaliases');
diff --git a/src/PMG/DBTools.pm b/src/PMG/DBTools.pm
index ff54acb3..01bde582 100644
--- a/src/PMG/DBTools.pm
+++ b/src/PMG/DBTools.pm
@@ -1419,7 +1419,8 @@ sub reload_ruledb {
     if (defined($ruledb)) {
         eval {
             my $rulecache = PMG::RuleCache->new($ruledb);
-            PMG::Config::rewrite_postfix_welcomelist($rulecache);
+            my $changed = PMG::Config::rewrite_postfix_welcomelist($rulecache);
+            PMG::Utils::service_cmd('postfix', 'reload') if $changed;
         };
         warn "problems updating SMTP welcomelist - $@" if $@;
     }
-- 
2.47.3





                 reply	other threads:[~2026-03-13 20:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260313201338.18613-1-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal