From: David Goulet Date: Mon, 19 Aug 2013 16:08:06 +0000 (-0400) Subject: Fix: snapshot with multiple UIDs X-Git-Tag: v2.3.0-rc3~39 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=567eb353c7f88e2fdaa106eb7e0a38dbb8717792;p=lttng-tools.git Fix: snapshot with multiple UIDs This commit refs #615. Waiting on the confirmation of the author to close it. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 79fdbf1c8..17fc91976 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -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)); diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index 44fd708ec..2dd3b81dd 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -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, diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 9f3557cd0..d6fe58cd9 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -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(); diff --git a/src/common/consumer.h b/src/common/consumer.h index 5021a1035..2003cbe43 100644 --- a/src/common/consumer.h +++ b/src/common/consumer.h @@ -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]; /* diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index c52a6caa0..b98e4f747 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -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; diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 9612b9a23..9b1675e8b 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -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,