#define LTTNG_TRIGGER_INTERNAL_H
#include <lttng/trigger/trigger.h>
+#include <common/credentials.h>
#include <common/macros.h>
+#include <common/optional.h>
#include <stdint.h>
#include <stdbool.h>
#include <sys/types.h>
struct lttng_trigger {
struct lttng_condition *condition;
struct lttng_action *action;
+ LTTNG_OPTIONAL(struct lttng_credentials) creds;
};
struct lttng_trigger_comm {
LTTNG_HIDDEN
bool lttng_trigger_validate(struct lttng_trigger *trigger);
+LTTNG_HIDDEN
+const struct lttng_credentials *lttng_trigger_get_credentials(
+ const struct lttng_trigger *trigger);
+
+LTTNG_HIDDEN
+void lttng_trigger_set_credentials(
+ struct lttng_trigger *trigger,
+ const struct lttng_credentials *creds);
+
#endif /* LTTNG_TRIGGER_INTERNAL_H */
ssize_t sock_recv_len;
struct lttng_trigger *trigger = NULL;
struct lttng_payload trigger_payload;
+ struct lttng_credentials cmd_creds = {
+ .uid = cmd_ctx->creds.uid,
+ .gid = cmd_ctx->creds.gid,
+ };
lttng_payload_init(&trigger_payload);
trigger_len = (size_t) cmd_ctx->lsm.u.trigger.length;
}
}
+ /* Set the trigger credential */
+ lttng_trigger_set_credentials(trigger, &cmd_creds);
+
+ /* Inform the notification thread */
ret = notification_thread_command_register_trigger(notification_thread,
trigger);
/* Ownership of trigger was transferred. */
ssize_t sock_recv_len;
struct lttng_trigger *trigger = NULL;
struct lttng_payload trigger_payload;
+ struct lttng_credentials cmd_creds = {
+ .uid = cmd_ctx->creds.uid,
+ .gid = cmd_ctx->creds.gid,
+ };
lttng_payload_init(&trigger_payload);
trigger_len = (size_t) cmd_ctx->lsm.u.trigger.length;
}
}
+ lttng_trigger_set_credentials(trigger, &cmd_creds);
+
ret = notification_thread_command_unregister_trigger(notification_thread,
trigger);
end:
#include <common/time.h>
#include <common/hashtable/utils.h>
#include <common/kernel-ctl/kernel-ctl.h>
+#include <common/credentials.h>
#include <sys/eventfd.h>
#include <sys/stat.h>
#include <time.h>
enum lttng_condition_status condition_status;
enum lttng_notification_channel_status nc_status;
struct lttng_action *action;
+ const struct lttng_credentials session_creds = {
+ .uid = session->uid,
+ .gid = session->gid,
+ };
session->rotate_condition = lttng_condition_session_consumed_size_create();
if (!session->rotate_condition) {
goto end;
}
+ lttng_trigger_set_credentials(
+ session->rotate_trigger, &session_creds);
+
nc_status = lttng_notification_channel_subscribe(
rotate_notification_channel, session->rotate_condition);
if (nc_status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) {
(optional).value; \
})
+/*
+ * This macro is available as a 'convenience' to allow sites that assume
+ * an optional value is set to assert() that it is set when fecthing the
+ * underlying value's address.
+ */
+#define LTTNG_OPTIONAL_GET_PTR(optional) \
+ ({ \
+ assert((optional).is_set); \
+ &(optional).value; \
+ })
+
/*
* Initialize an optional field.
*
#include <lttng/trigger/trigger-internal.h>
#include <lttng/condition/condition-internal.h>
#include <lttng/action/action-internal.h>
+#include <common/credentials.h>
#include <common/payload.h>
#include <common/payload-view.h>
#include <common/error.h>
+#include <common/optional.h>
#include <assert.h>
LTTNG_HIDDEN
trigger->condition = condition;
trigger->action = action;
+
end:
return trigger;
}
end:
return ret;
}
+
+LTTNG_HIDDEN
+const struct lttng_credentials *lttng_trigger_get_credentials(
+ const struct lttng_trigger *trigger)
+{
+ return LTTNG_OPTIONAL_GET_PTR(trigger->creds);
+}
+
+LTTNG_HIDDEN
+void lttng_trigger_set_credentials(
+ struct lttng_trigger *trigger,
+ const struct lttng_credentials *creds)
+{
+ assert(creds);
+ LTTNG_OPTIONAL_SET(&trigger->creds, *creds);
+}