Skip to content

Doesn't find PulseAudio socket on systems without an XDG_RUNTIME_DIR #4058

Closed

Description

@smcv

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 /tmp that is pointed to by a symlink ~/.pulse/${machine_id}-runtime or ${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/pulse and 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=network then 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 info to verify
  • Get a shell in a Flatpak sandbox, and inspect $PULSE_SERVER and the contents of /run/user/$(id -u)
    • I used flatpak run --command=bash --socket=pulseaudio org.gnome.Weather
  • In that shell, run an application that should connect to PulseAudio
    • I used pactl info
  • Expected result: PULSE_SERVER is 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_SERVER is unset. The socket is not bind-mounted. PA clients fail to connect.
  • Workaround: export PULSE_SERVER=unix:/tmp/pulse-XXXXXX/native, replacing XXXXXX with the correct temporary directory listed in pactl info output, before launching the Flatpak app.

I think this is probably the root cause for #2169.

Activity

  1. added 2 commits that reference this issue on Jan 7, 2021
    86bc3e0
    c45fecd
  2. added a commit that references this issue on Jan 12, 2021
    2dc0006
  3. added a commit that references this issue on Jan 12, 2021
    fe95ef6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions