#1105096 snapclient: marlformed ExecStart= in systemd service

Package:
snapclient
Source:
snapclient
Description:
Snapcast client
Submitter:
aloo_shu
Date:
2025-05-11 05:15:02 UTC
Severity:
normal
Tags:
#1105096#5
Date:
2025-05-11 03:03:02 UTC
From:
To:
Dear Maintainer,

to reproduce, use the included conf file and start the systemwide snapclient.service

expected:         service starts and runs
what happens:     starts and deactivates
suspected cause:  ExecStart=/usr/bin/snapclient --logsink=system $SNAPCLIENT_OPTS in snapclient.service

systemd doesn't do shell-like variable substitution, you'd need to start the process in a shell
systemd has instead has its own fixed set of %-'speciefiers' for substitution, defined in man systemd.unit
luckily, including the SNAPCLIENT_OPTS with the ExecStart= directive, is redundant, since snapclient
reads SNAPCLIENT_OPTS from its environment, and the EnvironmentFile=-/etc/default/snapclient directive
sources the environment from the conf file. Hence,

suggested patch: ExecStart=/usr/bin/snapclient --logsink=system , without the malformed variable

AFAICT, the bug affects not only this version

probably bad practice to mention two bugs in one report, but fwiw, snapclient apparantly also has a
non-robust way of managing its pidfile: running snapclient from the commandline as root once, then killing
it, can lead to Exception: Could not open PID lock file "/var/run/snapclient/pid" and failure of the
service later, alas, I'm failing to reproduce this now that I'd like to give exact steps

#1105096#10
Date:
2025-05-11 05:10:48 UTC
From:
To:
the option man snapclient suggests for changing niceness, is --daemon=<nice value>, and that's what I'm doing in my conf file, but the systemd service in its current form is of type simple, and expects the main process to run, not fork and daemonize

that's fixable with

[Service] Type=forking
Nice=-20 EnvironmentFile=-/etc/default/snapclient ExecStart=/usr/bin/snapclient --logsink=system --daemon=-3 $SNAPCLIENT_OPTS
[..]

like this, systemd will always run snapclient as a daemon. passing the --daemon option in the conf file, becomes safe. Nice=-20 will be overridden by --daemon=-3 (the default as per manpage, but although desirable, doesn't happen), and latter --daemon=<nice value> options sourced from the conf file, will be allowed all values

apparantly, systemd does the variable substitution after all

arguably, setting niceness is a core functionality for ensuring an audio streaming service's smooth and glitch-less operation, which could raise the bug severity