From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1070078DD8 for ; Thu, 30 Jun 2022 15:51:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 011ED2F736 for ; Thu, 30 Jun 2022 15:51:18 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 30 Jun 2022 15:51:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A672643D97 for ; Thu, 30 Jun 2022 15:44:25 +0200 (CEST) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Thu, 30 Jun 2022 15:44:21 +0200 Message-Id: <20220630134421.24476-1-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.193 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [utils.pm, quarantine.pm] Subject: [pmg-devel] [PATCH pmg-api] utils: always load custom SpamAssassin descriptions X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 13:51:48 -0000 currently PMG::API2::Quarantine::decode_spaminfo is the only place where we call PMG::Utils::load_sa_descriptions. Should this ever change it still would make little sense to not read all available descriptions in the potential future callsite. Signed-off-by: Stoiko Ivanov --- small refactoring following the last patch from Dominik, since I had a testsetup ready src/PMG/API2/Quarantine.pm | 7 +------ src/PMG/Utils.pm | 9 +++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm index 59eb1af..592cad7 100644 --- a/src/PMG/API2/Quarantine.pm +++ b/src/PMG/API2/Quarantine.pm @@ -68,12 +68,7 @@ sub decode_spaminfo { my $res = []; return $res if !defined($info); - my $saversion = Mail::SpamAssassin->VERSION; - - my $salocaldir = "/var/lib/spamassassin/$saversion/updates_spamassassin_org"; - my $sacustomdir = "/etc/mail/spamassassin"; - - $spamdesc = PMG::Utils::load_sa_descriptions([$salocaldir, $sacustomdir]) if !$spamdesc; + $spamdesc = PMG::Utils::load_sa_descriptions() if !$spamdesc; foreach my $test (split (',', $info)) { my ($name, $score) = split (':', $test); diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm index cef232b..8d389c2 100644 --- a/src/PMG/Utils.pm +++ b/src/PMG/Utils.pm @@ -11,6 +11,7 @@ use File::stat; use POSIX qw(strftime); use File::stat; use File::Basename; +use Mail::SpamAssassin; use MIME::Entity; use MIME::Words; use MIME::Parser; @@ -1166,10 +1167,14 @@ sub bencode_header { sub load_sa_descriptions { my ($additional_dirs) = @_; + my $saversion = Mail::SpamAssassin->VERSION; + my @dirs = ('/usr/share/spamassassin', - '/usr/share/spamassassin-extra'); + '/usr/share/spamassassin-extra', + "/var/lib/spamassassin/$saversion/updates_spamassassin_org", + '/etc/mail/spamassassin'); - push @dirs, @$additional_dirs if @$additional_dirs; + push @dirs, @$additional_dirs if $additional_dirs; my $res = {}; -- 2.30.2