Fix: Deny session creation name 'auto'
authorDavid Goulet <dgoulet@efficios.com>
Fri, 2 Nov 2012 17:45:05 +0000 (13:45 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 2 Nov 2012 17:49:24 +0000 (13:49 -0400)
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 <dgoulet@efficios.com>
src/bin/lttng/commands/create.c
src/lib/lttng-ctl/lttng-ctl.c

index f92861e474c2edfc6869b23b25bde74598fed9f6..2c58075b4646cde144763ae30542608fa698eb4e 100644 (file)
@@ -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);
index ab64d56c0ff3df7ef52bfc511bbec5cf95838a34..bbe7cb4180dda914676714496fe31c56d09bf56e 100644 (file)
@@ -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) {
This page took 0.027118 seconds and 4 git commands to generate.