<font size=2 face="sans-serif">I'll try to do that. Thanks.</font>
<br>
<br><font size=2 color=#000080 face="sans-serif">Amit Margalit</font>
<br><font size=2 color=#808000 face="sans-serif">IBM XIV </font><font size=2 face="sans-serif">-
<i>Storage Reinvented</i></font>
<br><font size=2 face="sans-serif">XIV-NAS Development Team</font>
<br><font size=2 face="sans-serif">Tel. 03</font><font size=2 face="Arial">-689-7774</font>
<br><font size=2 face="Arial">Fax. 03-689-7230</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:
</font><font size=1 face="sans-serif">David Goulet <dgoulet@efficios.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">Amit Margalit/Israel/IBM@IBMIL</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">lttng-dev@lists.lttng.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">06/12/2013 05:46 PM</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</font><font size=1 face="sans-serif">Re: [lttng-dev]
[RFC PATCH lttng-tools] Allow environment variable LTTNG_HOME to override
HOME - for lttng-tools</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>This looks good! It appears that there are multiple
callsites doing the same<br>
thing... We might want to just put it in src/common/utils.c with something
like<br>
utils_get_home_dir() and use it from there.<br>
<br>
Also, adding "LTTNG_HOME" in defaults.h as a defined value for
the env. variable<br>
name. Finally, updating the man page would be also great. :)<br>
<br>
Once you are ready to submit the patch, it would be good to use "git<br>
format-patch" or send me a pull request based on git HEAD master.<br>
<br>
Big thanks for this contribution!<br>
David<br>
<br>
Amit Margalit:<br>
> Hello all,<br>
> <br>
> Patch functionality - If LTTNG_HOME environment variable exists, it
is used<br>
> instead of HOME.<br>
> Reason for patch - We are trying to deploy LTTng on a system where
$HOME is on a<br>
> filesystem mounted read-only, but cannot afford to run lttng as a
different user<br>
> and cannot move the home directories of users to writeable locations.<br>
> Patch baseline: 2.2.0 rc2<br>
> <br>
> This patch handles only lttng-tools.<br>
> <br>
> I can provide the same patches against git, if asked.<br>
> <br>
> diff -ur lttng-tools-2.2.0-rc2-orig/src/bin/lttng/conf.c<br>
> lttng-tools-2.2.0-rc2/src/bin/lttng/conf.c<br>
> --- lttng-tools-2.2.0-rc2-orig/src/bin/lttng/conf.c
2013-05-06<br>
> 21:50:59.000000000 +0300<br>
> +++ lttng-tools-2.2.0-rc2/src/bin/lttng/conf.c
2013-06-11<br>
> 14:17:34.681673309 +0300<br>
> @@ -127,6 +127,11 @@<br>
> */<br>
> char *config_get_default_path(void)<br>
> {<br>
> + char *val = NULL;<br>
> + val = getenv("LTTNG_HOME");<br>
> + if (val != NULL) {<br>
> + return val;<br>
> + }<br>
> return getenv("HOME");<br>
> }<br>
> <br>
> diff -ur lttng-tools-2.2.0-rc2-orig/src/bin/lttng-relayd/utils.c<br>
> lttng-tools-2.2.0-rc2/src/bin/lttng-relayd/utils.c<br>
> --- lttng-tools-2.2.0-rc2-orig/src/bin/lttng-relayd/utils.c
2013-05-06<br>
> 21:50:59.000000000 +0300<br>
> +++ lttng-tools-2.2.0-rc2/src/bin/lttng-relayd/utils.c
2013-06-11<br>
> 14:15:52.553673444 +0300<br>
> @@ -34,7 +34,11 @@<br>
> */<br>
> static char *get_default_path(void)<br>
> {<br>
> - return getenv("HOME");<br>
> + char *val = NULL;<br>
> + val = getenv("LTTNG_HOME");<br>
> + if (val != NULL) {<br>
> + return val;<br>
> + }<br>
> }<br>
> <br>
> static char *create_output_path_auto(char *path_name)<br>
> diff -ur lttng-tools-2.2.0-rc2-orig/src/bin/lttng-sessiond/utils.c<br>
> lttng-tools-2.2.0-rc2/src/bin/lttng-sessiond/utils.c<br>
> --- lttng-tools-2.2.0-rc2-orig/src/bin/lttng-sessiond/utils.c
2013-01-07<br>
> 22:05:16.000000000 +0200<br>
> +++ lttng-tools-2.2.0-rc2/src/bin/lttng-sessiond/utils.c
2013-06-11<br>
> 14:16:16.697673412 +0300<br>
> @@ -53,5 +53,10 @@<br>
> */<br>
> const char *get_home_dir(void)<br>
> {<br>
> + const char *val = NULL;<br>
> + val = ((const char *) getenv("LTTNG_HOME"));<br>
> + if (val != NULL) {<br>
> + return val;<br>
> + }<br>
> return ((const char *) getenv("HOME"));<br>
> }<br>
> diff -ur lttng-tools-2.2.0-rc2-orig/src/lib/lttng-ctl/lttng-ctl.c<br>
> lttng-tools-2.2.0-rc2/src/lib/lttng-ctl/lttng-ctl.c<br>
> --- lttng-tools-2.2.0-rc2-orig/src/lib/lttng-ctl/lttng-ctl.c
2013-05-07<br>
> 22:42:07.000000000 +0300<br>
> +++ lttng-tools-2.2.0-rc2/src/lib/lttng-ctl/lttng-ctl.c
2013-06-11<br>
> 14:19:15.177673176 +0300<br>
> @@ -74,6 +74,22 @@<br>
> int lttng_opt_verbose;<br>
> <br>
> /*<br>
> + * Get the value of LTTNG_HOME if present, or HOME if not.<br>
> + * Caller must not free the returned pointer.<br>
> + * Used<br>
> + */<br>
> +static const char *get_lttng_home_dir(void)<br>
> +{<br>
> + const char *val = NULL;<br>
> + val = ((const char *) getenv("LTTNG_HOME"));<br>
> + if (val != NULL) {<br>
> + return val;<br>
> + }<br>
> + return ((const char *) getenv("HOME"));<br>
> +}<br>
> +<br>
> +<br>
> +/*<br>
> * Compare two URL destination.<br>
> *<br>
> * Return 0 is equal else is not equal.<br>
> @@ -485,7 +501,7 @@<br>
> * With
GNU C >= 2.1, snprintf returns the required size<br>
> (excluding closing null)<br>
> */<br>
> ret
= snprintf(sessiond_sock_path, sizeof(sessiond_sock_path),<br>
> -
DEFAULT_HOME_CLIENT_UNIX_SOCK,
getenv("HOME"));<br>
> +
DEFAULT_HOME_CLIENT_UNIX_SOCK,<br>
> get_lttng_home_dir());<br>
> if ((ret
< 0) || (ret >= sizeof(sessiond_sock_path))) {<br>
>
goto error;<br>
> }<br>
> @@ -1543,7 +1559,7 @@<br>
> * With
GNU C < 2.1, snprintf returns -1 if the target buffer<br>
> is too small;<br>
> * With
GNU C >= 2.1, snprintf returns the required size<br>
> (excluding closing null)<br>
> */<br>
> - home = getenv("HOME");<br>
> + home = get_lttng_home_dir();<br>
> if (home
== NULL) {<br>
>
/* Fallback in /tmp .. */<br>
>
home = "/tmp";<br>
> <br>
> Thanks,<br>
> <br>
> Amit Margalit<br>
> IBM XIV - /Storage Reinvented/<br>
> XIV-NAS Development Team<br>
> Tel. 03-689-7774<br>
> Fax. 03-689-7230<br>
> <br>
> <br>
> This body part will be downloaded on demand.<br>
<br>
</font></tt>
<br>