From d8b4a577b2164c084ef56ecc25739daeb8713a39 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Wed, 4 Aug 2021 11:43:36 +0100 Subject: [PATCH] pv_wrap_append_preload: Take environment as a parameter This allows mock environment variables to be used during unit testing. Signed-off-by: Simon McVittie <smcv@collabora.com> --- pressure-vessel/wrap-setup.c | 5 ++++- pressure-vessel/wrap-setup.h | 1 + pressure-vessel/wrap.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pressure-vessel/wrap-setup.c b/pressure-vessel/wrap-setup.c index eb734d07c..ddce9cd3a 100644 --- a/pressure-vessel/wrap-setup.c +++ b/pressure-vessel/wrap-setup.c @@ -343,6 +343,8 @@ pv_wrap_move_into_scope (const char *steam_app_id) * namespace, possibly including special ld.so tokens such as `$LIB`, * or basename of a preloadable module to be found in the standard * library search path + * @env: (array zero-terminated=1) (element-type filename): Environment + * variables to be used instead of `environ` * @flags: Flags to adjust behaviour * @runtime: (nullable): Runtime to be used in container * @exports: (nullable): Used to configure extra paths that need to be @@ -356,6 +358,7 @@ pv_wrap_append_preload (GPtrArray *argv, const char *variable, const char *option, const char *preload, + GStrv env, PvAppendPreloadFlags flags, PvRuntime *runtime, FlatpakExports *exports) @@ -437,7 +440,7 @@ pv_wrap_append_preload (GPtrArray *argv, else { const gchar *steam_path = NULL; - steam_path = g_getenv ("STEAM_COMPAT_CLIENT_INSTALL_PATH"); + steam_path = g_environ_getenv (env, "STEAM_COMPAT_CLIENT_INSTALL_PATH"); if (steam_path != NULL && flatpak_has_path_prefix (preload, steam_path)) { diff --git a/pressure-vessel/wrap-setup.h b/pressure-vessel/wrap-setup.h index 45a7b463a..0c13cecee 100644 --- a/pressure-vessel/wrap-setup.h +++ b/pressure-vessel/wrap-setup.h @@ -62,6 +62,7 @@ void pv_wrap_append_preload (GPtrArray *argv, const char *variable, const char *option, const char *preload, + GStrv env, PvAppendPreloadFlags flags, PvRuntime *runtime, FlatpakExports *exports); diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c index 16e3ce41e..6cd018d9b 100644 --- a/pressure-vessel/wrap.c +++ b/pressure-vessel/wrap.c @@ -2118,6 +2118,7 @@ main (int argc, variable, option, g_ptr_array_index (values, j), + environ, append_preload_flags, runtime, exports); -- GitLab