From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api v2 1/2] sa-custom: move shadow config to the same directory
Date: Fri, 4 Oct 2024 15:47:01 +0200 [thread overview]
Message-ID: <20241004134702.14522-2-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20241004134702.14522-1-s.ivanov@proxmox.com>
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@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@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
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
next prev parent reply other threads:[~2024-10-04 13:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 13:47 [pmg-devel] [PATCH pmg-api v2 0/2] sa-custom: move shadow config next to live config Stoiko Ivanov
2024-10-04 13:47 ` Stoiko Ivanov [this message]
2024-10-04 13:47 ` [pmg-devel] [PATCH pmg-api v2 2/2] d/postinst: move pmg-scores.cf shadow file to new location Stoiko Ivanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241004134702.14522-2-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox