Skip to content

Allow caller to supply a /usr to use instead of the runtime - #4018

Merged
alexlarsson merged 3 commits into
flatpak:masterfrom
smcv:replace-usr
Apr 7, 2021
Merged

alexlarsson merged 3 commits into
flatpak:masterfrom
smcv:replace-usr

Conversation

@smcv

@smcv smcv commented Dec 8, 2020 •

Copy link
Copy Markdown
Collaborator

Part of #3797.


  • flatpak_run_add_extension_args: Give caller more control

    When we add a way to specify a different /usr for a subsandbox, we'll
    want to mount the "official" runtime elsewhere and avoid adding it
    to the LD_LIBRARY_PATH.

  • flatpak_run_setup_usr_links: Add control over the mount point

  • run: Allow caller to replace /app and/or /usr

    The pressure-vessel container tool in Steam will want to use this, to
    replace /usr with a Steam Runtime container supplied by the Steam CDN,
    instead of using the same Flatpak runtime that is used to run the Steam
    client and non-containerized games.

    If a custom /usr is used, the "official" Flatpak runtime is still the
    one reflected in the metadata. It is also mounted at /run/parent,
    with all its extensions, so that pressure-vessel has the option of using
    its graphics drivers (by populating the custom /usr with symlinks into
    /run/parent and/or /run/host).

    When doing this, we need to put an empty directory on /app, because
    the real /app expects to be run on top of the real runtime. It would
    also be reasonable to substitute a custom replacement for /app, so
    I've included support for that too.

    Partially addresses Ability to subsandbox Steam games, with a different runtime #3797.

@smcv

smcv commented Dec 8, 2020

Copy link
Copy Markdown
Collaborator Author

Client-side: flatpak/flatpak-xdg-utils#39

Comment thread common/flatpak-run.c Resolved
Comment thread common/flatpak-run.c
if (g_file_query_exists (runtime_child, NULL))
flatpak_bwrap_add_args (bwrap,
"--symlink", "usr/etc", "/run/runtime/etc",
NULL);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a bit different from the regular /etc that would be if this was used as a runtime in the regular way. Still, probably right to have it there if there are things like relative symlinks pointing to it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right; in particular, if we want to look at the runtime's /etc/ld.so.cache, we can't, unless we provide /etc. It would be possible to do the full /etc setup for both /etc and /run/runtime/etc, but that seemed like extra code for no real gain.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is unchanged except for moving it to /run/parent/etc; I think it's still correct?)

Comment thread common/flatpak-run.c Outdated
/* For now we assume that if the caller wanted to update the
* ld.so.cache, it would already have done so; that's certainly
* true for pressure-vessel. */
use_ld_so_cache = FALSE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also remove the use of the ld.so cache for the app. But I guess its not really possible to run in some "mixed mode".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I need to think about this some more.

Disabling the ld.so cache regeneration and relying on LD_LIBRARY_PATH to find the imported graphics drivers is definitely the conservative, learn-to-walk-before-we-run option, and is how pressure-vessel works right now.

