Skip to content

Multiple instances of the same app don't share XDG_RUNTIME_DIR #4120

Closed

Description

@smcv

Linux distribution and version

Debian unstable

Flatpak version

1.10.1

Description of the problem

Two instances of the same app don't share most of XDG_RUNTIME_DIR. This seems inconsistent with the spec, and in particular means that if they try to communicate via app-specific sockets or flag-files in $XDG_RUNTIME_DIR, each one will usually think it's the only instance, whereas if they were running in a non-Flatpak environment, they'd communicate.

This is similar to #4091, and might make sense to fix as part of #4093.

Steps to reproduce

Have two terminals or tabs.

In the first:

host$ flatpak run --command=bash org.gnome.Recipes
[Recipes]$ touch $XDG_RUNTIME_DIR/1a
[Recipes]$ touch $XDG_RUNTIME_DIR/app/$FLATPAK_ID/1b

In the second:

host$ flatpak run --command=bash org.gnome.Recipes
[Recipes]$ touch $XDG_RUNTIME_DIR/2a
[Recipes]$ touch $XDG_RUNTIME_DIR/app/$FLATPAK_ID/2b

In both:

[Recipes]$ ls -al $XDG_RUNTIME_DIR $XDG_RUNTIME_DIR/app/$FLATPAK_ID

Exit from both instances. Start a third instance (without logging out completely), and look in those directories again.

Expected result

I would have expected the first two (concurrent) instances to see all four sockets 1a, 2a, 1b and 2b. This could be achieved by giving them the same directory as $XDG_RUNTIME_DIR, and then mounting sockets like bus and wayland-0 on top of that.

I think I would expect the third (non-concurrent) instance to see all four sockets, but I think it would be OK if they all disappeared, or if both the a sockets were kept and both the b sockets disappeared, or vice versa; it isn't clear to me what should happen here, and I think it's fine for it to be an implementation detail.

If I log out completely, and log back in, then 1a, 2a, 1b and 2b will disappear.

Actual result

All three instances can see 1b and 2b, in the Flatpak-specific directory $XDG_RUNTIME_DIR/app/$FLATPAK_ID.

Only the first instance can see 1a.

Only the second instance can see 2a.

If I log out completely, and log back in, then 1a, 2a, 1b and 2b will disappear, as expected.

Activity

  1. smcv commented on Feb 15, 2021

    @smcv
    CollaboratorAuthor

    Commit 24c691f says:

    • run: Mount /run/user/$uid/app/$appid in the sandbox

      This directory is shared between all instances of the app, as well
      as the host. In many ways this is similar to the ~/.var/app/$appid
      directory, but the directory is guaranteed to not be persistent (/run
      is on tmpfs), local to the host (not NFS), as well as nice support
      for features like locks and mmap (due to being tmpfs).

    So this seems to be trying to be XDG_RUNTIME_DIR, more or less? ... except that it's only useful for apps that have been modified to use this Flatpak-specific directory, and not for generic app/library code that is more likely to use something like XDG_RUNTIME_DIR/myapp.socket.

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