pmg-scores.cf not being updated

Mar 19, 2022
9
0
1
54
Hi Everyone,

I noticed today that a change to my custom scores hadn't been applied after applying it and restarting pmg-smtp-filter via the GUI. I get no errors from the GUI and can't find anything in /var/log that looks strange, but the update is not applied and the "pending changes" diff at the bottom of the screen never goes away and "details" shows "Status stopped: OK". This is a 2 node cluster, but pmgcm sync completes without errors. When I click apply (on either GUI):

On the master:
/var/cache/pmg-scores.cf is updated
/etc/mail/spamassassin/pmg-scores.cf is not updated

On the node:
/var/cache/pmg-scores.cf does not exist
/etc/mail/spamassassin/pmg-scores.cf is not updated
/etc/pmg/master/pmg-scores.cf is not updated

I have tried completely nuking the file and starting from scratch, adding a single rule, and this did not resolve the issue - that single rule just hangs:

--- /etc/mail/spamassassin/pmg-scores.cf 2022-03-23 22:17:21.041786351 -0600
+++ /var/cache/pmg-scores.cf 2022-03-23 22:29:42.351029387 -0600
@@ -0,0 +1 @@
+score SPF_FAIL 1.000

I hav etried restarting services and rebooting the VMs. Any idea where to look next?
 
Can someone from proxmox please at least explain how this is *supposed* to work? Or give me some direction so I can provide more useful info?
 
if you click applying (and check the restart box) you do everything right, it should apply the config and restart pmg-smtp-filter. other cluster nodes should get that file on the next sync
and apply it themselves.

i just tested it here and it works without any issues...

can you post the output of 'pmgversion -v' of both nodes?
to which node are you connected to the webui?
can you post the syslog from before you try to edit to after the sync after you applied (or tried to applied) the change?
 
Thanks for the reply!

It doesn't matter which node GUI I use, the result is the same, but usually the master. The result, every time, is that a file is created in /var/cache, but the file in /etc/mail/spamassassin is not modified. Feels like a permissions issue.

From the master:
proxmox-mailgateway: 7.1-1 (API: 7.1-2/75d043b3, running kernel: 5.13.19-6-pve)
pmg-api: 7.1-2
pmg-gui: 3.1-2
pve-kernel-helper: 7.1-13
pve-kernel-5.13: 7.1-9
pve-kernel-5.13.19-6-pve: 5.13.19-14
pve-kernel-5.13.19-4-pve: 5.13.19-9
pve-kernel-5.13.19-3-pve: 5.13.19-7
clamav-daemon: 0.103.5+dfsg-0+deb11u1
ifupdown: 0.8.36+pve1
libarchive-perl: 3.4.0-1
libjs-extjs: 7.0.0-1
libjs-framework7: 4.4.7-1
libproxmox-acme-perl: 1.4.1
libproxmox-acme-plugins: 1.4.1
libpve-apiclient-perl: 3.2-1
libpve-common-perl: 7.1-5
libpve-http-server-perl: 4.1-1
libxdgmime-perl: 1.0-1
lvm2: 2.03.11-2.1
pmg-docs: 7.1-2
pmg-i18n: 2.6-2
pmg-log-tracker: 2.3.1-1
postgresql-13: 13.5-0+deb11u1
proxmox-mini-journalreader: 1.3-1
proxmox-spamassassin: 3.4.6-4
proxmox-widget-toolkit: 3.4-7
pve-firmware: 3.3-6
pve-xtermjs: 4.16.0-1
vncterm: not correctly installed
zfsutils-linux: 2.1.2-pve1



From the node:
proxmox-mailgateway: 7.1-1 (API: 7.1-2/75d043b3, running kernel: 5.13.19-6-pve)
pmg-api: 7.1-2
pmg-gui: 3.1-2
pve-kernel-helper: 7.1-13
pve-kernel-5.13: 7.1-9
pve-kernel-5.13.19-6-pve: 5.13.19-14
pve-kernel-5.13.19-4-pve: 5.13.19-9
pve-kernel-5.13.19-3-pve: 5.13.19-7
clamav-daemon: 0.103.5+dfsg-0+deb11u1
ifupdown: 0.8.36+pve1
libarchive-perl: 3.4.0-1
libjs-extjs: 7.0.0-1
libjs-framework7: 4.4.7-1
libproxmox-acme-perl: 1.4.1
libproxmox-acme-plugins: 1.4.1
libpve-apiclient-perl: 3.2-1
libpve-common-perl: 7.1-5
libpve-http-server-perl: 4.1-1
libxdgmime-perl: 1.0-1
lvm2: 2.03.11-2.1
pmg-docs: 7.1-2
pmg-i18n: 2.6-2
pmg-log-tracker: 2.3.1-1
postgresql-13: 13.5-0+deb11u1
proxmox-mini-journalreader: 1.3-1
proxmox-spamassassin: 3.4.6-4
proxmox-widget-toolkit: 3.4-7
pve-firmware: 3.3-6
pve-xtermjs: 4.16.0-1
vncterm: not correctly installed
zfsutils-linux: 2.1.2-pve1


Log:
Mar 29 22:05:42 pmg-001 pmgdaemon[12469]: re-starting service pmg-smtp-filter: UPID:pmg-001:000030B5:00056DDD:6243D716:applycustomscores::root@pam:
Mar 29 22:05:42 pmg-001 pmgdaemon[1417]: starting task UPID:pmg-001:000030B5:00056DDD:6243D716:applycustomscores::root@pam:
Mar 29 22:05:42 pmg-001 systemd[1]: Stopping Proxmox SMTP Filter Daemon...
Mar 29 22:05:42 pmg-001 systemd[1]: pmg-smtp-filter.service: Succeeded.
Mar 29 22:05:42 pmg-001 systemd[1]: Stopped Proxmox SMTP Filter Daemon.
Mar 29 22:05:42 pmg-001 systemd[1]: pmg-smtp-filter.service: Consumed 1min 53.458s CPU time.
Mar 29 22:05:42 pmg-001 systemd[1]: Starting Proxmox SMTP Filter Daemon...
Mar 29 22:05:43 pmg-001 systemd[1]: Started Proxmox SMTP Filter Daemon.
Mar 29 22:05:43 pmg-001 pmgdaemon[1417]: end task UPID:pmg-001:000030B5:00056DDD:6243D716:applycustomscores::root@pam: OK
 
