/*
* SPDX-License-Identifier: GPL-2.0-only
*
- * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
* Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
}
ret = ustcomm_recv_app_reply(sock, &lur, lum.handle, lum.cmd);
if (ret < 0) {
+ if (ret == -EINVAL) {
+ /*
+ * Command unknown from remote end. The communication socket is
+ * now out-of-sync and needs to be shutdown.
+ */
+ (void) ustcomm_shutdown_unix_sock(sock);
+ }
goto end;
- } else if (ret == -EINVAL) {
- /*
- * Command unknown from remote end. The communication socket is
- * now out-of-sync and needs to be shutdown.
- */
- (void) ustcomm_shutdown_unix_sock(sock);
}
-
context_data->handle = -1;
DBG("Context created successfully");
*_context_data = context_data;
obj->u.channel.wakeup_fd =
dup(src->u.channel.wakeup_fd);
if (obj->u.channel.wakeup_fd < 0) {
- ret = errno;
+ ret = -errno;
goto chan_error_wakeup_fd;
}
} else {
obj->u.stream.wakeup_fd =
dup(src->u.stream.wakeup_fd);
if (obj->u.stream.wakeup_fd < 0) {
- ret = errno;
+ ret = -errno;
goto stream_error_wakeup_fd;
}
} else {
obj->u.stream.shm_fd =
dup(src->u.stream.shm_fd);
if (obj->u.stream.shm_fd < 0) {
- ret = errno;
+ ret = -errno;
goto stream_error_shm_fd;
}
} else {
obj->u.counter_global.shm_fd =
dup(src->u.counter_global.shm_fd);
if (obj->u.counter_global.shm_fd < 0) {
- ret = errno;
+ ret = -errno;
goto error_type;
}
}
obj->u.counter_cpu.shm_fd =
dup(src->u.counter_cpu.shm_fd);
if (obj->u.counter_cpu.shm_fd < 0) {
- ret = errno;
+ ret = -errno;
goto error_type;
}
}
int lttng_ust_ctl_get_nr_stream_per_channel(void)
{
- return num_possible_cpus();
+ return get_possible_cpus_array_len();
}
struct lttng_ust_ctl_consumer_channel *
/*
* Override application uid/gid with unix socket credentials. Use the
* first group of the cr_groups.
- * Use the pid and ppid provided by the application on registration.
*/
static
int get_cred(int sock,
socklen_t xucred_len = sizeof(struct xucred);
int ret;
- ret = getsockopt(sock, SOL_SOCKET, LOCAL_PEERCRED, &xucred, &xucred_len);
+ ret = getsockopt(sock, SOL_LOCAL, LOCAL_PEERCRED, &xucred, &xucred_len);
if (ret) {
return -LTTNG_UST_ERR_PEERCRED;
}
if (xucred.cr_version != XUCRED_VERSION || xucred.cr_ngroups < 1) {
return -LTTNG_UST_ERR_PEERCRED;
}
- DBG("Unix socket peercred [ uid: %u, gid: %u ], "
- "application registered claiming [ pid: %d, ppid: %d, uid: %u, gid: %u ]",
- xucred.cr_uid, xucred.cr_groups[0],
+ DBG("Unix socket peercred [ pid: %u, uid: %u, gid: %u ], "
+ "application registered claiming [ pid: %u, ppid: %u, uid: %u, gid: %u ]",
+ xucred.cr_pid, xucred.cr_uid, xucred.cr_groups[0],
reg_msg->pid, reg_msg->ppid, reg_msg->uid, reg_msg->gid);
- *pid = reg_msg->pid;
- *ppid = reg_msg->ppid;
+ *pid = xucred.cr_pid;
*uid = xucred.cr_uid;
*gid = xucred.cr_groups[0];
+ if (xucred.cr_pid == reg_msg->pid) {
+ *ppid = reg_msg->ppid;
+ } else {
+ *ppid = 0;
+ }
return 0;
}
#else
int lttng_ust_ctl_get_nr_cpu_per_counter(void)
{
- return num_possible_cpus();
+ return get_possible_cpus_array_len();
}
struct lttng_ust_ctl_daemon_counter *
return counter->ops->counter_clear(counter->counter, dimension_indexes);
}
+int lttng_ust_ctl_get_version(uint32_t *major, uint32_t *minor,
+ uint32_t *patchlevel) {
+ *major = LTTNG_UST_MAJOR_VERSION;
+ *minor = LTTNG_UST_MINOR_VERSION;
+ *patchlevel = LTTNG_UST_PATCHLEVEL_VERSION;
+ return 0;
+}
+
static
void lttng_ust_ctl_ctor(void)
__attribute__((constructor));