From: Carl Worth Date: Mon, 7 Oct 2013 22:47:05 +0000 (-0700) Subject: Allow user to specify FIPS_LIBGL as path to "real" libGL.so library X-Git-Url: https://git.cworth.org/git?p=fips;a=commitdiff_plain;h=5ecd74881b1c5757cdb577c5942ead891ff1d90c Allow user to specify FIPS_LIBGL as path to "real" libGL.so library This allows the user full control to cut through any heuristics fips might use for trying to locate libGL.so on its own. --- diff --git a/glwrap.c b/glwrap.c index 0ae295a..3c751cc 100644 --- a/glwrap.c +++ b/glwrap.c @@ -71,14 +71,31 @@ glwrap_lookup (char *name) * our dlopen wrapper, which will then call * glwrap_set_gl_handle to give us the handle to use here. * - * If the application hasn't called dlopen on a "libGL" * library, then presumably the application is linked directly * to an OpenGL implementation. In this case, we can use * RTLD_NEXT to find the symbol. + * + * But just in case, we also let the user override that by + * specifying the FIPS_LIBGL environment variable to the path + * of the real libGL.so library that fips should dlopen here. */ - if (gl_handle == NULL) - gl_handle = RTLD_NEXT; + if (gl_handle == NULL) { + const char *path; + + path = getenv ("FIPS_LIBGL"); + if (path) { + gl_handle = dlopen (path, RTLD_LAZY); + + if (gl_handle == NULL) { + fprintf (stderr, "Failed to dlopen FIPS_LIBGL: " + "%s\n", path); + exit (1); + } + } else { + gl_handle = RTLD_NEXT; + } + } ret = dlwrap_real_dlsym (gl_handle, name);