X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbin%2Flttng-sessiond%2Fnotification-thread-events.c;h=e52e4bd979cbe9108a599522a1eca74e848e541d;hb=b9bbdb8ae401dea58c56845fceb6b615225df6b4;hp=86a114c07ddb0cafc9acd5533d1315bce10d7343;hpb=882093eef6fdd658833928a62be5d42fc0cdcb00;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index 86a114c07..e52e4bd97 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -1807,8 +1808,8 @@ int handle_notification_thread_command_session_rotation( struct lttng_trigger_list_element *trigger_list_element; struct session_info *session_info; const struct lttng_credentials session_creds = { - .uid = session_uid, - .gid = session_gid, + .uid = LTTNG_OPTIONAL_INIT_VALUE(session_uid), + .gid = LTTNG_OPTIONAL_INIT_VALUE(session_gid), }; rcu_read_lock(); @@ -2058,7 +2059,7 @@ bool is_trigger_action_notify(const struct lttng_trigger *trigger) enum lttng_action_type action_type; assert(action); - action_type = lttng_action_get_type_const(action); + action_type = lttng_action_get_type(action); if (action_type == LTTNG_ACTION_TYPE_NOTIFY) { is_notify = true; goto end; @@ -2074,7 +2075,7 @@ bool is_trigger_action_notify(const struct lttng_trigger *trigger) lttng_action_group_get_at_index( action, i); - action_type = lttng_action_get_type_const(inner_action); + action_type = lttng_action_get_type(inner_action); if (action_type == LTTNG_ACTION_TYPE_NOTIFY) { is_notify = true; goto end; @@ -2117,6 +2118,8 @@ int handle_notification_thread_command_register_trigger( bool free_trigger = true; struct lttng_evaluation *evaluation = NULL; struct lttng_credentials object_creds; + uid_t object_uid; + gid_t object_gid; enum action_executor_status executor_status; rcu_read_lock(); @@ -2260,13 +2263,13 @@ int handle_notification_thread_command_register_trigger( switch (get_condition_binding_object(condition)) { case LTTNG_OBJECT_TYPE_SESSION: ret = evaluate_session_condition_for_client(condition, state, - &evaluation, &object_creds.uid, - &object_creds.gid); + &evaluation, &object_uid, + &object_gid); break; case LTTNG_OBJECT_TYPE_CHANNEL: ret = evaluate_channel_condition_for_client(condition, state, - &evaluation, &object_creds.uid, - &object_creds.gid); + &evaluation, &object_uid, + &object_gid); break; case LTTNG_OBJECT_TYPE_NONE: ret = 0; @@ -2282,6 +2285,9 @@ int handle_notification_thread_command_register_trigger( goto error_put_client_list; } + LTTNG_OPTIONAL_SET(&object_creds.uid, object_uid); + LTTNG_OPTIONAL_SET(&object_creds.gid, object_gid); + DBG("Newly registered trigger's condition evaluated to %s", evaluation ? "true" : "false"); if (!evaluation) { @@ -2869,7 +2875,7 @@ enum client_transmission_status client_flush_outgoing_queue( client->socket); to_send_count -= max(ret, 0); - memcpy(client->communication.outbound.payload.buffer.data, + memmove(client->communication.outbound.payload.buffer.data, pv.buffer.data + pv.buffer.size - to_send_count, to_send_count); @@ -3582,11 +3588,15 @@ int send_evaluation_to_clients(const struct lttng_trigger *trigger, struct notification_thread_state *state, uid_t object_uid, gid_t object_gid) { + const struct lttng_credentials creds = { + .uid = LTTNG_OPTIONAL_INIT_VALUE(object_uid), + .gid = LTTNG_OPTIONAL_INIT_VALUE(object_gid), + }; + return notification_client_list_send_evaluation(client_list, lttng_trigger_get_const_condition(trigger), evaluation, lttng_trigger_get_credentials(trigger), - &(struct lttng_credentials){ - .uid = object_uid, .gid = object_gid}, + &creds, client_handle_transmission_status_wrapper, state); } @@ -3693,8 +3703,8 @@ int notification_client_list_send_evaluation( } if (source_object_creds) { - if (client->uid != source_object_creds->uid && - client->gid != source_object_creds->gid && + if (client->uid != lttng_credentials_get_uid(source_object_creds) && + client->gid != lttng_credentials_get_gid(source_object_creds) && client->uid != 0) { /* * Client is not allowed to monitor this @@ -3705,7 +3715,7 @@ int notification_client_list_send_evaluation( } } - if (client->uid != trigger_creds->uid && client->gid != trigger_creds->gid) { + if (client->uid != lttng_credentials_get_uid(trigger_creds) && client->gid != lttng_credentials_get_gid(trigger_creds)) { DBG("[notification-thread] Skipping client at it does not have the permission to receive notification for this trigger"); goto skip_client; } @@ -3894,8 +3904,8 @@ int handle_notification_thread_channel_sample( } channel_creds = (typeof(channel_creds)) { - .uid = channel_info->session_info->uid, - .gid = channel_info->session_info->gid, + .uid = LTTNG_OPTIONAL_INIT_VALUE(channel_info->session_info->uid), + .gid = LTTNG_OPTIONAL_INIT_VALUE(channel_info->session_info->gid), }; trigger_list = caa_container_of(node, struct lttng_channel_trigger_list,