*/
#define _LGPL_SOURCE
-#include <errno.h>
#include <inttypes.h>
#include <pthread.h>
#include <stdio.h>
#include <urcu/compiler.h>
#include <signal.h>
+#include <common/compat/errno.h>
#include <common/common.h>
#include <common/sessiond-comm/sessiond-comm.h>
{
struct buffer_reg_uid *reg_uid = buffer_reg_uid_find(
ua_sess->tracing_id, ua_sess->bits_per_long,
- ua_sess->real_credentials.uid);
+ lttng_credentials_get_uid(&ua_sess->real_credentials));
if (!reg_uid) {
goto error;
}
if (uctx) {
memcpy(&ua_ctx->ctx, uctx, sizeof(ua_ctx->ctx));
if (uctx->ctx == LTTNG_UST_CONTEXT_APP_CONTEXT) {
- char *provider_name = NULL, *ctx_name = NULL;
+ char *provider_name = NULL, *ctx_name = NULL;
provider_name = strdup(uctx->u.app_ctx.provider_name);
ctx_name = strdup(uctx->u.app_ctx.ctx_name);
ua_sess->tracing_id = usess->id;
ua_sess->id = get_next_session_id();
- ua_sess->real_credentials.uid = app->uid;
- ua_sess->real_credentials.gid = app->gid;
- ua_sess->effective_credentials.uid = usess->uid;
- ua_sess->effective_credentials.gid = usess->gid;
+ LTTNG_OPTIONAL_SET(&ua_sess->real_credentials.uid, app->uid);
+ LTTNG_OPTIONAL_SET(&ua_sess->real_credentials.gid, app->gid);
+ LTTNG_OPTIONAL_SET(&ua_sess->effective_credentials.uid, usess->uid);
+ LTTNG_OPTIONAL_SET(&ua_sess->effective_credentials.gid, usess->gid);
ua_sess->buffer_type = usess->buffer_type;
ua_sess->bits_per_long = app->bits_per_long;
case LTTNG_BUFFER_PER_UID:
ret = snprintf(ua_sess->path, sizeof(ua_sess->path),
DEFAULT_UST_TRACE_UID_PATH,
- ua_sess->real_credentials.uid,
+ lttng_credentials_get_uid(&ua_sess->real_credentials),
app->bits_per_long);
break;
default:
app->uint64_t_alignment, app->long_alignment,
app->byte_order, app->version.major, app->version.minor,
reg_pid->root_shm_path, reg_pid->shm_path,
- ua_sess->effective_credentials.uid,
- ua_sess->effective_credentials.gid, ua_sess->tracing_id,
+ lttng_credentials_get_uid(&ua_sess->effective_credentials),
+ lttng_credentials_get_gid(&ua_sess->effective_credentials),
+ ua_sess->tracing_id,
app->uid);
if (ret < 0) {
/*
*/
static
int create_ust_app_channel_context(struct ust_app_channel *ua_chan,
- struct lttng_ust_context_attr *uctx,
+ struct lttng_ust_context_attr *uctx,
struct ust_app *app)
{
int ret = 0;
notification_ret = notification_thread_command_add_channel(
notification_thread_handle, session->name,
- ua_sess->effective_credentials.uid,
- ua_sess->effective_credentials.gid, ua_chan->name,
+ lttng_credentials_get_uid(&ua_sess->effective_credentials),
+ lttng_credentials_get_gid(&ua_sess->effective_credentials),
+ ua_chan->name,
ua_chan->key, LTTNG_DOMAIN_UST,
ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf);
if (notification_ret != LTTNG_OK) {
cmd_ret = notification_thread_command_add_channel(
notification_thread_handle, session->name,
- ua_sess->effective_credentials.uid,
- ua_sess->effective_credentials.gid, ua_chan->name,
+ lttng_credentials_get_uid(&ua_sess->effective_credentials),
+ lttng_credentials_get_gid(&ua_sess->effective_credentials),
+ ua_chan->name,
ua_chan->key, LTTNG_DOMAIN_UST,
ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf);
if (cmd_ret != LTTNG_OK) {
* allocated (if necessary) and sent to the application, and
* all enabled contexts will be added to the channel.
*/
- ret = find_or_create_ust_app_channel(usess, ua_sess,
+ ret = find_or_create_ust_app_channel(usess, ua_sess,
app, uchan, &ua_chan);
if (ret) {
/* Tracer is probably gone or ENOMEM. */
status = LTTNG_ERR_INVALID;
goto error;
}
- /* Add the UST default trace dir to path. */
+ /* Add the UST default trace dir to path. */
cds_lfht_for_each_entry(reg->registry->channels->ht, &iter.iter,
reg_chan, node.node) {
status = consumer_snapshot_channel(socket,
status = LTTNG_ERR_INVALID;
goto error;
}
- cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
+ cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
ua_chan, node.node) {
status = consumer_snapshot_channel(socket,
ua_chan->key, output, 0,
- ua_sess->effective_credentials
- .uid,
- ua_sess->effective_credentials
- .gid,
+ lttng_credentials_get_uid(&ua_sess->effective_credentials),
+ lttng_credentials_get_gid(&ua_sess->effective_credentials),
&trace_path[consumer_path_offset], wait,
nb_packets_per_stream);
switch (status) {
}
status = consumer_snapshot_channel(socket,
registry->metadata_key, output, 1,
- ua_sess->effective_credentials.uid,
- ua_sess->effective_credentials.gid,
+ lttng_credentials_get_uid(&ua_sess->effective_credentials),
+ lttng_credentials_get_gid(&ua_sess->effective_credentials),
&trace_path[consumer_path_offset], wait, 0);
switch (status) {
case LTTNG_OK:
ua_chan, node.node) {
ret = consumer_rotate_channel(socket,
ua_chan->key,
- ua_sess->effective_credentials
- .uid,
- ua_sess->effective_credentials
- .gid,
+ lttng_credentials_get_uid(&ua_sess->effective_credentials),
+ lttng_credentials_get_gid(&ua_sess->effective_credentials),
ua_sess->consumer,
/* is_metadata_channel */ false);
if (ret < 0) {
(void) push_metadata(registry, usess->consumer);
ret = consumer_rotate_channel(socket,
registry->metadata_key,
- ua_sess->effective_credentials.uid,
- ua_sess->effective_credentials.gid,
+ lttng_credentials_get_uid(&ua_sess->effective_credentials),
+ lttng_credentials_get_gid(&ua_sess->effective_credentials),
ua_sess->consumer,
/* is_metadata_channel */ true);
if (ret < 0) {
* Per-PID buffer and application going
* away.
*/
- if (ret == -LTTNG_ERR_CHAN_NOT_FOUND) {
+ if (open_ret == -LTTNG_ERR_CHAN_NOT_FOUND) {
continue;
}