users for snapclient and snapserver daemon

This commit is contained in:
badaix 2017-02-07 20:11:49 +01:00
parent 88cf84aa50
commit 0f2359c971
11 changed files with 64 additions and 22 deletions

View file

@ -101,7 +101,7 @@ else
install:
$(MAKE) adduser
$(MAKE) installfiles
install -g audio -o snapcast -d /var/run/$(BIN)
install -g audio -o snapclient -d /var/run/$(BIN)
@if [[ `systemctl` =~ -\.mount ]]; then \
$(MAKE) installsystemd; \
@ -135,8 +135,8 @@ installsysv:
/etc/init.d/$(BIN) start; \
adduser:
@if ! getent passwd snapcast >/dev/null; then \
adduser --quiet --ingroup audio --system --no-create-home --home /var/lib/snapcast snapcast; \
@if ! getent passwd snapclient >/dev/null; then \
adduser --quiet --ingroup audio --system --no-create-home --home /var/lib/snapclient snapclient; \
fi; \
ifeq ($(TARGET), MACOS)
@ -184,5 +184,5 @@ uninstallsystemd:
systemctl daemon-reload; \
deluser:
@deluser --quiet --system snapcast > /dev/null || true
@deluser --quiet --system snapclient > /dev/null || true

View file

@ -48,7 +48,7 @@ do_start()
PIDDIR=$(dirname "$PIDFILE")
if [ ! -d "$PIDDIR" ]; then
mkdir -m 0755 $PIDDIR
chown snapcast:audio $PIDDIR
chown snapclient:audio $PIDDIR
fi
# Return

View file

@ -7,9 +7,9 @@ ACTION="$1"
VERSION="$2"
if [ "$ACTION" = "configure" ]; then
# add the snapcast user
if ! getent passwd snapcast >/dev/null; then
adduser --quiet --ingroup audio --system --no-create-home snapcast
# add the snapclient user
if ! getent passwd snapclient >/dev/null; then
adduser --quiet --ingroup audio --system --no-create-home snapclient
fi
fi

View file

@ -3,15 +3,15 @@
set -e
if [ "$1" = "purge" ]; then
# clean up all statoverrides that belonged to snapcast, so the
# snapcast system user can be removed cleanly
for i in $(dpkg-statoverride --list | awk '/^snapcast / {print $4}'); do
# clean up all statoverrides that belonged to snapclient, so the
# snapclient system user can be removed cleanly
for i in $(dpkg-statoverride --list | awk '/^snapclient / {print $4}'); do
if dpkg-statoverride --list --quiet "$i" >/dev/null; then
dpkg-statoverride --force --quiet --remove "$i"
fi
done
deluser --quiet --system snapcast > /dev/null || true
deluser --quiet --system snapclient > /dev/null || true
fi
#DEBHELPER#

View file

@ -160,7 +160,10 @@ int main (int argc, char **argv)
if (daemonOption.isSet())
{
#ifdef HAS_DAEMON
daemonize("snapcast", "audio", "/var/run/snapclient/pid." + cpt::to_string(instance));
string pidFile = "/var/run/snapclient/pid";
if (instance != 1)
pidFile += "." + cpt::to_string(instance);
daemonize("snapclient", "audio", pidFile);
if (processPriority < -20)
processPriority = -20;
else if (processPriority > 19)