I am trying to setup SpamAssassin on my mail server (Rocky Linux 9.5). Just a basic setup!
This is the options variable at /etc/sysconfig/spamassassin:
SPAMDOPTIONS="-d -c -m5 -H --create-prefs --max-children 2 -u spamd -g spamd --socketpath=/var/lib/spamassassin/spamd.sock --socketowner=spamd --socketgroup=spamd --socketmode=0666 -s /var/log/spamd.log --debug"
--debugwas added temporarity
When I start SpamAssassin using systemctl, it exits with random errors and systemd restarts it again, I put the truncated log below:
.
.
Fri Feb 14 19:59:03 2025 [2133] info: spamd: server successfully spawned child process, pid 2135
Fri Feb 14 19:59:03 2025 [2133] dbg: prefork: child 2135: entering state 0
Fri Feb 14 19:59:03 2025 [2133] dbg: prefork: new lowest idle kid: none
Fri Feb 14 19:59:03 2025 [2135] dbg: spamd: Privilege de-escalation from user 0 and groups 0
Fri Feb 14 19:59:03 2025 [2135] dbg: spamd: setgid ERRNO is
Fri Feb 14 19:59:03 2025 [2135] dbg: util: get_user_groups: uid is 98
Fri Feb 14 19:59:03 2025 [2133] info: spamd: server successfully spawned child process, pid 2136
Fri Feb 14 19:59:03 2025 [2133] dbg: prefork: child 2136: entering state 0
Fri Feb 14 19:59:03 2025 [2133] dbg: prefork: new lowest idle kid: none
Fri Feb 14 19:59:03 2025 [2136] dbg: spamd: Privilege de-escalation from user 0 and groups 0
Fri Feb 14 19:59:03 2025 [2136] dbg: spamd: setgid ERRNO is
Fri Feb 14 19:59:03 2025 [2136] dbg: util: get_user_groups: uid is 98
Fri Feb 14 19:59:03 2025 [2133] info: spamd: server killed by SIGTERM, shutting down
Fri Feb 14 19:59:04 2025 [2137] dbg: logger: successfully added file method
.
.
I decided to use the following command and run spamd from cli both foreground and daemonized, it worked flawlessly!
sudo -u spamd -- spamd -c -m5 -H --create-prefs --max-children 2 -u spamd -g spamd --socketpath=/var/lib/spamassassin/spamd.sock --socketowner=spamd --socketgroup=spamd --socketmode=0666 -s /var/log/spamd.log --debug
It also works correctly without sudo!
Has anyone ran into similar issue with SpamAssassin or any other services?
sudois unnecessary insystemdscripts - they already run as UID 0 (root).$PATH. Use absolute paths (starting with/) for EVERYTHING (programs, data files, erc)