Repository navigation
Description
Linux distribution and version
Debian 10 'buster' with non-default sysvinit init system and without elogind. Also seen by others in:
- Slackware 14.2
- Void Linux
Probably reproducible in any distro/configuration that does not use one of: systemd-logind, elogind, pam-xdg-support (unmaintained), or some other implementation of XDG_RUNTIME_DIR from the fd.o basedir spec.
Flatpak version
Verified on Debian 10 with Flatpak 1.2.5, but the same issue appears in Steam's pressure-vessel tool, in code that was copied from approximately Flatpak 1.9.0. If we're fixing it in pressure-vessel then we might as well contribute the changes back to Flatpak.
Description of the problem
flatpak_run_add_pulseaudio_args() contains a simplified version of the code in libpulse.so.0 that locates a default PulseAudio server.
The real implementation in libpulse.so.0 tries the following:
$PULSE_SERVER, if set. Flatpak correctly tries this.- X11 properties, if run from a remote ssh connection. This is a significant amount of code and I think it would be pragmatic to ignore this in Flatpak. I'm definitely intending to ignore it in pressure-vessel.
${runtime}/native, where${runtime}can either be$PULSE_RUNTIME_PATH, or$XDG_RUNTIME_DIR/pulse, or a temporary directory in/tmpthat is pointed to by a symlink~/.pulse/${machine_id}-runtimeor${XDG_CONFIG_HOME:-$HOME/.config}/pulse/${machine_id}-runtime- where${machine_id}is either the contents of/etc/machine-id, or the contents of/var/lib/dbus/machine-id, or the hostname. Flatpak doesn't currently implement this fully: it assumes PulseAudio's runtime directory is always$XDG_RUNTIME_DIR/pulseand ignores the other possibilities./var/run/pulse/native(system-wide connection). Flatpak doesn't currently try this: see run: Try using /var/run/pulse/native as PulseAudio socket #4057 for an implementation.- Some TCP sockets, which are probably a bad idea to actually use. Flatpak doesn't need to do anything with these: if the Flatpak app has
--share=networkthen they'll work transparently, and if it doesn't, then it shouldn't be allowed to connect anyway.
Steps to reproduce
- Install Flatpak on an affected OS or installation
- Make sure a PulseAudio server is running, and use
pactl infoto verify - Get a shell in a Flatpak sandbox, and inspect
$PULSE_SERVERand the contents of/run/user/$(id -u)- I used
flatpak run --command=bash --socket=pulseaudio org.gnome.Weather
- I used
- In that shell, run an application that should connect to PulseAudio
- I used
pactl info
- I used
- Expected result:
PULSE_SERVERis set inside the sandbox, pointing to an AF_UNIX socket bind-mounted as/run/user/$(id -u)/pulse/native. PA clients work. - Actual result:
PULSE_SERVERis unset. The socket is not bind-mounted. PA clients fail to connect. - Workaround: export
PULSE_SERVER=unix:/tmp/pulse-XXXXXX/native, replacingXXXXXXwith the correct temporary directory listed inpactl infooutput, before launching the Flatpak app.
I think this is probably the root cause for #2169.
Activity
run: More accurately match PulseAudio's logic for finding its socket
run: More accurately match PulseAudio's logic for finding its socket
run: More accurately match PulseAudio's logic for finding its socket
run: More accurately match PulseAudio's logic for finding its socket