summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2021-02-23 13:33:06 +0100
committerAlexander Larsson <alexander.larsson@gmail.com>2021-03-10 11:13:38 +0100
commite7b5f4600967b505c11c948c4e6dfd91fc0199e8 (patch)
tree6fd0dd38c60718d2744a1c2cc162f9cfa713ed2b
parent936bd2b3e0f4d6c37ed62b8a2ab089aef62d9314 (diff)
downloadflatpak-e7b5f4600967b505c11c948c4e6dfd91fc0199e8.tar.gz
common: Fix Spawn portal method not working with UTF-8 files
When the portal's Spawn method is used with the environment cleared, it's very likely that the "flatpak run" that ends up being run will be in an environment without UTF-8 support. If one of the files or directories we try to expose to the sub-sandbox contains UTF-8/non-ASCII characters, then "flatpak run" would fail with: error: Invalid byte sequence in conversion input This is caused by GOption trying to parse the --filesystem option for flatpak, as, when using the G_OPTION_ARG_CALLBACK argument type, GOption will split the option name from its value, and try to convert the value to UTF-8. Which will fail because there's no UTF-8. It won't however do that if we tell the option parser that the value is a filename using G_OPTION_FLAG_FILENAME, so set it. (cherry picked from commit e67847e253da6756886cc727687f00c57a03b816)
-rw-r--r--common/flatpak-context.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/flatpak-context.c b/common/flatpak-context.c
index 4f8a3380..abeda358 100644
--- a/common/flatpak-context.c
+++ b/common/flatpak-context.c
@@ -1391,8 +1391,8 @@ static GOptionEntry context_options[] = {
{ "nodevice", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, &option_nodevice_cb, N_("Don't expose device to app"), N_("DEVICE") },
{ "allow", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, &option_allow_cb, N_("Allow feature"), N_("FEATURE") },
{ "disallow", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, &option_disallow_cb, N_("Don't allow feature"), N_("FEATURE") },
- { "filesystem", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, &option_filesystem_cb, N_("Expose filesystem to app (:ro for read-only)"), N_("FILESYSTEM[:ro]") },
- { "nofilesystem", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, &option_nofilesystem_cb, N_("Don't expose filesystem to app"), N_("FILESYSTEM") },
+ { "filesystem", 0, G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_FILENAME, G_OPTION_ARG_CALLBACK, &option_filesystem_cb, N_("Expose filesystem to app (:ro for read-only)"), N_("FILESYSTEM[:ro]") },
+ { "nofilesystem", 0, G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_FILENAME, G_OPTION_ARG_CALLBACK, &option_nofilesystem_cb, N_("Don't expose filesystem to app"), N_("FILESYSTEM") },
{ "env", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, &option_env_cb, N_("Set environment variable"), N_("VAR=VALUE") },
{ "env-fd", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, &option_env_fd_cb, N_("Read environment variables in env -0 format from FD"), N_("FD") },
{ "unset-env", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, &option_unset_env_cb, N_("Remove variable from environment"), N_("VAR") },