Skip to content
Snippets Groups Projects

pressure-vessel: Remap preloadable modules better

Merged Simon McVittie requested to merge wip/t29490 into master
5 files
+ 461
26
Compare changes
  • Side-by-side
  • Inline
Files
5
  • This deals with several situations that were previously not well-handled.
    
    For ${LIB} and ${PLATFORM}, we try to load the library to find out where
    it is, and then ask pv-adverb to set up ${PLATFORM}-based symlinks
    in the container. This addresses the part of steam-runtime#435 reported
    by Github user `lukashoracek`.
    
    For ${ORIGIN} and other unsupported dynamic string tokens, we export
    the deepest directory "above" the dynamic string token, and leave the
    string in the environment variable unchanged.
    
    For libraries that are loaded by a bare basename, the right thing to do
    is not completely obvious: if the user is loading something designed to
    be a LD_PRELOAD module, like libMangoHud.so or libfakechroot.so, then
    we want to copy it from the host into the container and use it like that.
    However, if the user specifies something like LD_PRELOAD=libcurl.so.4,
    it seems likely that they meant the library from the container runtime,
    so we use the new if-not-in-container option to make that happen.
    
    Dependencies of a library specified by a plain basename are not currently
    loaded, so that LD_PRELOAD=libMangoHud.so and
    LD_PRELOAD=/usr/$LIB/libMangoHud.so will have consistent behaviour.
    
    Resolves: https://github.com/ValveSoftware/steam-runtime/issues/435
    
    
    Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
+ 28
0
@@ -292,6 +292,7 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (RuntimeArchitecture,
static gboolean pv_runtime_use_provider_graphics_stack (PvRuntime *self,
FlatpakBwrap *bwrap,
PvEnviron *container_env,
const char * const *preload_modules,
GError **error);
static void pv_runtime_set_search_paths (PvRuntime *self,
PvEnviron *container_env);
@@ -3842,6 +3843,29 @@ collect_graphics_libraries_patterns (GPtrArray *patterns)
soname_globs[i]));
}
/*
* @patterns: (inout) (not nullable):
*/
static void
collect_preload_patterns (GPtrArray *patterns,
const char * const *preload_modules)
{
gsize i;
if (preload_modules == NULL)
return;
for (i = 0; preload_modules[i] != NULL; i++)
g_ptr_array_add (patterns,
g_strdup_printf (("if-exists"
":if-not-in-container"
":if-same-abi"
":no-dependencies"
":soname"
":%s"),
preload_modules[i]));
}
static gboolean
pv_runtime_collect_libc_family (PvRuntime *self,
RuntimeArchitecture *arch,
@@ -4664,6 +4688,7 @@ static gboolean
pv_runtime_use_provider_graphics_stack (PvRuntime *self,
FlatpakBwrap *bwrap,
PvEnviron *container_env,
const char * const *preload_modules,
GError **error)
{
gsize i, j;
@@ -4919,6 +4944,7 @@ pv_runtime_use_provider_graphics_stack (PvRuntime *self,
g_debug ("Collecting graphics drivers from provider system...");
collect_graphics_libraries_patterns (patterns);
collect_preload_patterns (patterns, preload_modules);
if (!collect_egl_drivers (self, arch, egl_icd_details, patterns,
error))
@@ -5252,6 +5278,7 @@ pv_runtime_bind (PvRuntime *self,
FlatpakExports *exports,
FlatpakBwrap *bwrap,
PvEnviron *container_env,
const char * const *preload_modules,
GError **error)
{
g_return_val_if_fail (PV_IS_RUNTIME (self), FALSE);
@@ -5280,6 +5307,7 @@ pv_runtime_bind (PvRuntime *self,
{
if (!pv_runtime_use_provider_graphics_stack (self, bwrap,
container_env,
preload_modules,
error))
return FALSE;
}
Loading