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

wrap: Append argv in container directly to final argv


Instead of this pseudocode:

    bwrap += argv_in_container
    final_argv += bwrap

if we do this:

    final_argv += bwrap
    final_argv += argv_in_container

it will be easier to adapt to Flatpak sub-sandboxing, in which we never
directly build up a bwrap command-line and so bwrap remains NULL.

This means that in the case where we are escaping from a Flatpak sandbox
to run commands on the host, we have to forward the fds from
argv_in_container in addition to the fds from bwrap.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 135ae960
Branches
Tags
1 merge request!213Further refactoring towards Flatpak sub-sandboxing support
......@@ -2361,11 +2361,6 @@ main (int argc,
flatpak_bwrap_append_argsv (argv_in_container, &argv[1], argc - 1);
}
g_warn_if_fail (g_strv_length (argv_in_container->envp) == 0);
flatpak_bwrap_append_bwrap (bwrap, argv_in_container);
g_warn_if_fail (g_strv_length (bwrap->envp) == 0);
if (is_flatpak_env)
{
/* Use pv-launch to launch bwrap on the host. */
......@@ -2380,6 +2375,14 @@ main (int argc,
g_array_index (bwrap->fds, int, i));
flatpak_bwrap_add_arg (launch_on_host, fd_str);
}
for (i = 0; i < argv_in_container->fds->len; i++)
{
g_autofree char *fd_str = g_strdup_printf ("--forward-fd=%d",
g_array_index (argv_in_container->fds, int, i));
flatpak_bwrap_add_arg (launch_on_host, fd_str);
}
/* Change the current working directory where pv-launch will run bwrap.
* Bwrap will then set its directory by itself. For this reason here
* we just need a directory that it's known to exist. */
......@@ -2391,8 +2394,12 @@ main (int argc,
flatpak_bwrap_append_bwrap (final_argv, launch_on_host);
}
g_warn_if_fail (g_strv_length (bwrap->envp) == 0);
flatpak_bwrap_append_bwrap (final_argv, bwrap);
g_warn_if_fail (g_strv_length (argv_in_container->envp) == 0);
flatpak_bwrap_append_bwrap (final_argv, argv_in_container);
/* We'll have permuted the order anyway, so we might as well sort it,
* to make debugging a bit easier. */
if (final_argv->envp != NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment