[glick2] Export LD_LIBRARY_PATH in the bundle



commit eb91c4dac2929ae70d2e6b6dc4dfe1246169147d
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Oct 13 16:30:50 2011 +0200

    Export LD_LIBRARY_PATH in the bundle

 helper.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/helper.c b/helper.c
index 9b6d83b..de085e3 100644
--- a/helper.c
+++ b/helper.c
@@ -9,6 +9,55 @@
 #include <stdlib.h>
 #include <errno.h>
 
+char *
+strconcat (const char *s1,
+	   const char *s2,
+	   const char *s3)
+{
+  size_t len = 0;
+  char *res;
+
+  if (s1)
+    len += strlen (s1);
+  if (s2)
+    len += strlen (s2);
+  if (s3)
+    len += strlen (s3);
+
+  res = malloc (len + 1);
+  if (res == NULL)
+    return NULL;
+
+  *res = 0;
+  if (s1)
+    strcat (res, s1);
+  if (s2)
+    strcat (res, s2);
+  if (s3)
+    strcat (res, s3);
+
+  return res;
+}
+
+static void
+update_env_var_list (const char *var, const char *item)
+{
+  const char *env;
+  char *value;
+
+  env = getenv (var);
+  if (env == NULL || *env == 0)
+    {
+      setenv (var, item, 1);
+    }
+  else
+    {
+      value = strconcat (item, ":", env);
+      setenv (var, value, 1);
+      free (value);
+    }
+}
+
 int
 main (int argc,
       char **argv)
@@ -135,6 +184,8 @@ main (int argc,
     child_argv[j++] = argv[i];
   child_argv[j++] = NULL;
 
+  update_env_var_list ("LD_LIBRARY_PATH", BUNDLE_PREFIX "/lib");
+
   return execv (executable, child_argv);
 
  oom:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]