From c295ec411f7dd32b16ba6ce949b0a0d6001c0b5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 3 May 2021 12:50:25 -0400 Subject: [PATCH] Fix: lttng-ctl: erroneous check if user is part of the tracing group MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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: I614da0123d0546c5f54f121e8ed9716d6e292400 --- src/lib/lttng-ctl/lttng-ctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 7a38699d9..d9805e222 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -388,7 +388,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)); -- 2.34.1