lttng_crash_SOURCES = lttng-crash.cpp
lttng_crash_LDADD = $(top_builddir)/src/common/libcommon-gpl.la \
- $(top_builddir)/src/common/libconfig.la
+ $(top_builddir)/src/common/libconfig.la \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
DBG("Notifying applications of session daemon state: %d", active);
/* See shm.c for this call implying mmap, shm and futex calls */
- wait_shm_mmap = shm_ust_get_mmap(the_config.wait_shm_path.value, is_root);
+ wait_shm_mmap = shm_ust_get_mmap(
+ the_config.wait_shm.path.value, the_config.wait_shm.is_regular_path, is_root);
if (wait_shm_mmap == nullptr) {
goto error;
}
.apps_unix_sock_path = { nullptr, false },
.client_unix_sock_path = { nullptr, false },
- .wait_shm_path = { nullptr, false },
+ .wait_shm = { false, {nullptr, false}},
.health_unix_sock_path = { nullptr, false },
.lttng_ust_clock_plugin = { nullptr, false },
.pid_file_path = { nullptr, false },
return ret;
}
+static int config_set_ust_ctl_paths(struct sessiond_config *config,
+ const char *lttng_ust_ctl_path_override)
+{
+ char *str;
+ int ret;
+
+ ret = asprintf(&str, "%s/%s", lttng_ust_ctl_path_override, LTTNG_UST_SOCK_FILENAME);
+ if (ret < 0) {
+ ERR("Failed to set default ust_ctl unix socket path");
+ return ret;
+ }
+
+ config_string_set(&config->apps_unix_sock_path, str);
+ str = nullptr;
+ ret = asprintf(&str, "%s/%s", lttng_ust_ctl_path_override, LTTNG_UST_WAIT_FILENAME);
+ if (ret < 0) {
+ ERR("Failed to set default ust_ctl wait shm path");
+ return ret;
+ }
+
+ config->wait_shm.is_regular_path = true;
+ config_string_set(&config->wait_shm.path, str);
+ str = nullptr;
+
+ ret = asprintf(
+ &str, "%s/%s", lttng_ust_ctl_path_override, DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE);
+ if (ret < 0) {
+ ERR("Failed to set ust_ctl agent port file path");
+ return ret;
+ }
+
+ config_string_set(&config->agent_port_file_path, str);
+ str = nullptr;
+ return 0;
+}
+
static int config_set_paths_root(struct sessiond_config *config)
{
int ret = 0;
}
config_string_set_static(&config->apps_unix_sock_path, DEFAULT_GLOBAL_APPS_UNIX_SOCK);
+ config_string_set_static(&config->wait_shm.path, DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH);
config_string_set_static(&config->client_unix_sock_path, DEFAULT_GLOBAL_CLIENT_UNIX_SOCK);
- config_string_set_static(&config->wait_shm_path, DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH);
config_string_set_static(&config->health_unix_sock_path, DEFAULT_GLOBAL_HEALTH_UNIX_SOCK);
end:
return ret;
ERR("Failed to set default home apps unix socket path");
goto end;
}
+
config_string_set(&config->apps_unix_sock_path, str);
str = nullptr;
-
- ret = asprintf(&str, DEFAULT_HOME_CLIENT_UNIX_SOCK, home_path);
+ ret = asprintf(&str, DEFAULT_HOME_APPS_WAIT_SHM_PATH, getuid());
if (ret < 0) {
- ERR("Failed to set default home client unix socket path");
+ ERR("Failed to set default home apps wait shm path");
goto end;
}
- config_string_set(&config->client_unix_sock_path, str);
+
+ config_string_set(&config->wait_shm.path, str);
str = nullptr;
- ret = asprintf(&str, DEFAULT_HOME_APPS_WAIT_SHM_PATH, getuid());
+ ret = asprintf(&str, DEFAULT_HOME_CLIENT_UNIX_SOCK, home_path);
if (ret < 0) {
- ERR("Failed to set default home apps wait shm path");
+ ERR("Failed to set default home client unix socket path");
goto end;
}
- config_string_set(&config->wait_shm_path, str);
+ config_string_set(&config->client_unix_sock_path, str);
str = nullptr;
ret = asprintf(&str, DEFAULT_HOME_HEALTH_UNIX_SOCK, home_path);
int sessiond_config_init(struct sessiond_config *config)
{
+ const char *lttng_ust_ctl_path_override = utils_get_lttng_ust_ctl_path_override_dir();
int ret;
const bool is_root = (getuid() == 0);
char *str;
goto error;
}
+ if (lttng_ust_ctl_path_override) {
+ /*
+ * Since a ustctl path override has been specified, re-evaluate the following paths
+ * to take it into account:
+ * - apps_unix_sock_path
+ * - wait_shm_path
+ * - agent_port_file_path
+ */
+ ret = config_set_ust_ctl_paths(config, lttng_ust_ctl_path_override);
+ if (ret < 0) {
+ goto error;
+ }
+ } else {
+ ret = asprintf(
+ &str, "%s/%s", config->rundir.value, DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE);
+ if (ret < 0) {
+ ERR("Failed to set agent port file path");
+ goto error;
+ }
+
+ config_string_set(&config->agent_port_file_path, str);
+ str = nullptr;
+ }
+
/* 32 bits consumerd path setup */
ret = asprintf(&str, DEFAULT_USTCONSUMERD32_PATH, config->rundir.value);
if (ret < 0) {
config_string_set(&config->lock_file_path, str);
str = nullptr;
- ret = asprintf(&str, "%s/%s", config->rundir.value, DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE);
- if (ret < 0) {
- ERR("Failed to set agent port file path");
- goto error;
- }
- config_string_set(&config->agent_port_file_path, str);
- str = nullptr;
-
/*
* Allow INSTALL_BIN_PATH to be used as a target path for the
* native architecture size consumer if CONFIG_CONSUMER*_PATH
config_string_fini(&config->rundir);
config_string_fini(&config->apps_unix_sock_path);
config_string_fini(&config->client_unix_sock_path);
- config_string_fini(&config->wait_shm_path);
+ config_string_fini(&config->wait_shm.path);
config_string_fini(&config->health_unix_sock_path);
config_string_fini(&config->lttng_ust_clock_plugin);
config_string_fini(&config->pid_file_path);
{
RESOLVE_CHECK(&config->apps_unix_sock_path);
RESOLVE_CHECK(&config->client_unix_sock_path);
- RESOLVE_CHECK(&config->wait_shm_path);
+ RESOLVE_CHECK(&config->wait_shm.path);
RESOLVE_CHECK(&config->health_unix_sock_path);
RESOLVE_CHECK(&config->lttng_ust_clock_plugin);
RESOLVE_CHECK(&config->pid_file_path);
config->apps_unix_sock_path.value ?: "Unknown");
DBG_NO_LOC("\tclient socket path: %s",
config->client_unix_sock_path.value ?: "Unknown");
- DBG_NO_LOC("\twait shm path: %s", config->wait_shm_path.value ?: "Unknown");
+ DBG_NO_LOC("\twait shm path: %s", config->wait_shm.path.value ?: "Unknown");
DBG_NO_LOC("\thealth socket path: %s",
config->health_unix_sock_path.value ?: "Unknown");
DBG_NO_LOC("\tLTTNG_UST_CLOCK_PLUGIN: %s",
struct config_string apps_unix_sock_path;
/* Global client Unix socket path */
struct config_string client_unix_sock_path;
- /* Global wait shm path for UST */
- struct config_string wait_shm_path;
+ struct {
+ /*
+ * Whether wait_shm is a regular file path or an shm_open parameter (false).
+ * The default configuration values assume the path refers to a POSIX shared memory
+ * object by name.
+ *
+ * When an ustctl override path is specified, the path is assumed to point to a
+ * regular file path.
+ */
+ bool is_regular_path;
+ /* Global wait shm path for UST */
+ struct config_string path;
+
+ } wait_shm;
/* Global health check unix path */
struct config_string health_unix_sock_path;
/*
noinst_PROGRAMS = filter-grammar-test
filter_grammar_test_SOURCES = filter-grammar-test.cpp
-filter_grammar_test_LDADD = libcommon-gpl.la
+filter_grammar_test_LDADD = libcommon-gpl.la \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
EXTRA_DIST = \
mi-lttng-4.1.xsd \
/* Default lttng run directory */
#define DEFAULT_LTTNG_HOME_ENV_VAR "LTTNG_HOME"
#define DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR "HOME"
+#define DEFAULT_LTTNG_UST_CTL_PATH_ENV_VAR "LTTNG_UST_CTL_PATH"
#define DEFAULT_LTTNG_RUNDIR CONFIG_LTTNG_SYSTEM_RUNDIR
#define DEFAULT_LTTNG_HOME_RUNDIR "%s/.lttng"
#define DEFAULT_LTTNG_SESSIOND_PIDFILE "lttng-sessiond.pid"
#include <unistd.h>
#include <urcu.h>
+static int wait_shm_open(const char *wait_shm_path, int flags, mode_t mode, bool wait_shm_is_file)
+{
+ if (wait_shm_is_file) {
+ return open(wait_shm_path, flags, mode);
+ } else {
+ return shm_open(wait_shm_path, flags, mode);
+ }
+}
+
/*
* We deal with the shm_open vs ftruncate race (happening when the sessiond owns
* the shm and does not let everybody modify it, to ensure safety against
* seconds. For global shm, everybody has rw access to it until the sessiond
* starts.
*/
-static int get_wait_shm(char *shm_path, size_t mmap_size, int global)
+static int get_wait_shm(char *shm_path, bool wait_shm_is_file, size_t mmap_size, int global)
{
int wait_shm_fd, ret;
mode_t mode, old_mode;
* use a now-unlinked shm, while the next application would create
* a new named shm.
*/
- wait_shm_fd = shm_open(shm_path, O_RDWR | O_CREAT, mode);
+ wait_shm_fd = wait_shm_open(shm_path, O_RDWR | O_CREAT, mode, wait_shm_is_file);
if (wait_shm_fd < 0) {
if (errno == EACCES) {
/* Work around sysctl fs.protected_regular. */
"Attempting to open the shm without "
"creating it.",
shm_path);
- wait_shm_fd = shm_open(shm_path, O_RDWR, mode);
+ wait_shm_fd = wait_shm_open(shm_path, O_RDWR, mode, wait_shm_is_file);
}
if (wait_shm_fd < 0) {
PERROR("Failed to open \"wait\" shared memory object: path = '%s'",
* This returned value is used by futex_wait_update() in futex.c to WAKE all
* waiters which are UST application waiting for a session daemon.
*/
-char *shm_ust_get_mmap(char *shm_path, int global)
+char *shm_ust_get_mmap(char *shm_path, bool wait_shm_is_file, int global)
{
size_t mmap_size;
int wait_shm_fd, ret;
}
mmap_size = sys_page_size;
- wait_shm_fd = get_wait_shm(shm_path, mmap_size, global);
+ wait_shm_fd = get_wait_shm(shm_path, wait_shm_is_file, mmap_size, global);
if (wait_shm_fd < 0) {
goto error;
}
#ifndef _LTT_SHM_H
#define _LTT_SHM_H
-char *shm_ust_get_mmap(char *shm_path, int global);
+char *shm_ust_get_mmap(char *shm_path, bool wait_shm_is_file, int global);
int shm_create_anonymous(const char *owner_name);
#include <common/compat/getenv.hpp>
#include <common/compat/string.hpp>
#include <common/dynamic-buffer.hpp>
+#include <common/format.hpp>
#include <common/readwrite.hpp>
#include <common/runas.hpp>
#include <common/string-utils/format.hpp>
return val;
}
+/*
+ * Obtain the value of LTTNG_UST_CTL_PATH environment variable, if
+ * exists. Otherwise return NULL.
+ */
+const char *utils_get_lttng_ust_ctl_path_override_dir()
+{
+ const auto *val = lttng_secure_getenv(DEFAULT_LTTNG_UST_CTL_PATH_ENV_VAR);
+ if (val == nullptr) {
+ return nullptr;
+ }
+
+ DBG_FMT("LTTng ust-ctl override path specified: {}=`{}`",
+ DEFAULT_LTTNG_UST_CTL_PATH_ENV_VAR,
+ val);
+ return val;
+}
+
/*
* Get user's home directory. Dynamically allocated, must be freed
* by the caller.
int utils_get_count_order_u64(uint64_t x);
const char *utils_get_home_dir();
char *utils_get_user_home_dir(uid_t uid);
+const char *utils_get_lttng_ust_ctl_path_override_dir();
size_t utils_get_current_time_str(const char *format, char *dst, size_t len)
ATTR_FORMAT_STRFTIME(1);
# URI unit tests
test_uri_SOURCES = test_uri.cpp
-test_uri_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS)
+test_uri_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
RELAYD_OBJS = $(top_builddir)/src/bin/lttng-relayd/backward-compatibility-group-by.$(OBJEXT)
# parse_size_suffix unit test
test_utils_parse_size_suffix_SOURCES = test_utils_parse_size_suffix.cpp
-test_utils_parse_size_suffix_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS)
+test_utils_parse_size_suffix_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# parse_time_suffix unit test
test_utils_parse_time_suffix_SOURCES = test_utils_parse_time_suffix.cpp
-test_utils_parse_time_suffix_LDADD = $(LIBTAP) $(LIBCOMMON_GPL)
+test_utils_parse_time_suffix_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# compat_poll unit test
test_utils_compat_poll_SOURCES = test_utils_compat_poll.cpp
test_utils_compat_poll_LDADD = $(LIBTAP) $(DL_LIBS) \
- $(top_builddir)/src/common/libcompat.la $(LIBCOMMON_GPL)
+ $(top_builddir)/src/common/libcompat.la $(LIBCOMMON_GPL) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# compat_pthread unit test
test_utils_compat_pthread_SOURCES = test_utils_compat_pthread.cpp
# directory handle unit test
test_directory_handle_SOURCES = test_directory_handle.cpp
-test_directory_handle_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS)
+test_directory_handle_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# string utilities unit test
test_string_utils_SOURCES = test_string_utils.cpp
-test_string_utils_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBSTRINGUTILS) $(DL_LIBS)
+test_string_utils_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBSTRINGUTILS) $(DL_LIBS) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# Notification api
test_notification_SOURCES = test_notification.cpp
# Event rule api
test_event_rule_SOURCES = test_event_rule.cpp
test_event_rule_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS) \
- $(top_builddir)/src/bin/lttng/lttng-loglevel.$(OBJEXT)
+ $(top_builddir)/src/bin/lttng/lttng-loglevel.$(OBJEXT) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# Condition api
test_condition_SOURCES = test_condition.cpp
-test_condition_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS)
+test_condition_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# relayd backward compat for groou-by-session utilities
test_relayd_backward_compat_group_by_session_SOURCES = test_relayd_backward_compat_group_by_session.cpp
# rate policy object unit test
test_rate_policy_SOURCES = test_rate_policy.cpp
test_rate_policy_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS) \
- $(top_builddir)/src/bin/lttng/lttng-loglevel.$(OBJEXT)
+ $(top_builddir)/src/bin/lttng/lttng-loglevel.$(OBJEXT) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# fd tracker unit test
test_fd_tracker_SOURCES = test_fd_tracker.cpp
-test_fd_tracker_LDADD = $(LIBTAP) $(LIBFDTRACKER) $(DL_LIBS) $(URCU_LIBS) $(LIBCOMMON_GPL)
+test_fd_tracker_LDADD = $(LIBTAP) $(LIBFDTRACKER) $(DL_LIBS) $(URCU_LIBS) $(LIBCOMMON_GPL) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# uuid unit test
test_uuid_SOURCES = test_uuid.cpp
# payload unit test
test_payload_SOURCES = test_payload.cpp
-test_payload_LDADD = $(LIBTAP) $(LIBSESSIOND_COMM) $(LIBCOMMON_GPL)
+test_payload_LDADD = $(LIBTAP) $(LIBSESSIOND_COMM) $(LIBCOMMON_GPL) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# unix socket test
test_unix_socket_SOURCES = test_unix_socket.cpp
-test_unix_socket_LDADD = $(LIBTAP) $(LIBSESSIOND_COMM) $(LIBCOMMON_GPL)
+test_unix_socket_LDADD = $(LIBTAP) $(LIBSESSIOND_COMM) $(LIBCOMMON_GPL) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# Kernel probe location api test
test_kernel_probe_SOURCES = test_kernel_probe.cpp
-test_kernel_probe_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS)
-#
+test_kernel_probe_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
+
# Event expression to bytecode test
test_event_expr_to_bytecode_SOURCES = test_event_expr_to_bytecode.cpp
-test_event_expr_to_bytecode_LDADD = $(LIBTAP) $(LIBLTTNG_CTL) $(LIBCOMMON_GPL)
+test_event_expr_to_bytecode_LDADD = $(LIBTAP) $(LIBLTTNG_CTL) $(LIBCOMMON_GPL) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# Log level rule api
test_log_level_rule_SOURCES = test_log_level_rule.cpp
-test_log_level_rule_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS)
+test_log_level_rule_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
# Action api
test_action_SOURCES = test_action.cpp
test_action_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS) \
- $(top_builddir)/src/vendor/fmt/libfmt.la
+ $(top_builddir)/src/vendor/fmt/libfmt.la
EXTRA_DIST = test_ini_config sample.ini
ini_config_SOURCES = ini_config.cpp
-ini_config_LDADD = $(LIBTAP) $(LIBCOMMON_GPL)
+ini_config_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) \
+ $(top_builddir)/src/vendor/fmt/libfmt.la
all-local:
@if [ x"$(srcdir)" != x"$(builddir)" ]; then \