From 8fae17bf51f77bed871cf5b54a6efd8c2257325b Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis <ludovico.denittis@collabora.com> Date: Mon, 26 Oct 2020 15:56:53 +0100 Subject: [PATCH] Pass the original environ to runtime.c If necessary, in runtime.c we should access the original environment instead of the global one, because it might have been edited. Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com> --- pressure-vessel/runtime.c | 24 ++++++++++++++++++++++++ pressure-vessel/runtime.h | 1 + pressure-vessel/wrap.c | 1 + 3 files changed, 26 insertions(+) diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index 2ef4891be..f294fb5e8 100644 --- a/pressure-vessel/runtime.c +++ b/pressure-vessel/runtime.c @@ -54,6 +54,7 @@ struct _PvRuntime gchar *source_files; gchar *tools_dir; PvBwrapLock *runtime_lock; + GStrv original_environ; gchar *libcapsule_knowledge; gchar *mutable_parent; @@ -90,6 +91,7 @@ struct _PvRuntimeClass enum { PROP_0, PROP_BUBBLEWRAP, + PROP_ORIGINAL_ENVIRON, PROP_FLAGS, PROP_MUTABLE_PARENT, PROP_PROVIDER_IN_CURRENT_NAMESPACE, @@ -277,6 +279,10 @@ pv_runtime_get_property (GObject *object, g_value_set_string (value, self->bubblewrap); break; + case PROP_ORIGINAL_ENVIRON: + g_value_set_boxed (value, self->original_environ); + break; + case PROP_FLAGS: g_value_set_flags (value, self->flags); break; @@ -323,6 +329,13 @@ pv_runtime_set_property (GObject *object, self->bubblewrap = g_value_dup_string (value); break; + case PROP_ORIGINAL_ENVIRON: + /* Construct-only */ + g_return_if_fail (self->original_environ == NULL); + + self->original_environ = g_value_dup_boxed (value); + break; + case PROP_FLAGS: self->flags = g_value_get_flags (value); break; @@ -396,6 +409,7 @@ pv_runtime_constructed (GObject *object) G_OBJECT_CLASS (pv_runtime_parent_class)->constructed (object); g_return_if_fail (self->bubblewrap != NULL); + g_return_if_fail (self->original_environ != NULL); g_return_if_fail (self->provider_in_current_namespace != NULL); g_return_if_fail (self->provider_in_container_namespace != NULL); g_return_if_fail (self->source_files != NULL); @@ -888,6 +902,7 @@ pv_runtime_finalize (GObject *object) pv_runtime_cleanup (self); g_free (self->bubblewrap); + g_strfreev (self->original_environ); g_free (self->libcapsule_knowledge); glnx_close_fd (&self->mutable_parent_fd); g_free (self->mutable_parent); @@ -924,6 +939,13 @@ pv_runtime_class_init (PvRuntimeClass *cls) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + properties[PROP_ORIGINAL_ENVIRON] = + g_param_spec_boxed ("original-environ", "Original environ", + "The original environ to use", + G_TYPE_STRV, + (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + properties[PROP_FLAGS] = g_param_spec_flags ("flags", "Flags", "Flags affecting how we set up the runtime", @@ -982,6 +1004,7 @@ pv_runtime_new (const char *source_files, const char *tools_dir, const char *provider_in_current_namespace, const char *provider_in_container_namespace, + const GStrv original_environ, PvRuntimeFlags flags, GError **error) { @@ -994,6 +1017,7 @@ pv_runtime_new (const char *source_files, NULL, error, "bubblewrap", bubblewrap, + "original-environ", original_environ, "mutable-parent", mutable_parent, "source-files", source_files, "tools-directory", tools_dir, diff --git a/pressure-vessel/runtime.h b/pressure-vessel/runtime.h index 923021ce2..b4e6ea18c 100644 --- a/pressure-vessel/runtime.h +++ b/pressure-vessel/runtime.h @@ -71,6 +71,7 @@ PvRuntime *pv_runtime_new (const char *source_files, const char *tools_dir, const char *provider_in_current_namespace, const char *provider_in_container_namespace, + const GStrv original_environ, PvRuntimeFlags flags, GError **error); diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c index ea119dad8..964e63690 100644 --- a/pressure-vessel/wrap.c +++ b/pressure-vessel/wrap.c @@ -1711,6 +1711,7 @@ main (int argc, tools_dir, opt_graphics_provider, graphics_provider_mount_point, + original_environ, flags, error); -- GitLab