Allow users to create trigger with their uid
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 15 Apr 2021 19:46:18 +0000 (15:46 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 22 Apr 2021 01:33:42 +0000 (21:33 -0400)
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

src/common/trigger.c

index ec96fc80b7d804249c8c4f1f395d4a693080fd1e..21550140100a755984523d8b1f1f7a8fd76e4acb 100644 (file)
@@ -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;
        }
This page took 0.025513 seconds and 4 git commands to generate.