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

pressure-vessel: Stop worrying about whether argv[1][0] is "-"


The reason we originally did this is that older versions of bwrap
didn't support the GNU-style "--" argument separator, used to
disambiguate between non-option arguments and strangely-named
executables that happened to start with a minus.

However, we now wrap our user-controlled "payload" command with pressure-vessel-adverb(1) in
all cases, which means we don't need this. bwrap's first non-option
argument is the absolute path to pressure-vessel-adverb, which
definitely does not start with "-" and so cannot be confused with an
option; and all of our own commands, notably pressure-vessel-adverb,
use GOptionContext and therefore support the "--" option-separator
correctly.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 2ffa6fb1
No related branches found
No related tags found
1 merge request!208Refactoring in preparation for Flatpak support
...@@ -2308,26 +2308,12 @@ main (int argc, ...@@ -2308,26 +2308,12 @@ main (int argc,
} }
else else
{ {
g_autoptr(FlatpakBwrap) wrapped_command = /* In non-"--launcher" mode, arguments after the "--" separator
flatpak_bwrap_new (flatpak_bwrap_empty_env); * are the command to execute, passed to the adverb after "--".
* Because we always use the adverb, we don't need to worry about
if (argc > 1 && argv[1][0] == '-') * whether argv[1] starts with "-". */
{
/* Make sure wrapped_command is something we can validly pass to env(1) */
if (strchr (argv[1], '=') != NULL)
flatpak_bwrap_add_args (wrapped_command,
"sh", "-euc", "exec \"$@\"", "sh",
NULL);
/* Make sure bwrap will interpret wrapped_command as the end of its
* options */
flatpak_bwrap_add_arg (wrapped_command, "env");
}
g_debug ("Setting arguments for wrapped command"); g_debug ("Setting arguments for wrapped command");
flatpak_bwrap_append_argsv (wrapped_command, &argv[1], argc - 1); flatpak_bwrap_append_argsv (bwrap, &argv[1], argc - 1);
flatpak_bwrap_append_bwrap (bwrap, wrapped_command);
} }
if (is_flatpak_env) if (is_flatpak_env)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment