[pmg-devel] [PATCH pmg-api] adapt journalctl invocation to buster
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Aug 5 19:54:37 CEST 2019
With Debian Buster the behavior of `journalctl` has changed when it finds
no entries for a given selection:
* The exit code was 0 in stretch, but is 1 in buster
* The output changed slightly - a header got added
Since PMG::Utils::scan_journal_for_rbl_rejects uses journalctl for reading the
IPs blocked by postscreen it needs to adapt for the new behavior
(otherwise the journal gets filled with spurious log-messages)
The patch addresses the problem by checking the die-message for
'failed: exit code 1`, and ignoring the error if the '-- No entries --' line
was found and no rbl-counter got incremented
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
Thanks @Fabian for reporting the issue initially. I verified that the spamming
in the journal started after an experimental upgrade to buster.
src/PMG/Utils.pm | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
index aa6aac7..385b6d3 100644
--- a/src/PMG/Utils.pm
+++ b/src/PMG/Utils.pm
@@ -1298,6 +1298,7 @@ sub scan_journal_for_rbl_rejects {
my $rbl_count = 0;
my $pregreet_count = 0;
+ my $noentries = 0;
my $parser = sub {
my $line = shift;
@@ -1305,6 +1306,8 @@ sub scan_journal_for_rbl_rejects {
if ($line =~ m/^--\scursor:\s(\S+)$/) {
$rbl_scan_last_cursor = $1;
return;
+ } elsif ($line =~ m/^-- No entries --$/) {
+ $noentries = 1;
}
if ($line =~ m/\s$identifier\[\d+\]:\sNOQUEUE:\sreject:.*550 5.7.1 Service unavailable;/) {
@@ -1324,7 +1327,12 @@ sub scan_journal_for_rbl_rejects {
push @$cmd, "--since=@" . $rbl_scan_start_time;
}
- PVE::Tools::run_command($cmd, outfunc => $parser);
+ eval{ PVE::Tools::run_command($cmd, outfunc => $parser); };
+ my $err = $@;
+ if ($err) {
+ return if ( $err =~ m/failed: exit code 1$/ && $noentries == 1 && $rbl_count == 0 && $pregreet_count == 0);
+ die "$err\n";
+ }
return ($rbl_count, $pregreet_count);
}
--
2.20.1
More information about the pmg-devel
mailing list