From: Francis Deslauriers Date: Thu, 15 Apr 2021 19:46:18 +0000 (-0400) Subject: Allow users to create trigger with their uid X-Git-Tag: v2.13.0-rc1~49 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=d84c8ae3fc703d9043eec97f1a5e61bef994da7b Allow users to create trigger with their uid 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 Signed-off-by: Jérémie Galarneau Change-Id: Ie0a642b3faf2259a892def3cb19a899e61cb4705 --- diff --git a/src/common/trigger.c b/src/common/trigger.c index ec96fc80b..215501401 100644 --- a/src/common/trigger.c +++ b/src/common/trigger.c @@ -704,6 +704,7 @@ enum lttng_trigger_status lttng_trigger_set_owner_uid( 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, @@ -715,7 +716,7 @@ enum lttng_trigger_status lttng_trigger_set_owner_uid( } /* 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; }