From: Jérémie Galarneau Date: Mon, 3 May 2021 16:50:25 +0000 (-0400) Subject: Fix: lttng-ctl: erroneous check if user is part of the tracing group X-Git-Tag: v2.12.4~5 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=408c55ab235ce49e532ea6825e80e8ee3aa353b4;p=lttng-tools.git Fix: lttng-ctl: erroneous check if user is part of the tracing group in_tgroup is set to `-1` whenever the current user is not part of the tracing group _or_ if an error occurred while looking up if the user is part of the tracing group. In other words, the value '0' is unused. in_tgroup must be explicitly checked against '1' and can't be assumed to behave as a boolean value. This is _not_ a security issue: if the user is not part of the tracing group, she will fail to open the root session damon's socket because of the kernel-side permission checking. However, the behaviour of the lttng client (and error reporting) will be confusing. Signed-off-by: Jérémie Galarneau Change-Id: I1c12285fd0f42bb73c560a32a56cab03f1a5a6e1 --- diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index c304a37db..2c2335a28 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -367,7 +367,7 @@ static int set_session_daemon_path(void) in_tgroup = lttng_check_tracing_group(); } - if ((uid == 0) || in_tgroup) { + if ((uid == 0) || in_tgroup == 1) { const int ret = lttng_strncpy(sessiond_sock_path, DEFAULT_GLOBAL_CLIENT_UNIX_SOCK, sizeof(sessiond_sock_path));