Fix: sessiond: size-based rotations never trigger
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 17 Jun 2022 20:53:53 +0000 (16:53 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 21 Jun 2022 04:45:24 +0000 (00:45 -0400)
Issue observed
==============

Size-based scheduled rotations have no effect.

Cause
=====

Since c08136a3f, the rotation thread's handle_condition() checks that
the notification received matches the trigger that was registered.

As part of the equality check, the triggers' credentials are compared.

This checks fails systematically since the group id of a trigger's
credentials is not transported by the serialize/create_from functions.
The trigger that is received through the notification thus has an unset
group id, while the rotation trigger of the `ltt_session` has a group id
set; it was not stripped by the communication layer.

The check also fails since the trigger registered for the size-based
rotation is "hidden". This internal attribute is not propagated through
the communication layer, which causes the comparison to fail.

Solution
========

Since triggers only use the 'uid' part of lttng_credentials, we ensure
that lttng_trigger_set_credentials only sets this part of the structure.

Also, the `is_hidden` attribute of a trigger is now propagated through
the communication layer. This has no effect for external applications
since this attribute is not exposed through the API. However, it is
useful for internal triggers which use the same communication
facilities.

This allows the equality check in rotation-thread.cpp to go through as
expected.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I216f5cb9297ecd1a867dc292c10b8da595efce34

include/lttng/trigger/trigger-internal.hpp
src/common/trigger.cpp

index 206e7dfa8cfdb518413e251514e16b45869721d0..a05a36ed3a2b4a5b1b5901a35b5b316be03613bb 100644 (file)
@@ -60,8 +60,7 @@ struct lttng_trigger {
         * clients.
         *
         * This is a property that can only be set internally by the session
         * clients.
         *
         * This is a property that can only be set internally by the session
-        * daemon. As such, it is not serialized nor set by a
-        * "create_from_buffer" constructor.
+        * daemon.
         *
         * The hidden property is preserved by copies.
         *
         *
         * The hidden property is preserved by copies.
         *
@@ -94,6 +93,8 @@ struct lttng_trigger_comm {
        uint32_t length;
        /* Includes '\0' terminator. */
        uint32_t name_length;
        uint32_t length;
        /* Includes '\0' terminator. */
        uint32_t name_length;
+       /* Hidden property. */
+       uint8_t is_hidden;
        /* A null-terminated name, a condition, and an action follow. */
        char payload[];
 } LTTNG_PACKED;
        /* A null-terminated name, a condition, and an action follow. */
        char payload[];
 } LTTNG_PACKED;
index 161c1abee7654f4ad5a00852f8e5fd53c2353302..bceeab534ae14a8113233537060fcc59b3fd92be 100644 (file)
@@ -266,6 +266,10 @@ ssize_t lttng_trigger_create_from_payload(
                }
        }
 
                }
        }
 
+       if (trigger_comm->is_hidden) {
+               lttng_trigger_set_hidden(trigger);
+       }
+
        ret = offset;
 
 error:
        ret = offset;
 
 error:
@@ -307,6 +311,8 @@ int lttng_trigger_serialize(const struct lttng_trigger *trigger,
 
        trigger_comm.name_length = size_name;
 
 
        trigger_comm.name_length = size_name;
 
+       trigger_comm.is_hidden = lttng_trigger_is_hidden(trigger);
+
        header_offset = payload->buffer.size;
        ret = lttng_dynamic_buffer_append(&payload->buffer, &trigger_comm,
                        sizeof(trigger_comm));
        header_offset = payload->buffer.size;
        ret = lttng_dynamic_buffer_append(&payload->buffer, &trigger_comm,
                        sizeof(trigger_comm));
@@ -736,8 +742,10 @@ const struct lttng_credentials *lttng_trigger_get_credentials(
 void lttng_trigger_set_credentials(struct lttng_trigger *trigger,
                const struct lttng_credentials *creds)
 {
 void lttng_trigger_set_credentials(struct lttng_trigger *trigger,
                const struct lttng_credentials *creds)
 {
+       /* Triggers do not use the group id to authenticate the user. */
        LTTNG_ASSERT(creds);
        LTTNG_ASSERT(creds);
-       trigger->creds = *creds;
+       LTTNG_OPTIONAL_SET(&trigger->creds.uid, LTTNG_OPTIONAL_GET(creds->uid));
+       LTTNG_OPTIONAL_UNSET(&trigger->creds.gid);
 }
 
 enum lttng_trigger_status lttng_trigger_set_owner_uid(
 }
 
 enum lttng_trigger_status lttng_trigger_set_owner_uid(
This page took 0.026851 seconds and 4 git commands to generate.