From: Mathieu Desnoyers Date: Fri, 2 Mar 2012 23:17:33 +0000 (-0500) Subject: Fix: meaningful error message X-Git-Tag: v2.0.0-rc2~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=531d29f9e514ad5a4880600d5c7e373f2f254ead;p=lttng-tools.git Fix: meaningful error message Show a meaningful error message to users attempting to do kernel tracing without root sessiond/tracing group creds. Reported-by: "Brosseau, Yannick" Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index ff29eb035..9e2b21b2d 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -1845,7 +1845,11 @@ error_open: error: WARN("No kernel tracer available"); kernel_tracer_fd = -1; - return LTTCOMM_KERN_NA; + if (!is_root) { + return LTTCOMM_NEED_ROOT_SESSIOND; + } else { + return LTTCOMM_KERN_NA; + } } /* @@ -3254,7 +3258,11 @@ static int process_client_msg(struct command_ctx *cmd_ctx) if (opt_no_kernel && need_domain && cmd_ctx->lsm->domain.type == LTTNG_DOMAIN_KERNEL) { - ret = LTTCOMM_KERN_NA; + if (!is_root) { + ret = LTTCOMM_NEED_ROOT_SESSIOND; + } else { + ret = LTTCOMM_KERN_NA; + } goto error; } @@ -3316,7 +3324,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx) switch (cmd_ctx->lsm->domain.type) { case LTTNG_DOMAIN_KERNEL: if (!is_root) { - ret = LTTCOMM_KERN_NA; + ret = LTTCOMM_NEED_ROOT_SESSIOND; goto error; } diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index 477bd1c64..fdd5856c0 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -117,6 +117,7 @@ static const char *lttcomm_readable_code[] = { [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_ENOMEM) ] = "consumerd splice ENOMEM", [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_ESPIPE) ] = "consumerd splice ESPIPE", [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_EVENT) ] = "Event not found", + [ LTTCOMM_ERR_INDEX(LTTCOMM_NEED_ROOT_SESSIOND) ] = "A root lttng-sessiond needs to be running, and client user part of the \"tracing\" group, to interact with kernel tracing", }; /* diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 31b7fe466..472ca35d4 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -151,6 +151,7 @@ enum lttcomm_return_code { CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */ CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */ CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */ + LTTCOMM_NEED_ROOT_SESSIOND, /* root sessiond is needed */ /* MUST be last element */ LTTCOMM_NR, /* Last element */ };