Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • steamrt/steam-runtime-tools
1 result
Show changes
Commits on Source (22)
Showing
with 365 additions and 365 deletions
......@@ -1617,7 +1617,7 @@ main (int argc,
server->purpose = opt_purpose;
if (opt_verbose || opt_hint)
if (_srt_util_is_debugging () || opt_hint)
server->flags |= PV_LAUNCHER_SERVER_FLAGS_HINT;
if (opt_stop_on_exit)
......
steam-runtime-tools (0.20231115.0) UNRELEASED; urgency=medium
steam-runtime-tools (0.20231117.0) UNRELEASED; urgency=medium
* pressure-vessel:
- Log a warning if we can't set up /etc/timezone
- If emitting debug messages, include the full contents of the new
ld.so.cache (Helps: steamrt/tasks#357, steam-runtime#630)
- Make SRT_LOG=debug activate extra output.
Previously, only --verbose or PRESSURE_VESSEL_VERBOSE would have
activated this.
- Refactoring
* Library code:
- Refactor helper subprocess launching
- Make execution environment for helper subprocesses more consistent
-- Simon McVittie <smcv@collabora.com> Wed, 15 Nov 2023 14:12:04 +0000
-- Simon McVittie <smcv@collabora.com> Fri, 17 Nov 2023 18:29:21 +0000
steam-runtime-tools (0.20231107.1) steamrt; urgency=medium
......
......@@ -637,7 +637,7 @@ regenerate_ld_so_cache (const GPtrArray *ld_so_cache_paths,
g_ptr_array_add (argv, new_path);
g_ptr_array_add (argv, (char *) "-X"); /* Don't update symlinks */
if (opt_verbose)
if (_srt_util_is_debugging ())
g_ptr_array_add (argv, (char *) "-v");
g_ptr_array_add (argv, NULL);
......@@ -684,6 +684,37 @@ regenerate_ld_so_cache (const GPtrArray *ld_so_cache_paths,
return glnx_prefix_error (error, "Cannot move %s to %s",
new_path, replace_path);
if (_srt_util_is_debugging ())
{
const char * const read_back_argv[] =
{
"/sbin/ldconfig",
"-p",
NULL
};
g_clear_pointer (&child_stdout, g_free);
g_clear_pointer (&child_stderr, g_free);
if (!run_helper_sync (NULL,
read_back_argv,
global_original_environ,
&child_stdout,
&child_stderr,
&wait_status,
error))
return glnx_prefix_error (error, "Cannot run /sbin/ldconfig -p");
if (child_stdout != NULL && child_stdout[0] != '\0')
g_debug ("ldconfig -p output:\n%s", child_stdout);
if (child_stderr != NULL && child_stderr[0] != '\0')
g_debug ("ldconfig -p diagnostic output:\n%s", child_stderr);
if (wait_status != 0)
g_debug ("ldconfig -p wait status:\n%d", wait_status);
}
return TRUE;
}
......@@ -1182,9 +1213,17 @@ main (int argc,
error))
{
g_debug ("Generated ld.so.cache in %s", opt_regenerate_ld_so_cache);
g_debug ("Setting LD_LIBARY_PATH to \"%s\"", opt_set_ld_library_path);
flatpak_bwrap_set_env (wrapped_command, "LD_LIBRARY_PATH",
opt_set_ld_library_path, TRUE);
if (opt_set_ld_library_path == NULL)
{
g_debug ("No new value for LD_LIBRARY_PATH available");
}
else
{
g_debug ("Setting LD_LIBRARY_PATH to \"%s\"", opt_set_ld_library_path);
flatpak_bwrap_set_env (wrapped_command, "LD_LIBRARY_PATH",
opt_set_ld_library_path, TRUE);
}
}
else
{
......@@ -1201,7 +1240,7 @@ main (int argc,
}
else if (opt_set_ld_library_path != NULL)
{
g_debug ("Setting LD_LIBARY_PATH to \"%s\"", opt_set_ld_library_path);
g_debug ("Setting LD_LIBRARY_PATH to \"%s\"", opt_set_ld_library_path);
flatpak_bwrap_set_env (wrapped_command, "LD_LIBRARY_PATH",
opt_set_ld_library_path, TRUE);
}
......@@ -1246,7 +1285,7 @@ main (int argc,
child_setup_data.pass_fds = (const int *) pass_fds->data;
child_setup_data.n_pass_fds = pass_fds->len;
if (opt_verbose)
if (_srt_util_is_debugging ())
{
g_debug ("Command-line:");
......
......@@ -2116,7 +2116,7 @@ pv_runtime_new (const char *source,
const char *bubblewrap,
PvGraphicsProvider *provider,
PvGraphicsProvider *interpreter_host_provider,
const GStrv original_environ,
const char * const *original_environ,
PvRuntimeFlags flags,
GError **error)
{
......@@ -7792,7 +7792,7 @@ pv_runtime_bind (PvRuntime *self,
gsize j;
search_path = _srt_graphics_get_vulkan_search_paths (self->real_root,
self->original_environ,
_srt_const_strv (self->original_environ),
pv_multiarch_tuples,
suffix);
......@@ -8067,7 +8067,7 @@ pv_runtime_log_overrides (PvRuntime *self)
g_debug ("Overrides in %s:", self->overrides_in_container);
listing = _srt_recursive_list_content (self->overrides, -1, ".", -1,
environ, NULL);
_srt_peek_environ_nonnull (), NULL);
for (i = 0; listing[i] != NULL; i++)
g_debug ("\t%s", listing[i]);
......@@ -8086,7 +8086,7 @@ pv_runtime_log_container (PvRuntime *self)
g_debug ("All files in container, excluding any extra bind mounts:");
listing = _srt_recursive_list_content (self->runtime_files, -1, ".", -1,
environ, NULL);
_srt_peek_environ_nonnull (), NULL);
for (i = 0; listing[i] != NULL; i++)
g_debug ("\t%s", listing[i]);
......
......@@ -104,7 +104,7 @@ PvRuntime *pv_runtime_new (const char *source,
const char *bubblewrap,
PvGraphicsProvider *provider,
PvGraphicsProvider *interpreter_host_provider,
const GStrv original_environ,
const char * const *original_environ,
PvRuntimeFlags flags,
GError **error);
......
......@@ -284,7 +284,7 @@ pv_wrap_add_gamescope_args (FlatpakBwrap *sharing_bwrap,
*/
FlatpakBwrap *
pv_wrap_share_sockets (PvEnviron *container_env,
const GStrv original_environ,
const char * const *original_environ,
gboolean using_a_runtime,
gboolean is_flatpak_env)
{
......@@ -405,7 +405,7 @@ pv_wrap_share_sockets (PvEnviron *container_env,
*/
void
pv_wrap_set_icons_env_vars (PvEnviron *container_env,
const GStrv original_environ)
const char * const *original_environ)
{
g_autoptr(GString) new_data_dirs = g_string_new ("");
g_autoptr(GString) new_xcursor_path = g_string_new ("");
......@@ -414,7 +414,7 @@ pv_wrap_set_icons_env_vars (PvEnviron *container_env,
const gchar *container_xdg_data_home = NULL;
g_autofree gchar *data_home_icons = NULL;
original_xcursor_path = g_environ_getenv (original_environ, "XCURSOR_PATH");
original_xcursor_path = _srt_environ_getenv (original_environ, "XCURSOR_PATH");
/* Cursors themes are searched in a few hardcoded paths. However if "XCURSOR_PATH"
* is set, the user specified paths will override the hardcoded ones.
* In order to keep the hardcoded paths in place, if "XCURSOR_PATH" is unset, we
......@@ -452,7 +452,7 @@ pv_wrap_set_icons_env_vars (PvEnviron *container_env,
initial_xdg_data_dirs = pv_environ_getenv (container_env, "XDG_DATA_DIRS");
if (initial_xdg_data_dirs == NULL)
initial_xdg_data_dirs = g_environ_getenv (original_environ, "XDG_DATA_DIRS");
initial_xdg_data_dirs = _srt_environ_getenv (original_environ, "XDG_DATA_DIRS");
/* Reference:
* https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html */
......
......@@ -38,12 +38,12 @@ gchar *pv_wrap_check_bwrap (const char *tools_dir,
PvBwrapFlags *flags_out);
FlatpakBwrap *pv_wrap_share_sockets (PvEnviron *container_env,
const GStrv original_environ,
const char * const *original_environ,
gboolean using_a_runtime,
gboolean is_flatpak_env);
void pv_wrap_set_icons_env_vars (PvEnviron *container_env,
const GStrv original_environ);
const char * const *original_environ);
gboolean pv_wrap_use_host_os (int root_fd,
FlatpakExports *exports,
......
......@@ -1362,7 +1362,7 @@ main (int argc,
_srt_get_current_dirs (&cwd_p, &cwd_l);
if (opt_verbose)
if (_srt_util_is_debugging ())
{
g_auto(GStrv) env = g_strdupv (original_environ);
......@@ -1602,7 +1602,7 @@ main (int argc,
goto out;
}
if (opt_verbose)
if (_srt_util_is_debugging ())
flags |= PV_RUNTIME_FLAGS_VERBOSE;
if (opt_import_vulkan_layers)
......@@ -1673,7 +1673,7 @@ main (int argc,
bwrap_executable,
graphics_provider,
interpreter_host_provider,
original_environ,
_srt_const_strv (original_environ),
flags,
error);
......@@ -2030,7 +2030,7 @@ main (int argc,
g_autoptr(FlatpakBwrap) sharing_bwrap = NULL;
sharing_bwrap = pv_wrap_share_sockets (container_env,
original_environ,
_srt_const_strv (original_environ),
(runtime != NULL),
is_flatpak_env);
g_warn_if_fail (g_strv_length (sharing_bwrap->envp) == 0);
......@@ -2042,7 +2042,7 @@ main (int argc,
}
else if (flatpak_subsandbox != NULL)
{
pv_wrap_set_icons_env_vars (container_env, original_environ);
pv_wrap_set_icons_env_vars (container_env, _srt_const_strv (original_environ));
}
if (runtime != NULL)
......@@ -2164,7 +2164,7 @@ main (int argc,
return FALSE;
if (opt_verbose)
if (_srt_util_is_debugging ())
{
g_debug ("%s options before bundling:", bwrap_executable);
......@@ -2306,7 +2306,7 @@ main (int argc,
flatpak_bwrap_append_args (adverb_argv, adverb_preload_argv);
if (opt_verbose)
if (_srt_util_is_debugging ())
flatpak_bwrap_add_arg (adverb_argv, "--verbose");
flatpak_bwrap_add_arg (adverb_argv, "--");
......@@ -2325,7 +2325,7 @@ main (int argc,
g_debug ("Adding steam-runtime-launcher-service '%s'...", launcher_service);
flatpak_bwrap_add_arg (launcher_argv, launcher_service);
if (opt_verbose)
if (_srt_util_is_debugging ())
flatpak_bwrap_add_arg (launcher_argv, "--verbose");
/* In --launcher mode, arguments after the "--" separator are
......@@ -2373,7 +2373,7 @@ main (int argc,
* to make debugging a bit easier. */
flatpak_bwrap_sort_envp (final_argv);
if (opt_verbose)
if (_srt_util_is_debugging ())
{
if (runtime != NULL && (pv_log_flags & PV_WRAP_LOG_FLAGS_OVERRIDES))
pv_runtime_log_overrides (runtime);
......
......@@ -28,6 +28,8 @@
#include <glib.h>
#include "steam-runtime-tools/subprocess-internal.h"
typedef struct
{
const char *multiarch_tuple;
......@@ -41,8 +43,7 @@ typedef struct
G_GNUC_INTERNAL const SrtKnownArchitecture *_srt_architecture_get_known (void);
G_GNUC_INTERNAL const SrtKnownArchitecture *_srt_architecture_get_by_tuple (const char *multiarch_tuple);
G_GNUC_INTERNAL gboolean _srt_architecture_can_run (gchar **envp,
const char *helpers_path,
G_GNUC_INTERNAL gboolean _srt_architecture_can_run (SrtSubprocessRunner *runner,
const char *multiarch);
const gchar *_srt_architecture_guess_from_elf (int dfd,
......
......@@ -112,22 +112,22 @@ _srt_architecture_get_known (void)
}
gboolean
_srt_architecture_can_run (gchar **envp,
const char *helpers_path,
_srt_architecture_can_run (SrtSubprocessRunner *runner,
const char *multiarch)
{
g_autoptr(SrtCompletedSubprocess) completed = NULL;
GPtrArray *argv = NULL;
int exit_status = -1;
GError *error = NULL;
gboolean ret = FALSE;
GStrv my_environ = NULL;
SrtHelperFlags helper_flags = SRT_HELPER_FLAGS_NONE;
g_return_val_if_fail (envp != NULL, FALSE);
g_return_val_if_fail (SRT_IS_SUBPROCESS_RUNNER (runner), FALSE);
g_return_val_if_fail (multiarch != NULL, FALSE);
g_return_val_if_fail (_srt_check_not_setuid (), FALSE);
argv = _srt_get_helper (helpers_path, multiarch, "true",
SRT_HELPER_FLAGS_NONE, &error);
argv = _srt_subprocess_runner_get_helper (runner, multiarch, "true",
helper_flags, &error);
if (argv == NULL)
{
g_debug ("%s", error->message);
......@@ -139,33 +139,22 @@ _srt_architecture_can_run (gchar **envp,
g_debug ("Testing architecture %s with %s",
multiarch, (const char *) g_ptr_array_index (argv, 0));
my_environ = _srt_filter_gameoverlayrenderer_from_envp (envp);
if (!g_spawn_sync (NULL, /* working directory */
(gchar **) argv->pdata,
my_environ, /* envp */
0, /* flags */
_srt_child_setup_unblock_signals,
NULL, /* user data */
NULL, /* stdout */
NULL, /* stderr */
&exit_status,
&error))
{
g_debug ("... %s", error->message);
goto out;
}
completed = _srt_subprocess_runner_run_sync (runner,
helper_flags,
(const char * const *) argv->pdata,
SRT_SUBPROCESS_OUTPUT_CAPTURE_DEBUG,
SRT_SUBPROCESS_OUTPUT_CAPTURE_DEBUG,
&error);
if (exit_status != 0)
if (completed == NULL || !_srt_completed_subprocess_check (completed, &error))
{
g_debug ("... wait status %d", exit_status);
g_debug ("... %s", error->message);
goto out;
}
g_debug ("... it works");
ret = TRUE;
out:
g_strfreev (my_environ);
g_clear_error (&error);
g_clear_pointer (&argv, g_ptr_array_unref);
return ret;
......@@ -197,8 +186,9 @@ out:
gboolean
srt_architecture_can_run_i386 (void)
{
return _srt_architecture_can_run ((gchar **) _srt_peek_environ_nonnull (),
NULL, SRT_ABI_I386);
g_autoptr(SrtSubprocessRunner) runner = _srt_subprocess_runner_new ();
return _srt_architecture_can_run (runner, SRT_ABI_I386);
}
/**
......@@ -216,8 +206,9 @@ srt_architecture_can_run_i386 (void)
gboolean
srt_architecture_can_run_x86_64 (void)
{
return _srt_architecture_can_run ((gchar **) _srt_peek_environ_nonnull (),
NULL, SRT_ABI_X86_64);
g_autoptr(SrtSubprocessRunner) runner = _srt_subprocess_runner_new ();
return _srt_architecture_can_run (runner, SRT_ABI_X86_64);
}
/**
......
......@@ -28,6 +28,7 @@
#include "steam-runtime-tools/glib-backports-internal.h"
#include "steam-runtime-tools/steam-runtime-tools.h"
#include "steam-runtime-tools/subprocess-internal.h"
#include <json-glib/json-glib.h>
......@@ -77,9 +78,7 @@ typedef enum
SRT_DISPLAY_EXIT_STATUS_ERROR = 3,
} SrtDisplayExitStatus;
SrtDisplayInfo *_srt_check_display (gchar **envp,
const char *helpers_path,
SrtTestFlags test_flags,
SrtDisplayInfo *_srt_check_display (SrtSubprocessRunner *runner,
const char *multiarch_tuple);
SrtDisplayInfo *_srt_display_info_get_from_report (JsonObject *json_obj);
......@@ -227,34 +227,30 @@ srt_display_info_class_init (SrtDisplayInfoClass *cls)
/**
* _srt_check_display:
* @envp: (not nullable): Environment variables to use
* @helpers_path: An optional path to find check-xdg-portal helper, PATH
* is used if %NULL.
* @test_flags: Flags used during automated testing
* @runner: The execution environment
* @multiarch_tuple: (not nullable): Multiarch tuple of helper executable to use
*
* Returns: A SrtDisplayInfo object containing the details of the check
*/
SrtDisplayInfo *
_srt_check_display (gchar **envp,
const char *helpers_path,
SrtTestFlags test_flags,
_srt_check_display (SrtSubprocessRunner *runner,
const char *multiarch_tuple)
{
GPtrArray *builder;
g_auto(GStrv) display_environ = NULL;
g_autoptr(GPtrArray) argv = NULL;
g_autoptr(GError) local_error = NULL;
g_autofree gchar *x11_messages = NULL;
g_autoptr(SrtCompletedSubprocess) completed = NULL;
const char *x11_messages = NULL;
const gchar *name;
int wait_status = -1;
int exit_status = -1;
int terminating_signal = 0;
gboolean timed_out = FALSE;
gboolean wayland_session = FALSE;
SrtDisplayWaylandIssues wayland_issues = SRT_DISPLAY_WAYLAND_ISSUES_NONE;
SrtDisplayX11Type x11_type = SRT_DISPLAY_X11_TYPE_UNKNOWN;
SrtHelperFlags helper_flags = (SRT_HELPER_FLAGS_TIME_OUT
| SRT_HELPER_FLAGS_SEARCH_PATH);
const char * const *envp;
static const gchar * const display_env[] =
{
"CLUTTER_BACKEND",
......@@ -270,7 +266,7 @@ _srt_check_display (gchar **envp,
NULL
};
g_return_val_if_fail (envp != NULL,
g_return_val_if_fail (SRT_IS_SUBPROCESS_RUNNER (runner),
_srt_display_info_new (NULL, FALSE,
SRT_DISPLAY_WAYLAND_ISSUES_UNKNOWN,
SRT_DISPLAY_X11_TYPE_UNKNOWN, NULL));
......@@ -280,10 +276,11 @@ _srt_check_display (gchar **envp,
SRT_DISPLAY_X11_TYPE_UNKNOWN, NULL));
builder = g_ptr_array_new_with_free_func (g_free);
envp = _srt_subprocess_runner_get_environ (runner);
for (guint i = 0; display_env[i] != NULL; i++)
{
const gchar *value = g_environ_getenv (envp, display_env[i]);
const gchar *value = _srt_environ_getenv (envp, display_env[i]);
if (value != NULL)
{
g_autofree gchar *key_value = NULL;
......@@ -295,7 +292,7 @@ _srt_check_display (gchar **envp,
g_ptr_array_add (builder, NULL);
display_environ = (gchar **) g_ptr_array_free (builder, FALSE);
name = g_environ_getenv (envp, "WAYLAND_DISPLAY");
name = _srt_environ_getenv (envp, "WAYLAND_DISPLAY");
/* If unset, the default fallback is `wayland-0` */
if (name == NULL)
name = "wayland-0";
......@@ -311,7 +308,7 @@ _srt_check_display (gchar **envp,
else
{
const gchar *xdg_runtime_dir;
xdg_runtime_dir = g_environ_getenv (envp, "XDG_RUNTIME_DIR");
xdg_runtime_dir = _srt_environ_getenv (envp, "XDG_RUNTIME_DIR");
if (xdg_runtime_dir == NULL)
{
......@@ -331,53 +328,45 @@ _srt_check_display (gchar **envp,
}
}
if (test_flags & SRT_TEST_FLAGS_TIME_OUT_SOONER)
helper_flags |= SRT_HELPER_FLAGS_TIME_OUT_SOONER;
argv = _srt_get_helper (helpers_path, multiarch_tuple, "is-x-server-xwayland",
helper_flags, &local_error);
argv = _srt_subprocess_runner_get_helper (runner, multiarch_tuple,
"is-x-server-xwayland",
helper_flags, &local_error);
if (argv == NULL)
{
g_debug ("An error occurred trying to check if the X server was XWayland: %s",
local_error->message);
x11_messages = g_strdup (local_error->message);
x11_messages = local_error->message;
goto out;
}
/* NULL terminate the array */
g_ptr_array_add (argv, NULL);
if (!g_spawn_sync (NULL, /* working directory */
(gchar **) argv->pdata,
envp,
G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL,
_srt_child_setup_unblock_signals,
NULL, /* user data */
NULL, /* stdout */
&x11_messages,
&wait_status,
&local_error))
completed = _srt_subprocess_runner_run_sync (runner,
helper_flags,
(const char * const *) argv->pdata,
SRT_SUBPROCESS_OUTPUT_SILENCE,
SRT_SUBPROCESS_OUTPUT_CAPTURE,
&local_error);
if (completed == NULL)
{
g_debug ("An error occurred calling the helper: %s", local_error->message);
x11_messages = g_strdup (local_error->message);
x11_messages = local_error->message;
goto out;
}
x11_messages = _srt_completed_subprocess_get_stderr (completed);
/* Normalize the empty string (expected to be common) to NULL */
if (x11_messages != NULL && x11_messages[0] == '\0')
g_clear_pointer (&x11_messages, g_free);
x11_messages = NULL;
if (wait_status != 0)
{
g_debug ("... wait status %d", wait_status);
if (_srt_process_timeout_wait_status (wait_status, &exit_status, &terminating_signal))
goto out;
}
else
{
exit_status = 0;
}
_srt_completed_subprocess_report (completed, NULL, &exit_status, NULL, &timed_out);
if (timed_out)
goto out;
if (exit_status == SRT_DISPLAY_EXIT_STATUS_IS_XWAYLAND)
x11_type = SRT_DISPLAY_X11_TYPE_XWAYLAND;
......
......@@ -897,8 +897,7 @@ get_glvnd_datadir (void)
* @helpers_path: (nullable): An optional path to find "inspect-library"
* helper, PATH is used if %NULL
* @sysroot: (not nullable): The root directory, usually `/`
* @envp: (array zero-terminated=1) (not nullable): Behave as though `environ`
* was this array
* @runner: The execution environment
* @multiarch_tuples: (nullable): If not %NULL, and a Flatpak environment
* is detected, assume a freedesktop-sdk-based runtime and look for
* GL extensions for these multiarch tuples. Also if not %NULL, duplicated
......@@ -915,9 +914,8 @@ get_glvnd_datadir (void)
*/
GList *
_srt_load_egl_things (GType which,
const char *helpers_path,
SrtSysroot *sysroot,
gchar **envp,
SrtSubprocessRunner *runner,
const char * const *multiarch_tuples,
SrtCheckFlags check_flags)
{
......@@ -932,13 +930,14 @@ _srt_load_egl_things (GType which,
const char *suffix;
const char *sysconfdir;
const char *datadir;
const char * const *envp;
g_return_val_if_fail (which == SRT_TYPE_EGL_ICD
|| which == SRT_TYPE_EGL_EXTERNAL_PLATFORM,
NULL);
g_return_val_if_fail (SRT_IS_SYSROOT (sysroot), NULL);
g_return_val_if_fail (SRT_IS_SUBPROCESS_RUNNER (runner), NULL);
g_return_val_if_fail (_srt_check_not_setuid (), NULL);
g_return_val_if_fail (envp != NULL, NULL);
/* See
* https://github.com/NVIDIA/libglvnd/blob/HEAD/src/EGL/icd_enumeration.md
......@@ -972,7 +971,8 @@ _srt_load_egl_things (GType which,
g_return_val_if_reached (NULL);
}
value = g_environ_getenv (envp, filenames_var);
envp = _srt_subprocess_runner_get_environ (runner);
value = _srt_environ_getenv (envp, filenames_var);
if (value != NULL)
{
......@@ -983,7 +983,7 @@ _srt_load_egl_things (GType which,
}
else
{
value = g_environ_getenv (envp, dirs_var);
value = _srt_environ_getenv (envp, dirs_var);
if (value != NULL)
{
......@@ -1020,8 +1020,7 @@ _srt_load_egl_things (GType which,
}
if (!(check_flags & SRT_CHECK_FLAGS_SKIP_SLOW_CHECKS))
_srt_loadable_flag_duplicates (which, envp, helpers_path,
multiarch_tuples, ret);
_srt_loadable_flag_duplicates (which, runner, multiarch_tuples, ret);
return g_list_reverse (ret);
}
......@@ -28,6 +28,7 @@
#include "steam-runtime-tools/steam-runtime-tools.h"
#include "steam-runtime-tools/graphics-internal.h"
#include "steam-runtime-tools/subprocess-internal.h"
#include "steam-runtime-tools/utils-internal.h"
typedef struct
......@@ -131,8 +132,7 @@ gboolean srt_loadable_write_to_file (const SrtLoadable *self,
GType which,
GError **error);
void _srt_loadable_flag_duplicates (GType which,
gchar **envp,
const char *helpers_path,
SrtSubprocessRunner *runner,
const char * const *multiarch_tuples,
GList *loadable);
void _srt_loadable_set_library_arch (SrtLoadable *self,
......
......@@ -393,14 +393,13 @@ srt_loadable_write_to_file (const SrtLoadable *self,
* resolving also its eventual symbolic links.
*/
static gchar *
_get_library_canonical_path (gchar **envp,
const char *helpers_path,
_get_library_canonical_path (SrtSubprocessRunner *runner,
const char *multiarch,
const gchar *library_path)
{
g_autoptr(SrtLibrary) library = NULL;
_srt_check_library_presence (helpers_path, library_path, multiarch, NULL,
NULL, SRT_CHECK_FLAGS_SKIP_SLOW_CHECKS, envp,
_srt_check_library_presence (runner, library_path, multiarch, NULL,
NULL, SRT_CHECK_FLAGS_SKIP_SLOW_CHECKS,
SRT_LIBRARY_SYMBOLS_FORMAT_PLAIN, &library);
/* Use realpath() because the path might still be a symbolic link or it can
......@@ -459,8 +458,7 @@ _update_duplicated_value (GType which,
}
/*
* @helpers_path: (nullable): An optional path to find "inspect-library"
* helper, PATH is used if %NULL
* @runner: The execution environment
* @loadable: (inout) (element-type SrtVulkanLayer):
*
* Iterate the provided @loadable list and update their "issues" property
......@@ -472,8 +470,7 @@ _update_duplicated_value (GType which,
*/
void
_srt_loadable_flag_duplicates (GType which,
gchar **envp,
const char *helpers_path,
SrtSubprocessRunner *runner,
const char * const *multiarch_tuples,
GList *loadable)
{
......@@ -518,7 +515,7 @@ _srt_loadable_flag_duplicates (GType which,
for (i = 0; multiarch_tuples[i] != NULL; i++)
{
g_autofree gchar *canonical_path = NULL;
canonical_path = _get_library_canonical_path (envp, helpers_path,
canonical_path = _get_library_canonical_path (runner,
multiarch_tuples[i],
resolved_path);
......@@ -560,7 +557,7 @@ _srt_loadable_flag_duplicates (GType which,
{
g_autofree gchar *canonical_path = NULL;
g_autofree gchar *hash_key = NULL;
canonical_path = _get_library_canonical_path (envp, helpers_path,
canonical_path = _get_library_canonical_path (runner,
multiarch_tuples[i],
resolved_path);
......
......@@ -584,7 +584,7 @@ get_vulkan_sysconfdir (void)
* parameters. */
gchar **
_srt_graphics_get_vulkan_search_paths (SrtSysroot *sysroot,
gchar **envp,
const char * const *envp,
const char * const *multiarch_tuples,
const char *suffix)
{
......@@ -594,13 +594,13 @@ _srt_graphics_get_vulkan_search_paths (SrtSysroot *sysroot,
const gchar *value;
gsize i;
home = g_environ_getenv (envp, "HOME");
home = _srt_environ_getenv (envp, "HOME");
if (home == NULL)
home = g_get_home_dir ();
/* 1. $XDG_CONFIG_HOME or $HOME/.config (since 1.2.198) */
value = g_environ_getenv (envp, "XDG_CONFIG_HOME");
value = _srt_environ_getenv (envp, "XDG_CONFIG_HOME");
if (value != NULL)
g_ptr_array_add (search_paths, g_build_filename (value, suffix, NULL));
......@@ -608,7 +608,7 @@ _srt_graphics_get_vulkan_search_paths (SrtSysroot *sysroot,
g_ptr_array_add (search_paths, g_build_filename (home, ".config", suffix, NULL));
/* 1a. $XDG_CONFIG_DIRS or /etc/xdg */
value = g_environ_getenv (envp, "XDG_CONFIG_DIRS");
value = _srt_environ_getenv (envp, "XDG_CONFIG_DIRS");
/* Constant and non-configurable fallback, as per
* https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */
......@@ -673,7 +673,7 @@ _srt_graphics_get_vulkan_search_paths (SrtSysroot *sysroot,
* https://github.com/ValveSoftware/steam-for-linux/issues/8337
* So for now we continue to follow the misinterpretation, to make the
* Steam Overlay more likely to work in pressure-vessel containers. */
value = g_environ_getenv (envp, "XDG_DATA_HOME");
value = _srt_environ_getenv (envp, "XDG_DATA_HOME");
if (value != NULL)
g_ptr_array_add (search_paths, g_build_filename (value, suffix, NULL));
......@@ -701,7 +701,7 @@ _srt_graphics_get_vulkan_search_paths (SrtSysroot *sysroot,
}
/* 5. $XDG_DATA_DIRS or /usr/local/share:/usr/share */
value = g_environ_getenv (envp, "XDG_DATA_DIRS");
value = _srt_environ_getenv (envp, "XDG_DATA_DIRS");
/* Constant and non-configurable fallback, as per
* https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */
......@@ -719,11 +719,8 @@ _srt_graphics_get_vulkan_search_paths (SrtSysroot *sysroot,
/*
* _srt_load_vulkan_icds:
* @helpers_path: (nullable): An optional path to find "inspect-library"
* helper, PATH is used if %NULL
* @sysroot: (not nullable): The root directory, usually `/`
* @envp: (array zero-terminated=1) (not nullable): Behave as though `environ` was this
* array
* @runner: The execution environment
* @multiarch_tuples: (nullable): If not %NULL, and a Flatpak environment
* is detected, assume a freedesktop-sdk-based runtime and look for
* GL extensions for these multiarch tuples
......@@ -741,12 +738,12 @@ _srt_graphics_get_vulkan_search_paths (SrtSysroot *sysroot,
* most-important first
*/
GList *
_srt_load_vulkan_icds (const char *helpers_path,
SrtSysroot *sysroot,
gchar **envp,
_srt_load_vulkan_icds (SrtSysroot *sysroot,
SrtSubprocessRunner *runner,
const char * const *multiarch_tuples,
SrtCheckFlags check_flags)
{
const char * const *envp;
const gchar *value;
gsize i;
/* To avoid O(n**2) performance, we build this list in reverse order,
......@@ -754,17 +751,18 @@ _srt_load_vulkan_icds (const char *helpers_path,
GList *ret = NULL;
g_return_val_if_fail (_srt_check_not_setuid (), NULL);
g_return_val_if_fail (envp != NULL, NULL);
g_return_val_if_fail (SRT_IS_SYSROOT (sysroot), NULL);
g_return_val_if_fail (SRT_IS_SUBPROCESS_RUNNER (runner), NULL);
/* Reference:
* https://github.com/KhronosGroup/Vulkan-Loader/blob/v1.3.207/docs/LoaderDriverInterface.md#overriding-the-default-driver-discovery
* https://github.com/KhronosGroup/Vulkan-Loader/pull/873
*/
value = g_environ_getenv (envp, "VK_DRIVER_FILES");
envp = _srt_subprocess_runner_get_environ (runner);
value = _srt_environ_getenv (envp, "VK_DRIVER_FILES");
if (value == NULL)
value = g_environ_getenv (envp, "VK_ICD_FILENAMES");
value = _srt_environ_getenv (envp, "VK_ICD_FILENAMES");
if (value != NULL)
{
......@@ -782,7 +780,7 @@ _srt_load_vulkan_icds (const char *helpers_path,
const gchar *add;
g_auto(GStrv) search_paths = NULL;
add = g_environ_getenv (envp, "VK_ADD_DRIVER_FILES");
add = _srt_environ_getenv (envp, "VK_ADD_DRIVER_FILES");
search_paths = _srt_graphics_get_vulkan_search_paths (sysroot, envp,
multiarch_tuples,
_SRT_GRAPHICS_VULKAN_ICD_SUFFIX);
......@@ -803,7 +801,7 @@ _srt_load_vulkan_icds (const char *helpers_path,
}
if (!(check_flags & SRT_CHECK_FLAGS_SKIP_SLOW_CHECKS))
_srt_loadable_flag_duplicates (SRT_TYPE_VULKAN_ICD, envp, helpers_path,
_srt_loadable_flag_duplicates (SRT_TYPE_VULKAN_ICD, runner,
multiarch_tuples, ret);
return g_list_reverse (ret);
......@@ -1659,11 +1657,8 @@ vulkan_layer_load_json_cb (SrtSysroot *sysroot,
/*
* _srt_load_vulkan_layers_extended:
* @helpers_path: (nullable): An optional path to find "inspect-library"
* helper, PATH is used if %NULL
* @sysroot: (not nullable): The root directory, usually `/`
* @envp: (array zero-terminated=1) (not nullable): Behave as though `environ`
* was this array
* @runner: The execution environment
* @multiarch_tuples: (nullable): If not %NULL, duplicated
* Vulkan layers are searched by their absolute path, obtained using
* 'inspect-library' in the provided multiarch tuples, instead of just their
......@@ -1678,9 +1673,8 @@ vulkan_layer_load_json_cb (SrtSysroot *sysroot,
* layers, most-important first
*/
GList *
_srt_load_vulkan_layers_extended (const char *helpers_path,
SrtSysroot *sysroot,
gchar **envp,
_srt_load_vulkan_layers_extended (SrtSysroot *sysroot,
SrtSubprocessRunner *runner,
const char * const *multiarch_tuples,
gboolean explicit,
SrtCheckFlags check_flags)
......@@ -1689,17 +1683,19 @@ _srt_load_vulkan_layers_extended (const char *helpers_path,
g_auto(GStrv) search_paths = NULL;
const gchar *value = NULL;
const gchar *suffix;
const char * const *envp;
g_return_val_if_fail (_srt_check_not_setuid (), NULL);
g_return_val_if_fail (envp != NULL, NULL);
g_return_val_if_fail (SRT_IS_SYSROOT (sysroot), NULL);
g_return_val_if_fail (SRT_IS_SUBPROCESS_RUNNER (runner), NULL);
if (explicit)
suffix = _SRT_GRAPHICS_EXPLICIT_VULKAN_LAYER_SUFFIX;
else
suffix = _SRT_GRAPHICS_IMPLICIT_VULKAN_LAYER_SUFFIX;
value = g_environ_getenv (envp, "VK_LAYER_PATH");
envp = _srt_subprocess_runner_get_environ (runner);
value = _srt_environ_getenv (envp, "VK_LAYER_PATH");
/* As in the Vulkan-Loader implementation, implicit layers are not
* overridden by "VK_LAYER_PATH"
......@@ -1717,7 +1713,7 @@ _srt_load_vulkan_layers_extended (const char *helpers_path,
const gchar *add = NULL;
if (explicit)
add = g_environ_getenv (envp, "VK_ADD_LAYER_PATH");
add = _srt_environ_getenv (envp, "VK_ADD_LAYER_PATH");
if (add != NULL)
{
......@@ -1737,7 +1733,7 @@ _srt_load_vulkan_layers_extended (const char *helpers_path,
}
if (!(check_flags & SRT_CHECK_FLAGS_SKIP_SLOW_CHECKS))
_srt_loadable_flag_duplicates (SRT_TYPE_VULKAN_LAYER, envp, helpers_path,
_srt_loadable_flag_duplicates (SRT_TYPE_VULKAN_LAYER, runner,
multiarch_tuples, ret);
return g_list_reverse (ret);
......@@ -1762,6 +1758,7 @@ _srt_load_vulkan_layers (const char *sysroot,
gboolean explicit)
{
g_autoptr(SrtSysroot) sysroot_object = NULL;
g_autoptr(SrtSubprocessRunner) runner = NULL;
g_autoptr(GError) local_error = NULL;
g_return_val_if_fail (sysroot != NULL, NULL);
......@@ -1775,7 +1772,10 @@ _srt_load_vulkan_layers (const char *sysroot,
return NULL;
}
return _srt_load_vulkan_layers_extended (NULL, sysroot_object, envp, NULL,
runner = _srt_subprocess_runner_new_full (_srt_const_strv (envp),
NULL,
SRT_TEST_FLAGS_NONE);
return _srt_load_vulkan_layers_extended (sysroot_object, runner, NULL,
explicit, SRT_CHECK_FLAGS_NONE);
}
......
This diff is collapsed.
......@@ -27,6 +27,7 @@
#pragma once
#include "steam-runtime-tools/steam-runtime-tools.h"
#include "steam-runtime-tools/subprocess-internal.h"
#include "steam-runtime-tools/system-info-internal.h"
#include "steam-runtime-tools/utils-internal.h"
......@@ -106,9 +107,7 @@ static inline int _srt_graphics_hash_key(SrtWindowSystem winsys, SrtRenderingInt
#ifndef __GTK_DOC_IGNORE__
G_GNUC_INTERNAL SrtGraphicsIssues _srt_check_graphics (gchar **envp,
const char *helpers_path,
SrtTestFlags test_flags,
G_GNUC_INTERNAL SrtGraphicsIssues _srt_check_graphics (SrtSubprocessRunner *runner,
const char *multiarch_tuple,
SrtWindowSystem window_system,
SrtRenderingInterface rendering_interface,
......@@ -288,30 +287,26 @@ typedef enum
G_GNUC_INTERNAL
GList *_srt_load_egl_things (GType which,
const char *helpers_path,
SrtSysroot *sysroot,
gchar **envp,
SrtSubprocessRunner *runner,
const char * const *multiarch_tuples,
SrtCheckFlags check_flags);
G_GNUC_INTERNAL
GList *_srt_load_vulkan_icds (const char *helpers_path,
SrtSysroot *sysroot,
gchar **envp,
GList *_srt_load_vulkan_icds (SrtSysroot *sysroot,
SrtSubprocessRunner *runner,
const char * const *multiarch_tuples,
SrtCheckFlags check_flags);
G_GNUC_INTERNAL
GList *_srt_list_graphics_modules (SrtSysroot *sysroot,
gchar **envp,
const char *helpers_path,
SrtSubprocessRunner *runner,
const char *multiarch_tuple,
SrtCheckFlags check_flags,
SrtGraphicsModule which);
G_GNUC_INTERNAL
GList *_srt_load_vulkan_layers_extended (const char *helpers_path,
SrtSysroot *sysroot,
gchar **envp,
GList *_srt_load_vulkan_layers_extended (SrtSysroot *sysroot,
SrtSubprocessRunner *runner,
const char * const *multiarch_tuples,
gboolean explicit,
SrtCheckFlags check_flags);
......@@ -331,7 +326,7 @@ GList *_srt_glx_icd_get_from_report (JsonObject *json_obj);
G_GNUC_INTERNAL
gchar ** _srt_graphics_get_vulkan_search_paths (SrtSysroot *sysroot,
gchar **envp,
const char * const *envp,
const char * const *multiarch_tuples,
const char *suffix);
......
......@@ -965,8 +965,8 @@ _srt_process_check_vulkan_info (JsonNode *node,
* @window_system: (not optional) (inout):
*/
static GPtrArray *
_argv_for_graphics_test (const char *helpers_path,
SrtTestFlags test_flags,
_argv_for_graphics_test (SrtSubprocessRunner *runner,
SrtHelperFlags flags,
const char *multiarch_tuple,
SrtWindowSystem *window_system,
SrtRenderingInterface rendering_interface,
......@@ -975,14 +975,9 @@ _argv_for_graphics_test (const char *helpers_path,
const char *api;
GPtrArray *argv = NULL;
gchar *platformstring = NULL;
SrtHelperFlags flags = (SRT_HELPER_FLAGS_TIME_OUT
| SRT_HELPER_FLAGS_SEARCH_PATH);
g_assert (window_system != NULL);
if (test_flags & SRT_TEST_FLAGS_TIME_OUT_SOONER)
flags |= SRT_HELPER_FLAGS_TIME_OUT_SOONER;
if (*window_system == SRT_WINDOW_SYSTEM_GLX)
{
switch (rendering_interface)
......@@ -1058,8 +1053,9 @@ _argv_for_graphics_test (const char *helpers_path,
{
case SRT_RENDERING_INTERFACE_GL:
case SRT_RENDERING_INTERFACE_GLESV2:
argv = _srt_get_helper (helpers_path, multiarch_tuple, "wflinfo", flags,
error);
argv = _srt_subprocess_runner_get_helper (runner, multiarch_tuple,
"wflinfo", flags,
error);
if (argv == NULL)
goto out;
......@@ -1075,8 +1071,9 @@ _argv_for_graphics_test (const char *helpers_path,
break;
case SRT_RENDERING_INTERFACE_VULKAN:
argv = _srt_get_helper (helpers_path, multiarch_tuple, "check-vulkan",
flags, error);
argv = _srt_subprocess_runner_get_helper (runner, multiarch_tuple,
"check-vulkan", flags,
error);
if (argv == NULL)
goto out;
......@@ -1084,8 +1081,9 @@ _argv_for_graphics_test (const char *helpers_path,
break;
case SRT_RENDERING_INTERFACE_VDPAU:
argv = _srt_get_helper (helpers_path, multiarch_tuple, "check-vdpau",
flags, error);
argv = _srt_subprocess_runner_get_helper (runner, multiarch_tuple,
"check-vdpau", flags,
error);
if (argv == NULL)
goto out;
......@@ -1094,8 +1092,9 @@ _argv_for_graphics_test (const char *helpers_path,
break;
case SRT_RENDERING_INTERFACE_VAAPI:
argv = _srt_get_helper (helpers_path, multiarch_tuple, "check-va-api",
flags, error);
argv = _srt_subprocess_runner_get_helper (runner, multiarch_tuple,
"check-va-api", flags,
error);
if (argv == NULL)
goto out;
......@@ -1116,19 +1115,16 @@ out:
}
static GPtrArray *
_argv_for_check_gl (const char *helpers_path,
SrtTestFlags test_flags,
_argv_for_check_gl (SrtSubprocessRunner *runner,
SrtHelperFlags flags,
const char *multiarch_tuple,
GError **error)
{
GPtrArray *argv;
SrtHelperFlags flags = SRT_HELPER_FLAGS_TIME_OUT;
if (test_flags & SRT_TEST_FLAGS_TIME_OUT_SOONER)
flags |= SRT_HELPER_FLAGS_TIME_OUT_SOONER;
argv = _srt_get_helper (helpers_path, multiarch_tuple, "check-gl",
flags, error);
argv = _srt_subprocess_runner_get_helper (runner, multiarch_tuple,
"check-gl", flags,
error);
if (argv == NULL)
return NULL;
......@@ -1139,7 +1135,7 @@ _argv_for_check_gl (const char *helpers_path,
/**
* _srt_check_library_vendor:
* @envp: (not nullable): The environment
* @runner: The execution environment
* @multiarch_tuple: A multiarch tuple to check e.g. i386-linux-gnu
* @window_system: The window system to check.
* @rendering_interface: The graphics renderer to check.
......@@ -1164,7 +1160,7 @@ _argv_for_check_gl (const char *helpers_path,
* %SRT_RENDERING_INTERFACE_VULKAN or if there was a problem loading the library.
*/
static SrtGraphicsLibraryVendor
_srt_check_library_vendor (gchar **envp,
_srt_check_library_vendor (SrtSubprocessRunner *runner,
const char *multiarch_tuple,
SrtWindowSystem window_system,
SrtRenderingInterface rendering_interface)
......@@ -1177,7 +1173,7 @@ _srt_check_library_vendor (gchar **envp,
gboolean have_libstdc_deps = FALSE;
gboolean have_libxcb_deps = FALSE;
g_return_val_if_fail (envp != NULL, SRT_GRAPHICS_LIBRARY_VENDOR_UNKNOWN);
g_return_val_if_fail (SRT_IS_SUBPROCESS_RUNNER (runner), SRT_GRAPHICS_LIBRARY_VENDOR_UNKNOWN);
/* Vulkan, VDPAU and VA-API are always vendor-neutral, so it doesn't make sense to check it.
* We simply return SRT_GRAPHICS_LIBRARY_VENDOR_UNKNOWN */
......@@ -1201,7 +1197,14 @@ _srt_check_library_vendor (gchar **envp,
g_return_val_if_reached (SRT_GRAPHICS_LIBRARY_VENDOR_UNKNOWN);
}
issues = srt_check_library_presence (soname, multiarch_tuple, NULL, SRT_LIBRARY_SYMBOLS_FORMAT_PLAIN, &library);
/* We assume libGL and libEGL have no hidden dependencies: if they did,
* games that dlopen them would have a problem. */
issues = _srt_check_library_presence (runner, soname, multiarch_tuple,
NULL, /* no symbols file */
NULL, /* no hidden dependencies */
SRT_CHECK_FLAGS_NONE,
SRT_LIBRARY_SYMBOLS_FORMAT_PLAIN,
&library);
if ((issues & SRT_LIBRARY_ISSUES_CANNOT_LOAD) != 0)
goto out;
......@@ -1251,7 +1254,8 @@ out:
/*
* Run the given helper and report any issues found
*
* @my_environ: (inout) (transfer full): The environment to modify and run the argv in
* @runner: The execution environment
* @helper_flags: (inout): Flags used to run the helper
* @output: (inout) (transfer full): The output collected from the helper
* @child_stderr: (inout) (transfer full): The stderr collected from the helper
* @argv: (transfer none): The helper and arguments to run
......@@ -1266,7 +1270,8 @@ out:
* @non_zero_waitstatus_issue: Which issue should be set if wait_status is non zero
*/
static SrtGraphicsIssues
_srt_run_helper (GStrv *my_environ,
_srt_run_helper (SrtSubprocessRunner *runner,
SrtHelperFlags *helper_flags,
gchar **output,
gchar **child_stderr,
const GPtrArray *argv,
......@@ -1276,6 +1281,9 @@ _srt_run_helper (GStrv *my_environ,
gboolean verbose,
SrtGraphicsIssues non_zero_wait_status_issue)
{
g_autoptr(SrtCompletedSubprocess) completed = NULL;
gboolean timed_out = FALSE;
// non_zero_wait_status_issue needs to be something other than NONE, otherwise
// we get no indication in caller that there was any error
g_return_val_if_fail (non_zero_wait_status_issue != SRT_GRAPHICS_ISSUES_NONE,
......@@ -1291,7 +1299,7 @@ _srt_run_helper (GStrv *my_environ,
if (verbose)
{
// Issues found, so run again with LIBGL_DEBUG=verbose set in environment
*my_environ = g_environ_setenv (*my_environ, "LIBGL_DEBUG", "verbose", TRUE);
*helper_flags |= SRT_HELPER_FLAGS_LIBGL_VERBOSE;
}
// Ignore what came on stderr previously, use this run's error message
......@@ -1303,35 +1311,33 @@ _srt_run_helper (GStrv *my_environ,
*exit_status = -1;
*terminating_signal = 0;
if (!g_spawn_sync (NULL, /* working directory */
(gchar **) argv->pdata,
*my_environ, /* envp */
G_SPAWN_SEARCH_PATH, /* flags */
_srt_child_setup_unblock_signals,
NULL, /* user data */
output, /* stdout */
child_stderr,
wait_status,
&error))
completed = _srt_subprocess_runner_run_sync (runner,
*helper_flags,
(const char * const *) argv->pdata,
SRT_SUBPROCESS_OUTPUT_CAPTURE,
SRT_SUBPROCESS_OUTPUT_CAPTURE,
&error);
if (completed == NULL)
{
g_debug ("An error occurred calling the helper: %s", error->message);
*child_stderr = g_strdup (error->message);
g_clear_error (&error);
issues |= non_zero_wait_status_issue;
return issues;
}
else if (*wait_status != 0)
*output = _srt_completed_subprocess_steal_stdout (completed);
*child_stderr = _srt_completed_subprocess_steal_stderr (completed);
if (!_srt_completed_subprocess_report (completed,
wait_status, exit_status,
terminating_signal, &timed_out))
{
g_debug ("... wait status %d", *wait_status);
issues |= non_zero_wait_status_issue;
if (_srt_process_timeout_wait_status (*wait_status, exit_status, terminating_signal))
{
issues |= SRT_GRAPHICS_ISSUES_TIMEOUT;
}
}
else
{
*exit_status = 0;
if (timed_out)
issues |= SRT_GRAPHICS_ISSUES_TIMEOUT;
}
return issues;
......@@ -1339,9 +1345,7 @@ _srt_run_helper (GStrv *my_environ,
/**
* _srt_check_graphics:
* @envp: (not nullable): Used instead of `environ`
* @helpers_path: An optional path to find wflinfo helpers, PATH is used if null.
* @test_flags: Flags used during automated testing
* @runner: Execution environment
* @multiarch_tuple: A multiarch tuple to check e.g. i386-linux-gnu
* @winsys: The window system to check.
* @renderer: The graphics renderer to check.
......@@ -1353,14 +1357,14 @@ _srt_run_helper (GStrv *my_environ,
* if no problems were found
*/
G_GNUC_INTERNAL SrtGraphicsIssues
_srt_check_graphics (gchar **envp,
const char *helpers_path,
SrtTestFlags test_flags,
_srt_check_graphics (SrtSubprocessRunner *runner,
const char *multiarch_tuple,
SrtWindowSystem window_system,
SrtRenderingInterface rendering_interface,
SrtGraphics **details_out)
{
SrtHelperFlags helper_flags = (SRT_HELPER_FLAGS_TIME_OUT
| SRT_HELPER_FLAGS_SEARCH_PATH);
gchar *output = NULL;
gchar *child_stderr = NULL;
gchar *child_stderr2 = NULL;
......@@ -1373,20 +1377,19 @@ _srt_check_graphics (gchar **envp,
GError *error = NULL;
SrtGraphicsIssues issues = SRT_GRAPHICS_ISSUES_NONE;
SrtGraphicsIssues non_zero_wait_status_issue = SRT_GRAPHICS_ISSUES_CANNOT_LOAD;
GStrv my_environ = NULL;
SrtGraphicsLibraryVendor library_vendor = SRT_GRAPHICS_LIBRARY_VENDOR_UNKNOWN;
g_auto(GStrv) json_output = NULL;
g_autoptr(GPtrArray) graphics_device = g_ptr_array_new_with_free_func (g_object_unref);
gsize i;
g_return_val_if_fail (SRT_IS_SUBPROCESS_RUNNER (runner), SRT_GRAPHICS_ISSUES_UNKNOWN);
g_return_val_if_fail (details_out == NULL || *details_out == NULL, SRT_GRAPHICS_ISSUES_UNKNOWN);
g_return_val_if_fail (((unsigned) window_system) < SRT_N_WINDOW_SYSTEMS, SRT_GRAPHICS_ISSUES_UNKNOWN);
g_return_val_if_fail (((unsigned) rendering_interface) < SRT_N_RENDERING_INTERFACES, SRT_GRAPHICS_ISSUES_UNKNOWN);
g_return_val_if_fail (_srt_check_not_setuid (), SRT_GRAPHICS_ISSUES_UNKNOWN);
g_return_val_if_fail (envp != NULL, SRT_GRAPHICS_ISSUES_UNKNOWN);
GPtrArray *argv = _argv_for_graphics_test (helpers_path,
test_flags,
GPtrArray *argv = _argv_for_graphics_test (runner,
helper_flags,
multiarch_tuple,
&window_system,
rendering_interface,
......@@ -1400,9 +1403,7 @@ _srt_check_graphics (gchar **envp,
goto out;
}
my_environ = _srt_filter_gameoverlayrenderer_from_envp (envp);
library_vendor = _srt_check_library_vendor (envp, multiarch_tuple,
library_vendor = _srt_check_library_vendor (runner, multiarch_tuple,
window_system,
rendering_interface);
......@@ -1424,7 +1425,8 @@ _srt_check_graphics (gchar **envp,
g_return_val_if_reached (SRT_GRAPHICS_ISSUES_UNKNOWN);
}
issues |= _srt_run_helper (&my_environ,
issues |= _srt_run_helper (runner,
&helper_flags,
&output,
&child_stderr,
argv,
......@@ -1442,7 +1444,8 @@ _srt_check_graphics (gchar **envp,
* output */
// Issues found, so run again with LIBGL_DEBUG=verbose set in environment
issues |= _srt_run_helper (&my_environ,
issues |= _srt_run_helper (runner,
&helper_flags,
&output,
&child_stderr,
argv,
......@@ -1469,7 +1472,8 @@ _srt_check_graphics (gchar **envp,
issues |= SRT_GRAPHICS_ISSUES_CANNOT_LOAD;
// Issues found, so run again with LIBGL_DEBUG=verbose set in environment
issues |= _srt_run_helper (&my_environ,
issues |= _srt_run_helper (runner,
&helper_flags,
&output,
&child_stderr,
argv,
......@@ -1487,7 +1491,8 @@ _srt_check_graphics (gchar **envp,
if (issues != SRT_GRAPHICS_ISSUES_NONE)
{
// Issues found, so run again with LIBGL_DEBUG=verbose set in environment
issues |= _srt_run_helper (&my_environ,
issues |= _srt_run_helper (runner,
&helper_flags,
&output,
&child_stderr,
argv,
......@@ -1505,8 +1510,8 @@ _srt_check_graphics (gchar **envp,
g_ptr_array_unref (argv);
g_clear_pointer (&output, g_free);
argv = _argv_for_check_gl (helpers_path,
test_flags,
argv = _argv_for_check_gl (runner,
helper_flags,
multiarch_tuple,
&error);
......@@ -1519,7 +1524,8 @@ _srt_check_graphics (gchar **envp,
}
/* Now run and report exit code/messages if failure */
issues |= _srt_run_helper (&my_environ,
issues |= _srt_run_helper (runner,
&helper_flags,
&output,
&child_stderr2,
argv,
......@@ -1532,7 +1538,8 @@ _srt_check_graphics (gchar **envp,
if (issues != SRT_GRAPHICS_ISSUES_NONE)
{
// Issues found, so run again with LIBGL_DEBUG=verbose set in environment
issues |= _srt_run_helper (&my_environ,
issues |= _srt_run_helper (runner,
&helper_flags,
&output,
&child_stderr2,
argv,
......@@ -1691,7 +1698,6 @@ out:
g_free (child_stderr);
g_free (child_stderr2);
g_clear_error (&error);
g_strfreev (my_environ);
return issues;
}
......
......@@ -27,13 +27,13 @@
#include <glib.h>
#include <glib-object.h>
G_GNUC_INTERNAL gchar *_srt_libdl_detect_platform (gchar **envp,
const char *helpers_path,
#include "steam-runtime-tools/subprocess-internal.h"
G_GNUC_INTERNAL gchar *_srt_libdl_detect_platform (SrtSubprocessRunner *runner,
const char *multiarch_tuple,
GError **error);
G_GNUC_INTERNAL gchar *_srt_libdl_detect_lib (gchar **envp,
const char *helpers_path,
G_GNUC_INTERNAL gchar *_srt_libdl_detect_lib (SrtSubprocessRunner *runner,
const char *multiarch_tuple,
GError **error);
......