Fix: meaningful error message
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 2 Mar 2012 23:17:33 +0000 (18:17 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 2 Mar 2012 23:17:33 +0000 (18:17 -0500)
Show a meaningful error message to users attempting to do kernel tracing
without root sessiond/tracing group creds.

Reported-by: "Brosseau, Yannick" <yannick.brosseau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng-sessiond/main.c
src/common/sessiond-comm/sessiond-comm.c
src/common/sessiond-comm/sessiond-comm.h

index ff29eb03566775b8cc351296f4dab543a732cc0a..9e2b21b2dd417d7fc217f75de2293ff932f8b43c 100644 (file)
@@ -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;
                }
 
index 477bd1c644ca18a6d87bde40212e46678a3db0b1..fdd5856c0c0fe2328e12ceb050f6bcbd9814c72e 100644 (file)
@@ -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",
 };
 
 /*
index 31b7fe4661cbd1db37acb52013d31048b873df2e..472ca35d4446ead2215d7931e362dbf0da44e960 100644 (file)
@@ -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 */
 };
This page took 0.029825 seconds and 4 git commands to generate.