[pmg-devel] [PATCH pmg-api v2 2/2] Add default rulename of 'unknown' to Actions

Stoiko Ivanov s.ivanov at proxmox.com
Thu Jun 6 11:26:38 CEST 2019


To provide a better experience while logging - set the name to 'unknown' in
case it's not defined. Related to #2232

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 PMG/RuleDB/Accept.pm     | 2 +-
 PMG/RuleDB/BCC.pm        | 2 +-
 PMG/RuleDB/Block.pm      | 2 +-
 PMG/RuleDB/Notify.pm     | 2 +-
 PMG/RuleDB/Quarantine.pm | 2 +-
 PMG/RuleDB/Remove.pm     | 2 +-
 PMG/RuleDB/ReportSpam.pm | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/PMG/RuleDB/Accept.pm b/PMG/RuleDB/Accept.pm
index 1387e24..79fb0d8 100644
--- a/PMG/RuleDB/Accept.pm
+++ b/PMG/RuleDB/Accept.pm
@@ -91,7 +91,7 @@ sub execute {
 
     my $subgroups = $mod_group->subgroups($targets, 1);
 
-    my $rulename = $vars->{RULE};
+    my $rulename = $vars->{RULE} // 'unknown';
 
     foreach my $ta (@$subgroups) {
 	my ($tg, $entity) = (@$ta[0], @$ta[1]);
diff --git a/PMG/RuleDB/BCC.pm b/PMG/RuleDB/BCC.pm
index cbe2810..be695f7 100644
--- a/PMG/RuleDB/BCC.pm
+++ b/PMG/RuleDB/BCC.pm
@@ -114,7 +114,7 @@ sub execute {
 
     my $subgroups = $mod_group->subgroups($targets, 1);
 
-    my $rulename = $vars->{RULE};
+    my $rulename = $vars->{RULE} // 'unknown';
 
     my $bcc_to = PMG::Utils::subst_values($self->{target}, $vars);
 
diff --git a/PMG/RuleDB/Block.pm b/PMG/RuleDB/Block.pm
index c7c640e..c758787 100644
--- a/PMG/RuleDB/Block.pm
+++ b/PMG/RuleDB/Block.pm
@@ -89,7 +89,7 @@ sub execute {
     my ($self, $queue, $ruledb, $mod_group, $targets, 
 	$msginfo, $vars, $marks) = @_;
 
-    my $rulename = $vars->{RULE};
+    my $rulename = $vars->{RULE} // 'unknown';
 
     if ($msginfo->{testmode}) {
 	my $fh = $msginfo->{test_fh};
diff --git a/PMG/RuleDB/Notify.pm b/PMG/RuleDB/Notify.pm
index 20d87af..860b5ce 100644
--- a/PMG/RuleDB/Notify.pm
+++ b/PMG/RuleDB/Notify.pm
@@ -207,7 +207,7 @@ sub execute {
 
     my $from = 'postmaster';
 
-    my $rulename = $vars->{RULE};
+    my $rulename = $vars->{RULE} // 'unknown';
 
     my $body = PMG::Utils::subst_values($self->{body}, $vars);
     my $subject = PMG::Utils::subst_values($self->{subject}, $vars);
diff --git a/PMG/RuleDB/Quarantine.pm b/PMG/RuleDB/Quarantine.pm
index 487fa6e..aaa8623 100644
--- a/PMG/RuleDB/Quarantine.pm
+++ b/PMG/RuleDB/Quarantine.pm
@@ -89,7 +89,7 @@ sub execute {
     
     my $subgroups = $mod_group->subgroups($targets, 1);
 
-    my $rulename = $vars->{RULE};
+    my $rulename = $vars->{RULE} // 'unknown';
 
     foreach my $ta (@$subgroups) {
 	my ($tg, $entity) = (@$ta[0], @$ta[1]);
diff --git a/PMG/RuleDB/Remove.pm b/PMG/RuleDB/Remove.pm
index 551fb97..e610532 100644
--- a/PMG/RuleDB/Remove.pm
+++ b/PMG/RuleDB/Remove.pm
@@ -171,7 +171,7 @@ sub execute {
     my ($self, $queue, $ruledb, $mod_group, $targets,
 	$msginfo, $vars, $marks) = @_;
 
-    my $rulename = $vars->{RULE};
+    my $rulename = $vars->{RULE} // 'unknown';
 
     if (!$self->{all} && ($#$marks == -1)) {
 	# no marks
diff --git a/PMG/RuleDB/ReportSpam.pm b/PMG/RuleDB/ReportSpam.pm
index a3e06ee..e0ac004 100644
--- a/PMG/RuleDB/ReportSpam.pm
+++ b/PMG/RuleDB/ReportSpam.pm
@@ -85,7 +85,7 @@ sub execute {
     my ($self, $queue, $ruledb, $mod_group, $targets, 
 	$msginfo, $vars, $marks) = @_;
 
-    my $rulename = $vars->{RULE};
+    my $rulename = $vars->{RULE} // 'unknown';
 
     my $subgroups = $mod_group->subgroups($targets);
 
-- 
2.11.0




More information about the pmg-devel mailing list