I'm trying to teach pressure-vessel to generate its own ld.so.cache in its specially-prepared /usr when it launches games outside Flatpak, and I had thought that I'd be able to do that in pressure-vessel in the Flatpak case too, and hand it over to Flatpak already prepared - but now that I think about it more, I might not be able to do that without entering a container. If I can't, and I want to use a ld.so.cache, I'll have to either teach Flatpak to do that (in a way that is appropriate for the /usr I'm giving it), or put ld.so.cache somewhere that is modifiable by the subsandbox (to which the one in /etc would be a symlink) and tell the launched command to regenerate it before running the actual game.

The code in pressure-vessel that generates its own ld.so.cache also doesn't work yet (graphics drivers don't load successfully, and I haven't been able to pin down why).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at enabling the ld.so cache generation, but the logic for cache invalidation assumes that the ld.so.cache is based on the app deployment, the app extensions, the runtime deployment and the runtime extensions. To be able to do the cache invalidation correctly, the caller would have to be able to pass in unique identifiers for its /app and /usr that would be hashed into the ld.so.cache checksum.

However, the Steam container runtime is dynamically set up based on not just a runtime, but also the graphics driver stack that it's borrowing, which might come from the Flatpak runtime, the host system or some third location - so there's no obvious unique ID to give it, and in practice I'd just be generating a UUID, which would result in the ld.so cache being invalidated and regenerated every time. The Steam runtime is also not stored in a content-addressed way, so we can't really rely on it not being modified locally.

Do we want to go to those lengths?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ld.so cache generation code also makes some assumptions about the ld.so.conf and ld.so.cache setup, such as "it's appropriate to enable all the extensions" and "we'll use /run/flatpak/ld.so.conf.d/runtime-*.conf" - although those are things I could work around in the runtime, if I need to.

Comment thread common/flatpak-run.c Outdated
if (!flatpak_run_add_extension_args (bwrap, runtime_metakey, runtime_ref, use_ld_so_cache, &runtime_extensions, cancellable, error))
if (!flatpak_run_add_extension_args (bwrap, runtime_metakey, runtime_ref,
use_ld_so_cache,
(runtime_files == original_runtime_files),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you would not want to update LD_LIBRARY_PATH based on extensions here if the runtime is not on /usr. However, this looses information that would be needed if you were to try to use the extensions from /run/runtime. Maybe we need to propagate this info somewhere else? RUNTIME_LD_LIBRARY_PATH?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could write it into /.flatpak-info? It probably doesn't need to be an environment variable.

My intention was that pressure-vessel will build a modified /usr containing exactly the files it needs, where each file is either a hard link to a pristine Steam Runtime file, a symlink into /run/host or a symlink into /run/runtime. It will need to know the layout of the extensions while building that modified /usr before launching the container, at which time they are Steam's and pressure-vessel's /usr, but the launched game will not need to know that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, you will need it before the .flatpak-info (or RUNTIME_LD_LIBRARY_PATH) is filled anyway, so maybe exposing this is not so important.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't taken action for this so far.

Comment thread common/flatpak-run.c

if (!flatpak_run_add_app_info_args (bwrap,
app_files, app_deploy_data, app_extensions,
runtime_files, runtime_deploy_data, runtime_extensions,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is right, but we should perhaps add a new field to the flatpak-info file so you can tell what /usr is.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that makes sense. I think the Steam-launched subsandbox should look like this:

  • "official" runtime: org.freedesktop.Platform/x86_64/20.08 (or whatever version Steam is using by the time we land this)
  • replacement /usr: /home/me/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-abcdef/usr

instead of pretending the runtime is com.valvesoftware.SteamRuntime.Platform/x86_64/soldier - which it sort of is, but Flatpak has no good way to know it can trust a string supplied by pressure-vessel.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the next revision of this branch I'm going to make it look something like this:

[Application]
name=com.valvesoftware.Steam
runtime=runtime/org.freedesktop.Platform/x86_64/20.08

[Instance]
app-path=
original-app-path=/var/lib/flatpak/app/.../files
runtime-path=/home/me/.../SteamLinuxRuntime_soldier/var/tmp-abcdef/usr
original-runtime-path=/var/lib/flatpak/runtime/.../files

where app-path= denotes "an empty directory on a tmpfs".

Similarly, flatpak run --app-path=/tmp/app would come out as app-path=/tmp/app.

The other possibility would be to set app-path and runtime-path to the "official" app and runtime files, and have a new replacement-app-path and replacement-usr-path, like this:

[Application]
name=com.valvesoftware.Steam
runtime=runtime/org.freedesktop.Platform/x86_64/20.08

[Instance]
app-path=/var/lib/flatpak/app/.../files
replacement-app-path=
runtime-path=/var/lib/flatpak/runtime/.../files
replacement-usr-path=/home/me/.../SteamLinuxRuntime_soldier/var/tmp-abcdef/usr

but I think that has a worse compatibility story for existing versions of xdg-desktop-portal, which is the only user I can find of those fields.

Comment thread portal/flatpak-portal.c Resolved
@alexlarsson

Copy link
Copy Markdown
Member

Added some comments + this needs rebasing as the other PRs landed. But overall this looks good to me.

There is some portal fallout though. In xdp_app_info_remap_path() in xdg-desktop-portal we rewrite paths on /usr. It would need to also rewrite stuff on the "new" /usr (and maybe /run/runtime too).

@smcv

smcv commented Dec 9, 2020

Copy link
Copy Markdown
Collaborator Author

I don't know yet whether I'm going to make pressure-vessel default to taking graphics drivers from /run/host or from /run/runtime, so I've made sure both would be possible. Whichever one it does, it also has to recurse through their dependencies and choose the libfoo from the same place as the graphics drivers or the libfoo from the Steam Runtime, whichever is newer, otherwise nothing will work.

Graphics drivers from /run/host are alarming from a stability/predictability point of view (and pull in an arbitrarily strange libc that might expect to be using non-FHS paths), but they're the only thing that is guaranteed to work on the user's hardware. We already do the equivalent for the non-Flatpak'd official Steam installations and it works surprisingly well, as long as you don't let amdgpu-pro install an outdated libdrm_amdgpu.so.1 in /opt.

Graphics drivers from /run/runtime would mean that whatever we use for more normal Flatpak apps, we're using the same thing for the pressure-vessel containers.

@smcv

smcv commented Dec 15, 2020

Copy link
Copy Markdown
Collaborator Author

Still WIP, and basically untested, but getting closer. I've added another feature that I'll need for Steam:

  • run: Add an option to share the pid namespace with the parent flatpak

    This will be useful for Steam's pressure-vessel container tool. The
    IPC between Steam games and the Steam client relies on process IDs,
    and becomes confused if they don't match up.

This adds --parent-share-pids, which is like --parent-expose-pids but symmetrical. It has the same restrictions as --parent-expose-pids (you need a non-setuid bwrap).

@alexlarsson

Copy link
Copy Markdown
Member

Overall I think this looks good, although I'd like to add the replacement /usr in .flatpak-info. Whats your plan/schedule for this work? I'd like to do a flatpak 1.10 release early next year, and a 1.9.x around xmas.

@smcv

smcv commented Dec 21, 2020 •

Copy link
Copy Markdown
Collaborator Author

I'm taking a much-needed break from my Steam-related work until early January, at which point I will be resuming work on this change and the corresponding changes in pressure-vessel (unless it gets preempted by something higher-priority).

From memory:

This is likely to need some changes before it works well enough to support SteamLinuxRuntime. At the moment, the pressure-vessel side of this change relies on being able to set the LD_LIBRARY_PATH so that we will find the graphics drivers and libc taken from either the host system or the Flatpak runtime, but Flatpak overwrites that with the app's LD_LIBRARY_PATH, so the game doesn't actually load yet: without the LD_LIBRARY_PATH, it often won't even find libc.so.6, so not even env(1) will work. To resolve that, I'll need to either generate a new ld.so.cache, either in Flatpak or in pressure-vessel, or teach Flatpak to give the app enough control over the subsandbox's LD_LIBRARY_PATH that it gets set to the correct value via bwrap --set-env before entering the container

I think we will also need to ignore the /app parts of LD_LIBRARY_PATH to make this correct, because the /app binaries and libraries are linked to the app's "official" runtime, and overriding /usr means we get a different runtime environment that does not necessarily have everything we need for those.

The other thing Steam is going to need, which I haven't attempted to resolve yet, is the ability to share a single /tmp between the Steam client (the main Flatpak app) and the individual games' subsandboxes: parts of Steam/Proton rely on this being shared as an IPC mechanism. So far, I've just been prototyping this by allowing --filesystem=/tmp, but it would be better sandboxing if we could teach Flatpak to do a mkdtemp() on the host system before launching Steam, and use that directory as the /tmp for both the app and its subsandboxes, instead of using a tmpfs for the Steam client's /tmp and a separate tmpfs for each subsandbox's /tmp. Perhaps a shareable-tmp flag?

smcv added a commit to smcv/flatpak that referenced this pull request Jan 7, 2021
This will be useful for Steam's pressure-vessel container tool. The
IPC between Steam games and the Steam client relies on process IDs,
and becomes confused if they don't match up.

This weakens the security boundary between a subsandbox and the parent,
but that's OK in some cases, particularly if the subsandbox is being
used as a way to get a different runtime /usr (flatpak#4018) rather than as a
security boundary.

Signed-off-by: Simon McVittie <[email protected]>
smcv added a commit to smcv/flatpak that referenced this pull request Jan 8, 2021
As with flatpak run --parent-expose-pids, this will only work if we have
a working, non-setuid bwrap. Systems where user namespace creation is
restricted and bwrap needs to be setuid (Debian 10, RHEL/CentOS 7,
Arch Linux linux-hardened kernel) will have degraded functionality.

This option is similar to --expose-pids, except that instead of making
the subsandbox use a nested pid namespace inside the parent's, it makes
the subsandbox share the parent's pid namespace as-is, so that process
IDs in the parent and the subsandbox are interchangeable. This will
be useful if the parent and the subsandbox communicate via protocols
that assume a global view of the process ID namespace, for example
passing process IDs across an AF_UNIX socket or in shared memory.

In particular, this will be useful for Steam's pressure-vessel container
tool: the IPC between the Steam client and the "game overlay" loaded into
Steam games uses process IDs, and becomes confused if they don't match up.

This weakens the security boundary between a subsandbox and the parent,
but that's OK in some cases, especially if the subsandbox is being used
as a way to get a different runtime /usr (flatpak-spawn --latest-version
or flatpak#4018) rather than as a security boundary.

Signed-off-by: Simon McVittie <[email protected]>
@smcv

smcv commented Jan 8, 2021

Copy link
Copy Markdown
Collaborator Author

run: Add an option to share the pid namespace with the parent flatpak

This is now #4060, and I think it's ready for review/merge. I'll rebase this branch onto #4060 next time I update it.

@smcv
smcv force-pushed the replace-usr branch 2 times, most recently from 731932e to cd1cec0 Compare January 8, 2021 18:19
@smcv

smcv commented Jan 8, 2021

Copy link
Copy Markdown
Collaborator Author

I have now launched a real game with this for the first time! 🎉

Unfinished:

  • The points noted above

  • The LD_LIBRARY_PATH coming from pressure-vessel is passed into the
    portal via --env, but the portal doesn't pass that into flatpak run
    and it is lost. Flatpak replaces that with /app/lib, which is
    certainly wrong. As a proof of concept to get at least one game to
    run, this patch currently hard-codes the correct LD_LIBRARY_PATH for
    pressure-vessel, which is obviously not suitable for merge.
    (But it works! Floating Point, Steam game ID 302380, is the first
    game to have been successfully launched in this way.)

  • Similarly, the PATH coming from pressure-vessel is lost, and we
    end up with /app/bin in the PATH - but that's wrong, because we have
    set up a library stack that is not using /app's runtime, so we cannot
    necessarily run everything in /app/bin.

Comment thread common/flatpak-run.c Resolved
alexlarsson pushed a commit that referenced this pull request Jan 12, 2021
As with flatpak run --parent-expose-pids, this will only work if we have
a working, non-setuid bwrap. Systems where user namespace creation is
restricted and bwrap needs to be setuid (Debian 10, RHEL/CentOS 7,
Arch Linux linux-hardened kernel) will have degraded functionality.

This option is similar to --expose-pids, except that instead of making
the subsandbox use a nested pid namespace inside the parent's, it makes
the subsandbox share the parent's pid namespace as-is, so that process
IDs in the parent and the subsandbox are interchangeable. This will
be useful if the parent and the subsandbox communicate via protocols
that assume a global view of the process ID namespace, for example
passing process IDs across an AF_UNIX socket or in shared memory.

In particular, this will be useful for Steam's pressure-vessel container
tool: the IPC between the Steam client and the "game overlay" loaded into
Steam games uses process IDs, and becomes confused if they don't match up.

This weakens the security boundary between a subsandbox and the parent,
but that's OK in some cases, especially if the subsandbox is being used
as a way to get a different runtime /usr (flatpak-spawn --latest-version
or #4018) rather than as a security boundary.

Signed-off-by: Simon McVittie <[email protected]>
@smcv

smcv commented Jan 15, 2021

Copy link
Copy Markdown
Collaborator Author

Similarly, the PATH coming from pressure-vessel is lost

This was also resolved (possibly in e2c4ded?) as a follow-up to resolving CVE-2021-21261. Now the app (pressure-vessel) gets to choose all environment variables for the subsandbox, including PATH and LD_LIBRARY_PATH.

@smcv

smcv commented Jan 15, 2021

Copy link
Copy Markdown
Collaborator Author

The other thing Steam is going to need, which I haven't attempted to resolve yet, is the ability to share a single /tmp between the Steam client (the main Flatpak app) and the individual games' subsandboxes

We'll probably need the same for /dev/shm - I think Steam uses shared memory for some of its IPC.

Steam already has --share=ipc, so we don't need a way to force the SysV IPC namespace to be shared between Steam and the subsandbox: both already share their SysV IPC namespace with the host.

@smcv

smcv commented Jan 19, 2021

Copy link
Copy Markdown
Collaborator Author

I think we will also need to ignore the /app parts of LD_LIBRARY_PATH to make this correct, because the /app binaries and libraries are linked to the app's "official" runtime, and overriding /usr means we get a different runtime environment that does not necessarily have everything we need for those.

In the next rev I'm going to rename --runtime-usr to --usr-path, and add a mostly-symmetrical --app-path, where --app-path= is special-cased to mean "mount an empty directory on /app" (which is probably what I'll use for Steam). That would also provide most of #408 if people wanted it.

@smcv smcv added ready-for-review sandbox issue related to sandbox setup labels Feb 25, 2021
@gasinvein

Copy link
Copy Markdown
Contributor

Confirming this seems to work, tried several Proton games. Great job, @smcv!

The only problem noticed is that Proton running in pressure-vessel refuses to use discrete GPU unless I specify VK_ICD_FILENAMES explicitly pointing to Nvidia ICD .json only. But I'm not sure if this is related to flatpak<->pressure-vessel interaction.

@smcv

smcv commented Mar 6, 2021

Copy link
Copy Markdown
Collaborator Author

Confirming this seems to work, tried several Proton games

Great! Thank you for not describing exactly how you did this - at the moment, I don't want people trying it unless they are sufficiently technical to be able to figure out how it works from the source code (the time taken to deal with confused bug reports from people following a recipe they don't understand would be detrimental to getting this feature landed).

The only problem noticed is that Proton running in pressure-vessel refuses to use discrete GPU unless I specify VK_ICD_FILENAMES explicitly pointing to Nvidia ICD .json only.

I think this is a more general problem with pressure-vessel: we've had ongoing issues with multi-GPU systems, and we don't completely understand what is going on with those systems. Vulkan multi-GPU is complicated and I don't currently have access to a multi-GPU system that is sufficiently new for Vulkan to work, so I'm completely dependent on user reports, many of which are incomplete or confused. Future releases will hopefully improve on this.

You might find that running with __NV_PRIME_RENDER_OFFLOAD=1 and optionally __VK_LAYER_NV_optimus=NVIDIA_only resolves this. See also flathub/com.valvesoftware.Steam#559 - I'm going to talk to Valve about whether we can/should make that change upstream.

It might also be to do with one of NVIDIA's Vulkan layers apparently not being present (see flathub/org.freedesktop.Platform.GL.nvidia#35).

When we have an actual release that you can test against, I'll ask you for some more targeted information. If you're able to run Steam unsandboxed (perhaps as a separate user account if you don't want it running unsandboxed under your main uid) then it would be useful to compare its behaviour as a Flatpak and unsandboxed.

@gasinvein

gasinvein commented Mar 6, 2021 •

Copy link
Copy Markdown
Contributor

You might find that running with __NV_PRIME_RENDER_OFFLOAD=1 and optionally __VK_LAYER_NV_optimus=NVIDIA_only resolves this.

Well, it didn't work for me. These variables do work for native games, proton ≤ 5.0 and the "community" proton 5.13 build, but not for official proton 5.13 running in pressure-vessel.
Setting VK_ICD_FILENAMES=/usr/lib/pressure-vessel/overrides/share/vulkan/icd.d/0.json helped, though.

Comment thread common/flatpak-run.c Outdated
"/run/parent");

g_clear_object (&runtime_child);
runtime_child = g_file_get_child (runtime_files, "etc");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be original_runtime_files?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch.

smcv added 3 commits April 6, 2021 16:37
When we add a way to specify a different /usr for a subsandbox, we'll
want to mount the "official" runtime elsewhere and avoid adding it
to the LD_LIBRARY_PATH.

Signed-off-by: Simon McVittie <[email protected]>
The pressure-vessel container tool in Steam will want to use this, to
replace /usr with a Steam Runtime container supplied by the Steam CDN,
instead of using the same Flatpak runtime that is used to run the Steam
client and non-containerized games.

If a custom /usr is used, the "official" Flatpak runtime is still the
one reflected in the metadata. It is also mounted at /run/parent,
with all its extensions, so that pressure-vessel has the option of using
its graphics drivers (by populating the custom /usr with symlinks into
/run/parent and/or /run/host).

When doing this, we need to put an empty directory on /app, because
the real /app expects to be run on top of the real runtime. It would
also be reasonable to substitute a custom replacement for /app, so
I've included support for that too.

Partially addresses flatpak#3797.

Signed-off-by: Simon McVittie <[email protected]>
@alexlarsson
alexlarsson merged commit 3ebf371 into flatpak:master Apr 7, 2021
@smcv

smcv commented Apr 8, 2021

Copy link
Copy Markdown
Collaborator Author

Testing this against Steam's containers, I confirm that it does work, with some limitations.

Native Linux game in a container

  • Debian 11, system flatpak package replaced by a build of Flatpak 1.11~git20210407 from commit 3ebf371
    • If you are running a version built from source code, note that you need to run at least the updated flatpak-portal, with the updated flatpak in its PATH: PATH="${builddir}:$PATH" "${builddir}/flatpak-portal" -vr seems suffcient
  • An old laptop (Lenovo T520), using the ancient Intel integrated GPU for simplicity
  • Steam launcher 1.0.0.70, from Flathub, on fd.o Platform 20.08.7
  • Steam beta branch build 1617753941, 2021-04-06
  • Life is Strange, episode 1 installed and configured to run under Steam Linux Runtime compatibility tool
  • SteamLinuxRuntime opted into the client_beta branch, VERSIONS.txt says scout 0.20210317.0 and pressure-vessel 0.20210317.0+srt1

flatpak run com.valvesoftware.Steam with these environment variables:

  • PRESSURE_VESSEL_SHELL=instead to get an xterm instead of running the game
  • STEAM_LINUX_RUNTIME_LOG=1 to get more logs
  • STEAM_LINUX_RUNTIME_VERBOSE=1 to get even more logs
  • a deliberately undocumented environment variable mentioning this PR number, which will be required until this is actually in a tagged Flatpak release (see steam-runtime-tools source code for details, and please don't publicize its name - we are not ready to receive bug reports from non-technical users for this feature)

Run Life is Strange. An xterm pops up instead, because of PRESSURE_VESSEL_SHELL=instead. Type "$@" into the xterm to run the actual game.

You can use systemd-cgls to confirm that this is working. You should find that you have two scopes of the form app-flatpak-com.valvesoftware.Steam-${pid}.scope: one containing steam-wrapper, Steam itself, and Steam's built-in web browser, and another containing a pressure-vessel-adverb process, the xterm and the actual game.

A log file for pressure-vessel (subsandbox) startup can be found in steamapps/common/SteamLinuxRuntime/var/slr-latest.log.

Known issue: pressing Shift+Tab to get the Steam overlay doesn't do anything. This is not expected to work until #4093 and #4214 land in Flatpak - I think it needs to see the same /dev/shm as Steam itself. Other features that are based on the Steam overlay, like game controller remapping, Remote Play and Remote Play Together, will probably not work.

Comparison: if you disable the compatibility tool and run Life is Strange directly, as an ordinary native Linux game, it will run in the same Flatpak sandbox and the same systemd scope as Steam itself.

Windows game with Proton, in a container

  • Laptop, Debian, Flatpak, Steam as above
  • Life is Strange, episode 1 installed and configured to run under Proton 6.3 compatibility tool (which forces Steam to install the Windows executables instead of native Linux); Proton 5.13 also works
  • Proton 6.3-2 (official build from Valve, not a Flathub community build) or 5.13-6 (same)
  • SteamLinuxRuntime_soldier opted into the client_beta branch, VERSIONS.txt says soldier 0.20210317.0 and pressure-vessel 0.20210317.0+srt1

flatpak run com.valvesoftware.Steam with these environment variables:

  • PRESSURE_VESSEL_SHELL=instead as before
  • STEAM_LINUX_RUNTIME_LOG=1 as before
  • STEAM_LINUX_RUNTIME_VERBOSE=1 as before
  • a deliberately undocumented environment variable mentioning this PR number as before
  • PROTON_LOG=1 to get a detailed log from Proton
  • PROTON_USE_WINED3D=1 because my GPU is too old to have a working Vulkan driver (leave this one out if you have a better GPU)

This time, the pressure-vessel log file appears in steamapps/common/SteamLinuxRuntime_soldier/var/slr-latest.log.

You can use systemd-cgls to confirm that this is working. You should find that you have two scopes of the form app-flatpak-com.valvesoftware.Steam-${pid}.scope: one containing steam-wrapper, Steam itself, and Steam's built-in web browser, and another containing a pressure-vessel-adverb process, the xterm, some Proton and Wine processes, and the actual game.

By default, Proton's log file from PROTON_LOG=1 appears in ~/steam-319630.log in the sandbox, which is ~/.var/app/com.valvesoftware.Steam/steam-319630.log on the host system.

Known issue: Shift+Tab for Steam overlay doesn't work, as above.

Comparison: if you set the compatibility tool to Proton 5.0 or older, it will run in the same Flatpak sandbox and the same systemd scope as Steam itself. In this case the Steam overlay does work.

@gasinvein

gasinvein commented Apr 8, 2021 •

Copy link
Copy Markdown
Contributor

Great! Although I'm a bit confused now: how does it work without #4093 and #4214, doesn't pressure-vessel need shared PRESSURE_VESSEL_SOCKET_DIR to function?

@smcv

smcv commented Apr 8, 2021

Copy link
Copy Markdown
Collaborator Author

how does it work without #4093 and #4214, doesn't pressure-vessel need shared PRESSURE_VESSEL_SOCKET_DIR to function?

The "setup commands" stage (installing Windows runtime libraries, setting registry keys, etc.) might well be failing as a result of the PRESSURE_VESSEL_SOCKET_DIR not being shared, but for this specific game that's not actually fatal.

We used to be completely reliant on PRESSURE_VESSEL_SOCKET_DIR-based communication between pv-launch and pv-launcher, but now we shut down the entire container after the setup commands and start a new one for the actual game, which makes Launch Options work more like what would be expected, and has the side-effect that a shared /tmp is not strictly required for basic functionality.

We are still going to need #4091 (as implemented in #4093 and #4214) for this to be anything like production-quality, because not having it breaks the Steam Overlay, and increasingly much Steam functionality relies on the overlay to be working.

@gasinvein

Copy link
Copy Markdown
Contributor

Thanks for explanation. Should we set up a shared directory under $XDG_RUNTIME_DIR and point $PRESSURE_VESSEL_SOCKET_DIR to it in the flatpak Steam wrapper, to ease testing?

@smcv

smcv commented Apr 8, 2021

Copy link
Copy Markdown
Collaborator Author

Should we set up a shared directory under $XDG_RUNTIME_DIR and point $PRESSURE_VESSEL_SOCKET_DIR to it in the flatpak Steam wrapper, to ease testing?

That's an interesting idea, but we need to get #4091 fixed anyway, which will mean we won't need that. Increasingly many Steam features need the Steam overlay, so if we enable this without a working overlay, we'll just be spending time dealing with issue reports like "game controller doesn't work" and "Remote Play doesn't work", which is time we can't spend on actually fixing things.

@smcv
smcv deleted the replace-usr branch April 15, 2021 20:10
smcv added a commit to smcv/flatpak-xdg-utils that referenced this pull request Jun 11, 2021
Steam's pressure-vessel tool will use this to launch a parallel
container with /usr supplied by the Steam Runtime, and an empty /app.

This is a client-side for
<flatpak/flatpak#4018>.

Signed-off-by: Simon McVittie <[email protected]>
smcv added a commit to smcv/flatpak-xdg-utils that referenced this pull request Jun 11, 2021
This is a client-side for
<flatpak/flatpak#4018>.

Steam's pressure-vessel tool does the equivalent of this to launch
a parallel container with /usr supplied by the Steam Runtime, and an
empty /app, although currently it has to use code derived from
flatpak-spawn rather than using the runtime's copy of flatpak-spawn.

Signed-off-by: Simon McVittie <[email protected]>
smcv added a commit to smcv/flatpak-xdg-utils that referenced this pull request Jul 23, 2021
This is a client-side for
<flatpak/flatpak#4018>.

Steam's pressure-vessel tool does the equivalent of this to launch
a parallel container with /usr supplied by the Steam Runtime, and an
empty /app, although currently it has to use code derived from
flatpak-spawn rather than using the runtime's copy of flatpak-spawn.

Signed-off-by: Simon McVittie <[email protected]>
@auwsom auwsom mentioned this pull request Oct 17, 2021
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sandbox issue related to sandbox setup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants