Using LTTNG_HOME environment variable if exists, with fallback to HOME
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 6c8ad411a3ab7de446f8a8bdda20c4b552dad6b6..1b9f3a8ab99a95d54e6ffcd6b8465092dfe4da17 100644 (file)
@@ -32,6 +32,7 @@
 #include <common/defaults.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/uri.h>
+#include <common/utils.h>
 #include <lttng/lttng.h>
 
 #include "filter/filter-ast.h"
@@ -485,7 +486,7 @@ static int set_session_daemon_path(void)
                 * With GNU C >= 2.1, snprintf returns the required size (excluding closing null)
                 */
                ret = snprintf(sessiond_sock_path, sizeof(sessiond_sock_path),
-                               DEFAULT_HOME_CLIENT_UNIX_SOCK, getenv("HOME"));
+                               DEFAULT_HOME_CLIENT_UNIX_SOCK, utils_get_home_dir());
                if ((ret < 0) || (ret >= sizeof(sessiond_sock_path))) {
                        goto error;
                }
@@ -1543,7 +1544,7 @@ static int set_health_socket_path(void)
                 * With GNU C <  2.1, snprintf returns -1 if the target buffer is too small;
                 * With GNU C >= 2.1, snprintf returns the required size (excluding closing null)
                 */
-               home = getenv("HOME");
+               home = utils_get_home_dir();
                if (home == NULL) {
                        /* Fallback in /tmp .. */
                        home = "/tmp";
This page took 0.022917 seconds and 4 git commands to generate.