Currently, the `add-trigger` prints the following if a user uses the
`--user-id` with its own uid:
Error: Failed to set trigger's user identity.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie0a642b3faf2259a892def3cb19a899e61cb4705
struct lttng_trigger *trigger, uid_t uid)
{
enum lttng_trigger_status ret = LTTNG_TRIGGER_STATUS_OK;
+ const uid_t euid = geteuid();
const struct lttng_credentials creds = {
.uid = LTTNG_OPTIONAL_INIT_VALUE(uid),
.gid = LTTNG_OPTIONAL_INIT_UNSET,
}
/* Client-side validation only to report a clearer error. */
- if (geteuid() != 0) {
+ if (euid != 0 && euid != uid) {
ret = LTTNG_TRIGGER_STATUS_PERMISSION_DENIED;
goto end;
}