[pmg-devel] [PATCH pmg-api v2 1/2] sa-custom: move shadow config to the same directory
Stoiko Ivanov
s.ivanov at proxmox.com
Fri Oct 4 15:47:01 CEST 2024
keeping the shadow-file in /var/cache breaks their application if
/var/cache is on another filesystem than /etc/mail/spamassassin.
Perl's `rename` function [0], which is a wrapper for rename(2).
`rename` does not work across filesystem boundaries (errors out with
EXDEV).
having `/var` on another filesystem is becoming less common, but
should probably be supported.
Instead of using some other means of file moving, just put the
shadow file in the same directory as pmg-scores.cf.
SpamAssassin only reads files ending in .(cf|pre)$ from its
config-dirs, so having both files in the same directory should not be
an issue. The use of '.new' for the shadow-file follows the naming for
/etc/network/interfaces(.new).
reported in our community-forum:
https://forum.proxmox.com/threads/.154814/
tested in a container with a seperate volume for `/var/cache`.
[0] https://perldoc.perl.org/functions/rename
[1] https://github.com/apache/spamassassin/blob/trunk/README
Suggested-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
src/PMG/SACustom.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/PMG/SACustom.pm b/src/PMG/SACustom.pm
index f91ebf2..21e8ff4 100644
--- a/src/PMG/SACustom.pm
+++ b/src/PMG/SACustom.pm
@@ -6,15 +6,17 @@ use warnings;
use PVE::INotify;
use Digest::SHA;
-my $shadow_path = "/var/cache/pmg-scores.cf";
my $conf_path = "/etc/mail/spamassassin/pmg-scores.cf";
+my $shadow_path = "$conf_path.new";
sub get_shadow_path {
return $shadow_path;
}
sub apply_changes {
- rename($shadow_path, $conf_path) if -f $shadow_path;
+ if (-f $shadow_path) {
+ rename($shadow_path, $conf_path) || die 'failed to apply custom scores - $!\n';
+ }
}
sub calc_digest {
--
2.39.5
More information about the pmg-devel
mailing list