[pulseaudio-discuss] [PATCH v3] systemd: disable socket activation for root

Tanu Kaskinen tanuk at iki.fi
Tue Feb 14 09:06:40 UTC 2017


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 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/daemon/systemd/user/pulseaudio.socket b/src/daemon/systemd/user/pulseaudio.socket
index 332ece893..cdaee5b77 100644
--- a/src/daemon/systemd/user/pulseaudio.socket
+++ b/src/daemon/systemd/user/pulseaudio.socket
@@ -6,5 +6,15 @@ 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 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



More information about the pulseaudio-discuss mailing list