diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c index 6a17c2d52ecdf53d965dce832e690d75efa20939..2aa1bac8aaa3b67fb8fd6c5d218f8802b43bc3d9 100644 --- a/pressure-vessel/wrap.c +++ b/pressure-vessel/wrap.c @@ -4,7 +4,7 @@ * Contains code taken from Flatpak. * * Copyright © 2014-2019 Red Hat, Inc - * Copyright © 2017-2020 Collabora Ltd. + * Copyright © 2017-2021 Collabora Ltd. * * SPDX-License-Identifier: LGPL-2.1-or-later * @@ -2233,6 +2233,22 @@ main (int argc, /* TODO: In future we will not do this when using Flatpak sub-sandboxing */ { + /* Tell the application that it's running under a container manager + * in a generic way (based on https://systemd.io/CONTAINER_INTERFACE/, + * although a lot of that document is intended for "system" + * containers and is less suitable for "app" containers like + * Flatpak and pressure-vessel). */ + flatpak_bwrap_add_args (bwrap, + "--setenv", "container", "pressure-vessel", + NULL); + if (!flatpak_bwrap_add_args_data (bwrap, + "container-manager", + "pressure-vessel\n", -1, + "/run/host/container-manager", + error)) + return FALSE; + + if (opt_verbose) { g_message ("%s options before bundling:", bwrap_executable); diff --git a/tests/pressure-vessel/inside-runtime.py b/tests/pressure-vessel/inside-runtime.py index b305f3ea4fd04602a3f51bde55e36fccadbe2fb0..3914843e70a3427bc07e1afb8f14ac66c85c41b8 100755 --- a/tests/pressure-vessel/inside-runtime.py +++ b/tests/pressure-vessel/inside-runtime.py @@ -159,6 +159,11 @@ class TestInsideRuntime(BaseTest): elif os.environ.get('TEST_INSIDE_RUNTIME_IS_SOLDIER'): self.assertEqual(os.environ.get('STEAM_RUNTIME'), None) + self.assertEqual(os.environ.get('container'), 'pressure-vessel') + + with open('/run/host/container-manager', 'r') as reader: + self.assertEqual(reader.read(), 'pressure-vessel\n') + def test_overrides(self) -> None: if os.getenv('TEST_INSIDE_RUNTIME_IS_COPY'): target = os.readlink('/overrides')