X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=fdc72b834158c1de4082d657affff40e93979e08;hb=bfaba83f452c53682bcdc1075e760988b9549b67;hp=10517fbc0f999ac8c7497f34e9756ec29a72cb6a;hpb=d75bffee2ba2d4fd895dbc15e399db95e88fdb92;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 10517fbc0..fdc72b834 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -379,6 +379,8 @@ static int list_lttng_kernel_events(char *channel_name, strncpy((*events)[i].name, event->event->name, LTTNG_SYMBOL_NAME_LEN); (*events)[i].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; (*events)[i].enabled = event->enabled; + (*events)[i].filter = + (unsigned char) !!event->filter_expression; switch (event->event->instrumentation) { case LTTNG_KERNEL_TRACEPOINT: @@ -1106,9 +1108,40 @@ int cmd_enable_channel(struct ltt_session *session, break; } case LTTNG_DOMAIN_UST: + case LTTNG_DOMAIN_JUL: + case LTTNG_DOMAIN_LOG4J: + case LTTNG_DOMAIN_PYTHON: { struct ltt_ust_channel *uchan; + /* + * FIXME + * + * Current agent implementation limitations force us to allow + * only one channel at once in "agent" subdomains. Each + * subdomain has a default channel name which must be strictly + * adhered to. + */ + if (domain->type == LTTNG_DOMAIN_JUL) { + if (strncmp(attr->name, DEFAULT_JUL_CHANNEL_NAME, + LTTNG_SYMBOL_NAME_LEN)) { + ret = LTTNG_ERR_INVALID_CHANNEL_NAME; + goto error; + } + } else if (domain->type == LTTNG_DOMAIN_LOG4J) { + if (strncmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME, + LTTNG_SYMBOL_NAME_LEN)) { + ret = LTTNG_ERR_INVALID_CHANNEL_NAME; + goto error; + } + } else if (domain->type == LTTNG_DOMAIN_PYTHON) { + if (strncmp(attr->name, DEFAULT_PYTHON_CHANNEL_NAME, + LTTNG_SYMBOL_NAME_LEN)) { + ret = LTTNG_ERR_INVALID_CHANNEL_NAME; + goto error; + } + } + chan_ht = usess->domain_global.channels; uchan = trace_ust_find_channel_by_name(chan_ht, attr->name); @@ -1671,6 +1704,16 @@ static int _cmd_enable_event(struct ltt_session *session, assert(uchan); } + if (uchan->domain != LTTNG_DOMAIN_UST && !internal_event) { + /* + * Don't allow users to add UST events to channels which + * are assigned to a userspace subdomain (JUL, Log4J, + * Python, etc.). + */ + ret = LTTNG_ERR_INVALID_CHANNEL_DOMAIN; + goto error; + } + if (!internal_event) { /* * Ensure the event name is not reserved for internal @@ -1715,7 +1758,7 @@ static int _cmd_enable_event(struct ltt_session *session, if (!agt) { agt = agent_create(domain->type); if (!agt) { - ret = -LTTNG_ERR_NOMEM; + ret = LTTNG_ERR_NOMEM; goto error; } agent_add(agt, usess->agents); @@ -1725,9 +1768,10 @@ static int _cmd_enable_event(struct ltt_session *session, memset(&uevent, 0, sizeof(uevent)); uevent.type = LTTNG_EVENT_TRACEPOINT; uevent.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL; - default_event_name = event_get_default_agent_ust_name(domain->type); + default_event_name = event_get_default_agent_ust_name( + domain->type); if (!default_event_name) { - ret = -LTTNG_ERR_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } strncpy(uevent.name, default_event_name, sizeof(uevent.name)); @@ -1757,28 +1801,31 @@ static int _cmd_enable_event(struct ltt_session *session, } { - struct lttng_filter_bytecode *filter_copy = NULL; char *filter_expression_copy = NULL; + struct lttng_filter_bytecode *filter_copy = NULL; if (filter) { - filter_copy = zmalloc( - sizeof(struct lttng_filter_bytecode) - + filter->len); + const size_t filter_size = sizeof( + struct lttng_filter_bytecode) + + filter->len; + + filter_copy = zmalloc(filter_size); if (!filter_copy) { + ret = LTTNG_ERR_NOMEM; goto error; } + memcpy(filter_copy, filter, filter_size); - memcpy(filter_copy, filter, - sizeof(struct lttng_filter_bytecode) - + filter->len); - } - - if (filter_expression) { filter_expression_copy = strdup(filter_expression); if (!filter_expression) { ret = LTTNG_ERR_NOMEM; - goto error_free_copy; + } + + if (!filter_expression_copy || !filter_copy) { + free(filter_expression_copy); + free(filter_copy); + goto error; } } @@ -1786,11 +1833,6 @@ static int _cmd_enable_event(struct ltt_session *session, (char *) default_chan_name, &uevent, filter_expression_copy, filter_copy, NULL, wpipe); - filter_copy = NULL; - filter_expression_copy = NULL; -error_free_copy: - free(filter_copy); - free(filter_expression_copy); } if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) { @@ -1801,12 +1843,12 @@ error_free_copy: if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) { ret = event_agent_enable_all(usess, agt, event, filter, filter_expression); - filter = NULL; } else { ret = event_agent_enable(usess, agt, event, filter, filter_expression); - filter = NULL; } + filter = NULL; + filter_expression = NULL; if (ret != LTTNG_OK) { goto error; } @@ -2303,7 +2345,7 @@ int cmd_create_session_snapshot(char *name, struct lttng_uri *uris, * Create session in no output mode with URIs set to NULL. The uris we've * received are for a default snapshot output if one. */ - ret = cmd_create_session_uri(name, NULL, 0, creds, -1); + ret = cmd_create_session_uri(name, NULL, 0, creds, 0); if (ret != LTTNG_OK) { goto error; }