X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=dc442035a3fe21e6b4c487a1007c9f05d1b38c56;hp=37c0e31ce9dfe73b9713088c83ed1427f83ad389;hb=d7b377ed1acd4043bde353d99122e0e56fa4e975;hpb=e368fb4396b9bdb22de16f0c93512c9f6d7ab0b4 diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 37c0e31ce..dc442035a 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -6,9 +6,6 @@ * */ -#include "bin/lttng-sessiond/tracker.h" -#include "lttng/lttng-error.h" -#include "lttng/tracker.h" #define _LGPL_SOURCE #include #include @@ -40,6 +37,8 @@ #include #include #include +#include +#include #include #include "channel.h" @@ -59,6 +58,7 @@ #include "rotation-thread.h" #include "timer.h" #include "agent-thread.h" +#include "tracker.h" #include "cmd.h" @@ -946,7 +946,7 @@ static enum lttng_error_code send_consumer_relayd_socket( struct consumer_socket *consumer_sock, const char *session_name, const char *hostname, const char *base_path, int session_live_timer, - const uint64_t *current_chunk_id, + const uint64_t *current_chunk_id, time_t session_creation_time, bool session_name_contains_creation_time) { @@ -1074,9 +1074,9 @@ int cmd_setup_relayd(struct ltt_session *session) struct ltt_kernel_session *ksess; struct consumer_socket *socket; struct lttng_ht_iter iter; - LTTNG_OPTIONAL(uint64_t) current_chunk_id = {}; + LTTNG_OPTIONAL(uint64_t) current_chunk_id = {}; - assert(session); + assert(session); usess = session->ust_session; ksess = session->kernel_session; @@ -2288,7 +2288,7 @@ static int _cmd_enable_event(struct ltt_session *session, */ ret = validate_ust_event_name(event->name); if (ret) { - WARN("Userspace event name %s failed validation.", + WARN("Userspace event name %s failed validation.", event->name); ret = LTTNG_ERR_INVALID_EVENT_NAME; goto error; @@ -3164,10 +3164,10 @@ void cmd_destroy_session_reply(const struct ltt_session *session, lttng_dynamic_buffer_init(&payload); ret = lttng_dynamic_buffer_append(&payload, &llm, sizeof(llm)); - if (ret) { + if (ret) { ERR("Failed to append session destruction message"); goto error; - } + } cmd_header.rotation_state = (int32_t) (reply_context->implicit_rotation_on_destroy ? @@ -3290,10 +3290,10 @@ int cmd_destroy_session(struct ltt_session *session, session->name, lttng_strerror(-ret)); destruction_last_error = -ret; } - if (reply_context) { + if (reply_context) { reply_context->implicit_rotation_on_destroy = true; - } - } else if (session->has_been_started && session->current_trace_chunk) { + } + } else if (session->has_been_started && session->current_trace_chunk) { /* * The user has not triggered a session rotation. However, to * ensure all data has been consumed, the session is rotated @@ -3391,8 +3391,8 @@ int cmd_destroy_session(struct ltt_session *session, } else { *sock_fd = -1; } - } - ret = LTTNG_OK; + } + ret = LTTNG_OK; end: return ret; } @@ -3699,7 +3699,7 @@ void cmd_list_lttng_sessions(struct lttng_session *sessions, unsigned int i = 0; struct ltt_session *session; struct ltt_session_list *list = session_get_list(); - struct lttng_session_extended *extended = + struct lttng_session_extended *extended = (typeof(extended)) (&sessions[session_count]); DBG("Getting all available session for UID %d GID %d", @@ -3715,7 +3715,7 @@ void cmd_list_lttng_sessions(struct lttng_session *sessions, /* * Only list the sessions the user can control. */ - if (!session_access_ok(session, uid, gid) || + if (!session_access_ok(session, uid) || session->destroyed) { session_put(session); continue; @@ -4264,6 +4264,10 @@ int cmd_register_trigger(struct command_ctx *cmd_ctx, int sock, 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; @@ -4283,6 +4287,20 @@ int cmd_register_trigger(struct command_ctx *cmd_ctx, int sock, goto end; } + /* Receive fds, if any. */ + if (cmd_ctx->lsm.fd_count > 0) { + ret = lttcomm_recv_payload_fds_unix_sock( + sock, cmd_ctx->lsm.fd_count, &trigger_payload); + if (ret > 0 && ret != cmd_ctx->lsm.fd_count * sizeof(int)) { + ret = LTTNG_ERR_INVALID_PROTOCOL; + goto end; + } else if (ret <= 0) { + ret = LTTNG_ERR_FATAL; + goto end; + } + } + + /* Deserialize trigger. */ { struct lttng_payload_view view = lttng_payload_view_from_payload( @@ -4296,6 +4314,10 @@ int cmd_register_trigger(struct command_ctx *cmd_ctx, int sock, } } + /* 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. */ @@ -4314,6 +4336,10 @@ int cmd_unregister_trigger(struct command_ctx *cmd_ctx, int sock, 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; @@ -4333,6 +4359,19 @@ int cmd_unregister_trigger(struct command_ctx *cmd_ctx, int sock, goto end; } + /* Receive fds, if any. */ + if (cmd_ctx->lsm.fd_count > 0) { + ret = lttcomm_recv_payload_fds_unix_sock( + sock, cmd_ctx->lsm.fd_count, &trigger_payload); + if (ret > 0 && ret != cmd_ctx->lsm.fd_count * sizeof(int)) { + ret = LTTNG_ERR_INVALID_PROTOCOL; + goto end; + } else if (ret <= 0) { + ret = LTTNG_ERR_FATAL; + goto end; + } + } + { struct lttng_payload_view view = lttng_payload_view_from_payload( @@ -4346,6 +4385,8 @@ int cmd_unregister_trigger(struct command_ctx *cmd_ctx, int sock, } } + lttng_trigger_set_credentials(trigger, &cmd_creds); + ret = notification_thread_command_unregister_trigger(notification_thread, trigger); end: @@ -4969,7 +5010,7 @@ int cmd_rotate_session(struct ltt_session *session, cmd_ret = LTTNG_ERR_CREATE_DIR_FAIL; goto error; } - } + } /* * The current trace chunk becomes the chunk being archived.