Package: spamd Version: 4.0.0-4 Severity: wishlist X-Debbugs-Cc: [email protected]
Dear Maintainer Spamd allows communication via unix sockets as an alternative to the default tcp localhost. Unfortunately, this doesn't work if you want to have spamd drop privileges to non-root user for its child processes via its commandline parameters. Further, the creation of a runtime directory to contain the socket files via RuntimeDirectory parameter is not possible currently. Example: relevant part from OPTIONS parameter in /etc/default/spamd "<other options> -u debian-spamd -g debian-spamd --socketpath=/run/spamd/spamd.sock --socketmode=600 --socketowner=debian-spamd --socketgroup=debian-spamd" This does not work with the shipped systemd unit file for several reasons: - unit running as non-root isn't configurable - simply overriding User isn't possible because daemon needs root at start - daemon spawning less-privileged childs isn't mirrored in the unit file - no RuntimeDirectory configurable, eg. /run/spamd (neither via override nor via /etc/default/) and results in the daemon unable to startup. Issue exists on both bullseye and bookworm. The way the unit file is written, it can not easily be fixed with an override file unless you completely replace the packeted unit file. Additionally there are two bonus features that would make configuration cleaner: - Variable substitution for not writing the same config parameter 3 times - Don't hardcode the pid file path, so it can be inside the runtime directory I'd like to create a patch to address these issues, using the following improvements: - Add configurable RuntimeDirectory to unit file - Use the systemd way of using RuntimeDirectory in a daemon which spawns less-privileged childs as per [1] - Take the systemd way of using shellscripts to allow variable substitution in configuration as per [2] - Restructure /etc/default/spamd to a similar format as the one for spamass-milter - Make pid file really configurable - Additionally, make sure the behaviour of /etc/init.d/spamd is the same as the systemd unit file. As these are several changes, I'd like to ask beforehand whether I should split this into multiple patches, split into multiple debian bugs, or leave out some of these changes completely. Or you can tell me this will not be fixed, in which case I won't bother. Be aware that the proposed changes would probably also improve: - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=292939#20 - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=486914 - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=743872 - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=712564 Additionally I could fix this while I'm at it: - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=955571 If any sysadmin runs into the same issue, here's a fix you can use in the meantime to get a runtime dir where the nonroot childs can create sockets. Create an override /etc/systemd/system/spamd.service.d/override.conf for the unit file with this content: [Service] # create directory before daemon start, and give it correct permissions ExecStartPre=/usr/bin/mkdir -m 770 -p /run/spamd ExecStartPre=/usr/bin/chown -v debian-spamd:debian-spamd /run/spamd # remove directory again on service shutdown or crash ExecStopPost=/usr/bin/rm -r /run/spamd This emulates a proper unit file's RuntimeDirectory setting. The alternative would be to completely replace the shipped unit file including the ExecStart line according to [1]. Another option would be to not tie the sockets and containing directory to the daemon lifecycle, in which case you could either use /var/lib/spamassassin or create /run/spamd using systemd-tmpfiles. I haven't tested that, maybe it'll lead to problems if the daemon crashes and leaves behind socket files that aren't cleaned up. [1] https://github.com/systemd/systemd/issues/8560#issuecomment-375701123 [2] https://github.com/systemd/systemd/issues/2123#issuecomment-163019609 -- System Information: Debian Release: bookworm/sid APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 6.1.0-2-amd64 (SMP w/1 CPU thread; PREEMPT) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages spamd depends on: ii init-system-helpers 1.65.2 ii rsyslog [system-log-daemon] 8.2212.0-1 ii spamassassin 4.0.0-4 ii systemd 252.4-2 spamd recommends no packages. spamd suggests no packages. -- Configuration Files: /etc/default/spamd changed: OPTIONS="--nouser-config --max-children 5 --helper-home-dir -u debian-spamd -g debian-spamd --socketpath=/run/spamd/spamd.sock --socketmode=600 --socketowner=debian-spamd --socketgroup=debian-spamd" PIDFILE="/run/spamd.pid" CRON=0 -- no debconf information

