From: David Goulet Date: Fri, 2 Nov 2012 17:45:05 +0000 (-0400) Subject: Fix: Deny session creation name 'auto' X-Git-Tag: v2.1.0-rc7~26 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=61b35a5aa71d4c0715f390a32cb4e967e817c81f;p=lttng-tools.git Fix: Deny session creation name 'auto' This is a reserved keyword for default session(s). Note that this is only for the lttng command line tool. Using 'auto' is possible with the API but the current date and time is automatically appended to it for now so be aware of that. Fixes #359 Signed-off-by: David Goulet --- diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index f92861e47..2c58075b4 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -278,6 +278,14 @@ static int create_session(void) } DBG("Auto session name set to %s", session_name_date); } else { + if (strncmp(opt_session_name, DEFAULT_SESSION_NAME, + strlen(DEFAULT_SESSION_NAME)) == 0 && + strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME)) { + ERR("%s is a reserved keyword for default session(s)", + DEFAULT_SESSION_NAME); + ret = CMD_ERROR; + goto error; + } session_name = opt_session_name; ret = snprintf(session_name_date, sizeof(session_name_date), "%s-%s", session_name, datetime); diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index ab64d56c0..bbe7cb418 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1606,7 +1606,8 @@ int _lttng_create_session_ext(const char *name, const char *url, memset(&lsm, 0, sizeof(lsm)); lsm.cmd_type = LTTNG_CREATE_SESSION; - if (!strncmp(name, DEFAULT_SESSION_NAME, strlen(DEFAULT_SESSION_NAME))) { + if (!strncmp(name, DEFAULT_SESSION_NAME, strlen(DEFAULT_SESSION_NAME)) + && strlen(name) == strlen(DEFAULT_SESSION_NAME)) { ret = snprintf(lsm.session.name, sizeof(lsm.session.name), "%s-%s", name, datetime); if (ret < 0) {