[lttng-dev] [RFC PATCH lttng-ust] Allow environment variable LTTNG_HOME to override HOME

Amit Margalit AMITM at il.ibm.com
Tue Jun 11 08:04:05 EDT 2013


Hello all,

I tried to find some guide for contribution, but http://lttng.org/contrib 
insists that page is not found, so please forgive me (and teach) where I 
do things in a non-standard way.

Patch functionality - If LTTNG_HOME environment variable exists, it is 
used instead of HOME.
Reason for patch - We are trying to deploy LTTng on a system where $HOME 
is on a filesystem mounted read-only, but cannot afford to run lttng as a 
different user and cannot move the home directories of users to writeable 
locations.
Patch baseline: 2.2.0 rc2 

This patch handles only UST. The next email will be a patch against 
lttng-tools.

diff -ur lttng-ust-2.2.0-rc2-orig/liblttng-ust/lttng-ust-comm.c 
lttng-ust-2.2.0-rc2/liblttng-ust/lttng-ust-comm.c
--- lttng-ust-2.2.0-rc2-orig/liblttng-ust/lttng-ust-comm.c      2013-05-08 
22:58:40.000000000 +0300
+++ lttng-ust-2.2.0-rc2/liblttng-ust/lttng-ust-comm.c   2013-06-11 
14:12:55.921673678 +0300
@@ -189,6 +189,20 @@
 extern void lttng_ring_buffer_metadata_client_exit(void);
 
 /*
+ * Returns the HOME directory path. Caller MUST NOT free(3) the return 
pointer.
+ */
+static
+char *get_lttng_home_dir(void)
+{
+       char *val = NULL;
+       val = getenv("LTTNG_HOME");
+       if (val != NULL) {
+               return val;
+       }
+       return getenv("HOME");
+}
+
+/*
  * Force a read (imply TLS fixup for dlopen) of TLS variables.
  */
 static
@@ -230,7 +244,7 @@
                assert(local_apps.allowed == 0);
                return 0;
        }
-       home_dir = (const char *) getenv("HOME");
+       home_dir = (const char *) get_lttng_home_dir();
        if (!home_dir) {
                WARN("HOME environment variable not set. Disabling 
LTTng-UST per-user tracing.");
                assert(local_apps.allowed == 0);

Thanks,

Amit Margalit
IBM XIV - Storage Reinvented
XIV-NAS Development Team
Tel. 03-689-7774
Fax. 03-689-7230
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20130611/290063c5/attachment.html>


More information about the lttng-dev mailing list