the log is a bit short (i doubt you edited & clicked apply in 1 second ;) )

also, the code applying the scores is basically a
Code:
mv /var/cache/pmg-scores.cf /etc/mail/spamassassin/pmg-scores.cf

there's not much that can fail...


can you post the task log of that 'applycustomscores' task ? (Administration -> Tasks -> double click on the task)
 
What kids of things are you looking for in syslog? I have rsyslogd not logging mail logs in /var/log/syslog, so that's all that gets logged there. The only thing of interest that I can see in the mail log is:

Mar 30 21:07:56 pmg-001 pmg-smtp-filter[9017]: 2022/03/30-21:07:56 Server closing!
Mar 30 21:07:57 pmg-001 pmg-smtp-filter[11367]: Process Backgrounded
Mar 30 21:07:57 pmg-001 pmg-smtp-filter[11367]: 2022/03/30-21:07:57 main (type Net::Server::preFork) starting! pid(11367)
Mar 30 21:07:57 pmg-001 pmg-smtp-filter[11367]: Binding to TCP port 10023 on host 127.0.0.1 with IPv4
Mar 30 21:07:57 pmg-001 pmg-smtp-filter[11367]: Binding to TCP port 10024 on host 127.0.0.1 with IPv4
Mar 30 21:07:57 pmg-001 pmg-smtp-filter[11367]: Group Not Defined. Defaulting to EGID '0'
Mar 30 21:07:57 pmg-001 pmg-smtp-filter[11367]: User Not Defined. Defaulting to EUID '0'
Mar 30 21:07:57 pmg-001 pmg-smtp-filter[11367]: Setting up serialization via flock
Mar 30 21:07:57 pmg-001 pmg-smtp-filter[11367]: Filter daemon (re)started (max. 40 processes)


The task log is:
Mar 30 21:07:57 pmg-001 pmgdaemon[1722]: end task UPID:pmg-001:00002C2D:000303AD:62451B02:applycustomscores::root@pam: OK


Can this be run from the CLI? I could strace it then. As it is, with everything deleted, starting from scratch, I end up with no pmg-scores.cf file in /etc/mail/spamassassin/. The only thing of interest I can think of is that /var is its own partition.
 
What kids of things are you looking for in syslog? I have rsyslogd not logging mail logs in /var/log/syslog, so that's all that gets logged there. The only thing of interest that I can see in the mail log is:
i don't exactly know, but i'd probably know it if i'd see it

The task log is:
no thats only the result of the task that gets logged, i meant the complete task log. Click on 'Administration->Tasks, look for the custom scores task and double click it. a window should open with some content (at least 'Task OK')

Can this be run from the CLI? I could strace it then. As it is, with everything deleted, starting from scratch, I end up with no pmg-scores.cf file in /etc/mail/spamassassin/. The only thing of interest I can think of is that /var is its own partition.
i mean yes you can, but the strace output is not pretty (it's perl after all^^)
Code:
strace -fyy pmgsh set /config/customscores
 
It looks to me like using rename to copy a file across partitions (/var being its own partition) is failing, but the script is returning "TASK OK" anyhow.

[pid 653419] stat("/var/cache/pmg-scores.cf", {st_mode=S_IFREG|0644, st_size=241, ...}) = 0 [pid 653419] rename("/var/cache/pmg-scores.cf", "/etc/mail/spamassassin/pmg-scores.cf") = -1 EXDEV (Invalid cross-device link) [pid 653419] write(11<pipe:[7727533]>, "TASK OK\n", 8) = 8
 
Yeah, I was able to "fix" this with move instead of rename inside SACustom.pm - I'm sure that changing the shadow path to somplace on the / partition would be preferable, (/tmp?) but I can't figure out where that's set and this issue has already burned way more hours than I could afford to spend on it.

--- SACustom.pm.BAK 2022-03-31 20:53:54.158006752 -0600 +++ SACustom.pm 2022-03-31 21:30:32.271634527 -0600 @@ -6,6 +6,9 @@ use PVE::INotify; use Digest::SHA; +### ADDED FOR TESTING +use File::Copy qw(move); + my $shadow_path = "/var/cache/pmg-scores.cf"; my $conf_path = "/etc/mail/spamassassin/pmg-scores.cf"; @@ -14,7 +17,8 @@ } sub apply_changes { - rename($shadow_path, $conf_path) if -f $shadow_path; + ###rename($shadow_path, $conf_path) if -f $shadow_path; + move($shadow_path, $conf_path) if -f $shadow_path; } sub calc_digest {
 
ah ok, did not see that /var is on another filesystem

mhmm... can you open a bug for that on https://bugzilla.proxmox.com ?
using File::Copy::move is probably not the way to go here, since it's not atomic and if it fails leaves the target in an undefined (possibly partial) state, which would make matters even worse
 
OK, when I get a chance I'll get that ticket open. Unfortunately, the company that I'm helping needs someone doing sysadmin/network/etc full time, but they don't have that person.

I agree that "move" is not the best option, which is why I was hoping to just change the shadow_path to somewhere else. However, for now it works so people at this company can make changes via the GUI.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!