From: Jérémie Galarneau Date: Thu, 5 Aug 2021 21:30:28 +0000 (-0400) Subject: run-as: clean-up: handle_one_cmd: mark initial uid/gid as const X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=45d6ecaaee3b2dd4d72f8de54a21ba2290f3b756;p=lttng-tools.git run-as: clean-up: handle_one_cmd: mark initial uid/gid as const Signed-off-by: Jérémie Galarneau Change-Id: Ia4fdf5b52a89bc499433550c0de8aeb50d3dea91 --- diff --git a/src/common/runas.c b/src/common/runas.c index ab43423b1..db95429b4 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -1101,8 +1101,8 @@ int handle_one_cmd(struct run_as_worker *worker) ssize_t readlen, writelen; struct run_as_ret sendret = {}; run_as_fct cmd; - uid_t prev_ruid; - gid_t prev_rgid; + const uid_t prev_ruid = getuid(); + const gid_t prev_rgid = getgid(); /* * Stage 1: Receive run_as_data struct from the master. @@ -1140,9 +1140,6 @@ int handle_one_cmd(struct run_as_worker *worker) goto end; } - prev_ruid = getuid(); - prev_rgid = getgid(); - ret = demote_creds(prev_ruid, prev_rgid, data.uid, data.gid); if (ret < 0) { goto write_return;