[pmg-devel] [PATCH pmg-api] fix #5966: ruledb: modify header: log action

Stoiko Ivanov s.ivanov at proxmox.com
Thu Oct 2 16:30:57 CEST 2025


ModField (modify header) is the only action which we currently do not
log. Originally I skipped it explicitly, expecting this to add too
many lines on an average system. However it does prevent some
situations from being debugged correctly (as laid out in #5966), and
I don't think that the argument of too many log-lines outweighs that.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
minimally tested on my pmg-setup (with mails to discard€@testdomain,
discard at testdomain) to verify the logs look ok.

 src/PMG/RuleDB/ModField.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/PMG/RuleDB/ModField.pm b/src/PMG/RuleDB/ModField.pm
index 849726f8..bf08a18e 100644
--- a/src/PMG/RuleDB/ModField.pm
+++ b/src/PMG/RuleDB/ModField.pm
@@ -6,6 +6,8 @@ use DBI;
 use Digest::SHA;
 use Encode qw(encode decode);
 
+use PVE::SafeSyslog;
+
 use PMG::Utils;
 use PMG::ModGroup;
 use PMG::RuleDB::Object;
@@ -100,9 +102,20 @@ sub execute {
 
     my $subgroups = $mod_group->subgroups($targets);
 
+    my $rulename = encode('UTF-8', $vars->{RULE} // 'unknown');
+
     foreach my $ta (@$subgroups) {
         my ($tg, $e) = (@$ta[0], @$ta[1]);
         $e->head->replace($self->{field}, $fvalue);
+        my $targets = join('>, <', @$tg);
+        syslog(
+            'info',
+            "%s: modified header '%s' for <%s> (rule: %s)",
+            $queue->{logid},
+            encode('UTF-8', $self->{field}),
+            encode('UTF-8', $targets),
+            $rulename,
+        );
     }
 }
 
-- 
2.47.3





More information about the pmg-devel mailing list