mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-26 14:13:26 +00:00
portal, session-helper: Save original environment and use it for child
Otherwise, the child process will inherit GIO_USE_VFS=local, breaking its ability to use GVfs and other GIO plugin interfaces. Resolves: https://github.com/flatpak/flatpak/issues/5567 Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
14d735bfda
commit
6e7eb1e19a
@ -63,6 +63,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (PortalFlatpakUpdateMonitorSkeleton, g_object_unre
|
||||
/* Should be roughly 2 seconds */
|
||||
#define CHILD_STATUS_CHECK_ATTEMPTS 20
|
||||
|
||||
static GStrv original_environ = NULL;
|
||||
static GHashTable *client_pid_data_hash = NULL;
|
||||
static GDBusConnection *session_bus = NULL;
|
||||
static GNetworkMonitor *network_monitor = NULL;
|
||||
@ -1042,7 +1043,7 @@ handle_spawn (PortalFlatpak *object,
|
||||
if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
||||
{
|
||||
g_warning ("Environment for \"flatpak run\" was not found, falling back to current environment");
|
||||
env = g_get_environ ();
|
||||
env = g_strdupv (original_environ);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3025,6 +3026,10 @@ main (int argc,
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/* Save the enviroment before changing anything, so that subprocesses
|
||||
* can get the unchanged version */
|
||||
original_environ = g_get_environ ();
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
g_setenv ("GIO_USE_VFS", "local", TRUE);
|
||||
@ -3127,5 +3132,6 @@ main (int argc,
|
||||
main_loop = g_main_loop_new (NULL, FALSE);
|
||||
g_main_loop_run (main_loop);
|
||||
|
||||
g_strfreev (original_environ);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "flatpak-session-helper.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
|
||||
static GStrv original_environ = NULL;
|
||||
static char *monitor_dir;
|
||||
static char *p11_kit_server_socket_path;
|
||||
static int p11_kit_server_pid = 0;
|
||||
@ -310,7 +311,7 @@ handle_host_command (FlatpakDevelopment *object,
|
||||
env = g_strdupv (empty);
|
||||
}
|
||||
else
|
||||
env = g_get_environ ();
|
||||
env = g_strdupv (original_environ);
|
||||
|
||||
n_envs = g_variant_n_children (arg_envs);
|
||||
for (i = 0; i < n_envs; i++)
|
||||
@ -783,6 +784,10 @@ main (int argc,
|
||||
m_localtime = NULL;
|
||||
struct sigaction action;
|
||||
|
||||
/* Save the enviroment before changing anything, so that subprocesses
|
||||
* can get the unchanged version */
|
||||
original_environ = g_get_environ ();
|
||||
|
||||
atexit (do_atexit);
|
||||
|
||||
memset (&action, 0, sizeof (struct sigaction));
|
||||
@ -880,5 +885,6 @@ main (int argc,
|
||||
|
||||
g_bus_unown_name (owner_id);
|
||||
|
||||
g_strfreev (original_environ);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user