sessiond/lttng-ctl: Introduce LTTNG_RUNDIR
Observed issue
==============
Starting multiple instances of lttng-sessiond as the root user isn't
possible, even with setting different values for the `LTTNG_HOME`
environment variable.
Cause
=====
When starting `lttng-sessiond` the `apps_unix_sock_path`,
`client_unix_sock_path`, and `health_unix_sock_path` are set to
configure time static defines under `CONFIG_LTTNG_SYSTEM_RUNDIR`,
e.g. `/var/lib/lttng`.
Solution
========
A new environment variable `LTTNG_RUNDIR` is introduced to control the
base directory used by applications to find communication sockets.
The default behaviour is to emulate the existing divide: if
`LTTNG_RUNDIR` is not set the root `lttng-sessiond` will continue to
use `CONFIG_LTTNG_SYSTEM_RUNDIR`, and a non-root user `lttng-sessiond`
will use `LTTNG_HOME/.lttng`.
When `LTTNG_RUNDIR` is set, it takes priority over `LTTNG_HOME` for
determining the base directory. The output directory for traces is
not affected by `LTTNG_RUNDIR`, it continues to respect `LTTNG_HOME`.
Example with starting multiple root `lttng-sessiond`s:
```
DIR_A=$(mktemp -d)
DIR_B=$(mktemp -d)
LTTNG_RUNDIR="${DIR_A}" lttng-sessiond -b
LTTNG_RUNDIR="${DIR_B}" lttng-sessiond -b
LTTNG_RUNDIR="${DIR_A}" lttng list
LTTNG_RUNDIR="${DIR_B}" lttng list
```
In the example above, as `LTTNG_HOME` is not set, the default output
directory for traces by both over the `lttng-sessiond` instances will
be `$HOME/lttng-traces`.
The following will also work:
```
DIR_A=$(mktemp -d)
LTTNG_RUNDIR="${DIR_A}" lttng create
LTTNG_RUNDIR="${DIR_A}" lttng enable-event -u --all
LTTNG_RUNDIR="${DIR_A}" lttng start
LTTNG_UST_APP_PATH="${DIR_A}" test-application
```
The `LTTNG_UST_CTL_PATH` can be set to a location other than the
rundir as follows;
```
DIR_A=$(mktemp -d)
DIR_B=$(mktemp -d)
LTTNG_UST_CTL_PATH="${DIR_B}" LTTNG_RUNDIR="${DIR_A}" lttng create
LTTNG_RUNDIR="${DIR_A}" lttng enable-event -u -all
LTTNG_RUNDIR="${DIR_A}" lttng start
LTTNG_UST_APP_PATH="${DIR_B}" test-application
LTTNG_UST_APP_PATH="${DIR_A}" test-application
```
Known drawbacks
===============
None.
Change-Id: I371c2c72644277b7dcafaf970ee7b75d9bfbaedc
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
22 files changed:
This page took 0.030029 seconds and 4 git commands to generate.