+ const enum lttng_action_type action_type = lttng_action_get_type(action);
+
+ assert(action_type != LTTNG_ACTION_TYPE_UNKNOWN);
+
+ return action_type_names[action_type];
+}
+
+/* Check if this trigger allowed to interect with a given session. */
+static bool is_trigger_allowed_for_session(const struct lttng_trigger *trigger,
+ struct ltt_session *session)
+{
+ bool is_allowed = false;
+ const struct lttng_credentials session_creds = {
+ .uid = LTTNG_OPTIONAL_INIT_VALUE(session->uid),
+ .gid = LTTNG_OPTIONAL_INIT_VALUE(session->gid),
+ };
+ /* Can never be NULL. */
+ const struct lttng_credentials *trigger_creds =
+ lttng_trigger_get_credentials(trigger);
+
+ is_allowed = (lttng_credentials_is_equal_uid(trigger_creds, &session_creds)) ||
+ (lttng_credentials_get_uid(trigger_creds) == 0);
+ if (!is_allowed) {
+ WARN("Trigger is not allowed to interact with session `%s`: session uid = %ld, session gid = %ld, trigger uid = %ld",
+ session->name,
+ (long int) session->uid,
+ (long int) session->gid,
+ (long int) lttng_credentials_get_uid(trigger_creds));
+ }
+
+ return is_allowed;
+}
+
+static const char *get_trigger_name(const struct lttng_trigger *trigger)
+{
+ const char *trigger_name;
+ enum lttng_trigger_status trigger_status;
+
+ trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
+ assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+ return trigger_name;