More special casing of LD_LIBRARY_PATH

* Convert LD_LIBRARY_PATH in [Vars] to _LD_LIBRARY_PATH in the env
  so that its properly propagated.

* Always unset the regular LD_LIBRARY_PATH in the app if
  _LD_LIBRARY_PATH is unset.

* Always unset LD_LIBRARY_PATH as passed to the helper to
  avoid it getting some weird effect.
This commit is contained in:
Alexander Larsson
2015-05-12 12:06:07 +02:00
parent 6c99fcb832
commit 2e4d410bc6
2 changed files with 9 additions and 0 deletions

View File

@@ -1867,6 +1867,8 @@ main (int argc,
xsetenv ("LD_LIBRARY_PATH", getenv("_LD_LIBRARY_PATH"), 1);
xunsetenv ("_LD_LIBRARY_PATH");
}
else
xunsetenv ("LD_LIBRARY_PATH");
xdg_runtime_dir = strdup_printf ("/run/user/%d", getuid());
xsetenv ("XDG_RUNTIME_DIR", xdg_runtime_dir, 1);

View File

@@ -307,6 +307,7 @@ xdg_app_run_add_environment_args (GPtrArray *argv_array,
static const struct {const char *env; const char *val;} default_exports[] = {
{"PATH","/self/bin:/usr/bin"},
{"LD_LIBRARY_PATH", ""},
{"_LD_LIBRARY_PATH", "/self/lib"},
{"XDG_CONFIG_DIRS","/self/etc/xdg:/etc/xdg"},
{"XDG_DATA_DIRS","/self/share:/usr/share"},
@@ -434,6 +435,12 @@ xdg_app_run_apply_env_vars (char **envp, GKeyFile *metakey)
{
const char *key = keys[i];
g_autofree char *value = g_key_file_get_string (metakey, "Vars", key, NULL);
/* We special case LD_LIBRARY_PATH to avoid passing it top
the helper */
if (strcmp (key, "LD_LIBRARY_PATH") == 0)
key = "_LD_LIBRARY_PATH";
if (value)
envp = g_environ_setenv (envp, key, value, TRUE);
else