We disallow autospawning for root, but when using systemd socket activation to start pulseaudio, that replaces the autospawning mechanism, and there was no similar "root protection" in socket activation. This patch disables the socket activation for root. --- src/daemon/systemd/user/pulseaudio.socket | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/daemon/systemd/user/pulseaudio.socket b/src/daemon/systemd/user/pulseaudio.socket index 332ece893..c428b9b3b 100644 --- a/src/daemon/systemd/user/pulseaudio.socket +++ b/src/daemon/systemd/user/pulseaudio.socket @@ -6,5 +6,20 @@ Priority=6 Backlog=5 ListenStream=%t/pulse/native +# We don't want to enable socket activation for root, because alsa device +# handover doesn't work between root and normal users. +# +# Using ExecStartPre is not quite ideal, because the unit state becomes +# "failed", which can make people think that something went wrong, even though +# this is normal behaviour. A better solution would be to use +# ConditionCapability=!CAP_SYS_ADMIN, but that didn't work for some reason on +# a Debian system (in February 2017), so it seems best to not use that. There's +# a bug report about the capability check failure: +# https://github.com/systemd/systemd/issues/5296 +# +# A request has been submitted for a more straightforward way to make units +# conditional based on the user: https://github.com/systemd/systemd/issues/5187 +ExecStartPre=/bin/sh -c '/usr/bin/test $(/usr/bin/whoami) != "root"' + [Install] WantedBy=sockets.target -- 2.11.0