Skip to content
Snippets Groups Projects
Commit 1a39648f authored by Simon McVittie's avatar Simon McVittie
Browse files

pv-wrap: Factor out get_subsandbox_adverb()

parent 78262e5c
No related branches found
No related tags found
1 merge request!292Improve Flatpak sub-sandboxing support
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include "flatpak-run-private.h" #include "flatpak-run-private.h"
#include "utils.h" #include "utils.h"
#define FLATPAK_PORTAL_BUS_NAME "org.freedesktop.portal.Flatpak"
#define FLATPAK_SESSION_HELPER_BUS_NAME "org.freedesktop.Flatpak"
static gboolean static gboolean
check_launch_on_host (const char *launch_executable, check_launch_on_host (const char *launch_executable,
GError **error) GError **error)
...@@ -34,7 +37,7 @@ check_launch_on_host (const char *launch_executable, ...@@ -34,7 +37,7 @@ check_launch_on_host (const char *launch_executable,
const char *test_argv[] = const char *test_argv[] =
{ {
NULL, NULL,
"--bus-name=org.freedesktop.Flatpak", "--bus-name=" FLATPAK_SESSION_HELPER_BUS_NAME,
"--", "--",
"true", "true",
NULL NULL
...@@ -72,6 +75,21 @@ check_launch_on_host (const char *launch_executable, ...@@ -72,6 +75,21 @@ check_launch_on_host (const char *launch_executable,
return TRUE; return TRUE;
} }
static FlatpakBwrap *
get_subsandbox_adverb (const char *launch_executable)
{
FlatpakBwrap *ret = flatpak_bwrap_new (flatpak_bwrap_empty_env);
flatpak_bwrap_add_arg (ret, launch_executable);
/* Tell pressure-vessel-launch to send its whole environment
* to the subsandbox, except for the parts that we edit later.
* This effectively matches bwrap's behaviour. */
flatpak_bwrap_add_arg (ret, "--pass-env-matching=*");
flatpak_bwrap_add_arg (ret, "--bus-name=" FLATPAK_PORTAL_BUS_NAME);
return ret;
}
/* /*
* pv_wrap_check_flatpak: * pv_wrap_check_flatpak:
* @tools_dir: Path to .../pressure-vessel/bin/ * @tools_dir: Path to .../pressure-vessel/bin/
...@@ -139,15 +157,7 @@ pv_wrap_check_flatpak (const char *tools_dir, ...@@ -139,15 +157,7 @@ pv_wrap_check_flatpak (const char *tools_dir,
{ {
g_warning ("Assuming your version of Flatpak contains unmerged " g_warning ("Assuming your version of Flatpak contains unmerged "
"changes (#4018, #4125, #4126, #4093)"); "changes (#4018, #4125, #4126, #4093)");
/* Use a sub-sandbox */ subsandbox = get_subsandbox_adverb (launch_executable);
subsandbox = flatpak_bwrap_new (flatpak_bwrap_empty_env);
flatpak_bwrap_add_arg (subsandbox, launch_executable);
/* Tell pressure-vessel-launch to send its whole environment
* to the subsandbox, except for the parts that we edit later.
* This effectively matches bwrap's behaviour. */
flatpak_bwrap_add_arg (subsandbox, "--pass-env-matching=*");
flatpak_bwrap_add_arg (subsandbox,
"--bus-name=org.freedesktop.portal.Flatpak");
} }
/* Also deliberately not documented */ /* Also deliberately not documented */
else if (g_getenv ("PRESSURE_VESSEL_FLATPAK_SANDBOX_ESCAPE") != NULL) else if (g_getenv ("PRESSURE_VESSEL_FLATPAK_SANDBOX_ESCAPE") != NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment