Fix: snapshot with multiple UIDs
authorDavid Goulet <dgoulet@efficios.com>
Mon, 19 Aug 2013 16:08:06 +0000 (12:08 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 19 Aug 2013 16:08:06 +0000 (12:08 -0400)
This commit refs #615. Waiting on the confirmation of the author to
close it.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/consumer.c
src/bin/lttng-sessiond/consumer.h
src/bin/lttng-sessiond/ust-consumer.c
src/common/consumer.h
src/common/sessiond-comm/sessiond-comm.h
src/common/ust-consumer/ust-consumer.c

index 79fdbf1c8b632bc9f049e27511f7b593314bd0f7..17fc919768fa98610ad4a0afddfdb58ef38db773 100644 (file)
@@ -737,7 +737,8 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
                uint64_t session_id_per_pid,
-               unsigned int monitor)
+               unsigned int monitor,
+               uint32_t ust_app_uid)
 {
        assert(msg);
 
@@ -762,6 +763,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
        msg->u.ask_channel.tracefile_size = tracefile_size;
        msg->u.ask_channel.tracefile_count = tracefile_count;
        msg->u.ask_channel.monitor = monitor;
+       msg->u.ask_channel.ust_app_uid = ust_app_uid;
 
        memcpy(msg->u.ask_channel.uuid, uuid, sizeof(msg->u.ask_channel.uuid));
 
index 44fd708ec8b8779a8d9ac77eec5835fbeb9611f9..2dd3b81ddbb40b537b1c314f131446a609d6d406 100644 (file)
@@ -214,7 +214,8 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
                uint64_t session_id_per_pid,
-               unsigned int monitor);
+               unsigned int monitor,
+               uint32_t ust_app_uid);
 void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg,
                enum lttng_consumer_command cmd,
                uint64_t channel_key,
index 9f3557cd0d02efa77f0e41be54bcc06d670b210e..d6fe58cd971aa9f1f770f99860a65129c329ac76 100644 (file)
@@ -161,7 +161,8 @@ static int ask_channel_creation(struct ust_app_session *ua_sess,
                        ua_chan->tracefile_size,
                        ua_chan->tracefile_count,
                        ua_sess->id,
-                       ua_sess->output_traces);
+                       ua_sess->output_traces,
+                       ua_sess->uid);
 
        health_code_update();
 
index 5021a103569ea28d18bcd9d071f2781704da078b..2003cbe43003f304c7bf60387416b9a5c8a1da76 100644 (file)
@@ -115,7 +115,7 @@ struct lttng_consumer_channel {
        char pathname[PATH_MAX];
        /* Channel name. */
        char name[LTTNG_SYMBOL_NAME_LEN];
-       /* UID and GID of the channel. */
+       /* UID and GID of the session owning this channel. */
        uid_t uid;
        gid_t gid;
        /* Relayd id of the channel. -1ULL if it does not apply. */
@@ -131,6 +131,7 @@ struct lttng_consumer_channel {
        enum consumer_channel_type type;
 
        /* For UST */
+       uid_t ust_app_uid;      /* Application UID. */
        struct ustctl_consumer_channel *uchan;
        unsigned char uuid[UUID_STR_LEN];
        /*
index c52a6caa0575272788797786b373b85ba286bce9..b98e4f747299c54c652f5b3dd2a83a6237d19979 100644 (file)
@@ -368,6 +368,13 @@ struct lttcomm_consumer_msg {
                        uint64_t session_id_per_pid;    /* Per-pid session ID. */
                        /* Tells the consumer if the stream should be or not monitored. */
                        uint32_t monitor;
+                       /*
+                        * For UST per UID buffers, this is the application UID of the
+                        * channel.  This can be different from the user UID requesting the
+                        * channel creation and used for the rights on the stream file
+                        * because the application can be in the tracing for instance.
+                        */
+                       uint32_t ust_app_uid;
                } LTTNG_PACKED ask_channel;
                struct {
                        uint64_t key;
index 9612b9a23154f0e9cc0b8e342bb722c5ca019487..9b1675e8be94b89b560dcd77db1e36e5fedb8775 100644 (file)
@@ -1178,6 +1178,13 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                        goto end_channel_error;
                }
 
+               /*
+                * Assign UST application UID to the channel. This value is ignored for
+                * per PID buffers. This is specific to UST thus setting this after the
+                * allocation.
+                */
+               channel->ust_app_uid = msg.u.ask_channel.ust_app_uid;
+
                /* Build channel attributes from received message. */
                attr.subbuf_size = msg.u.ask_channel.subbuf_size;
                attr.num_subbuf = msg.u.ask_channel.num_subbuf;
@@ -1859,12 +1866,18 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
 
        request.session_id = channel->session_id;
        request.session_id_per_pid = channel->session_id_per_pid;
-       request.uid = channel->uid;
+       /*
+        * Request the application UID here so the metadata of that application can
+        * be sent back. The channel UID corresponds to the user UID of the session
+        * used for the rights on the stream file(s).
+        */
+       request.uid = channel->ust_app_uid;
        request.key = channel->key;
+
        DBG("Sending metadata request to sessiond, session id %" PRIu64
-                       ", per-pid %" PRIu64,
-                       channel->session_id,
-                       channel->session_id_per_pid);
+                       ", per-pid %" PRIu64 ", app UID %u and channek key %" PRIu64,
+                       request.session_id, request.session_id_per_pid, request.uid,
+                       request.key);
 
        pthread_mutex_lock(&ctx->metadata_socket_lock);
        ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request,
This page took 0.030992 seconds and 4 git commands to generate.