Fix: lttng create default name check
[lttng-tools.git] / src / bin / lttng / commands / create.c
index fe659d08747394de4d62cd2ea7da8c030513ef26..6c6566b0185b7384d2ff8297ff1ac17cdc391828 100644 (file)
@@ -280,9 +280,16 @@ static int create_session(void)
                        ret = LTTNG_ERR_SESSION_FAIL;
                        goto error;
                }
-               if (strncmp(opt_session_name, DEFAULT_SESSION_NAME,
+               /*
+                * Check if the session name begins with "auto-" or is exactly "auto".
+                * Both are reserved for the default session name. See bug #449 to
+                * understand why we need to check both here.
+                */
+               if ((strncmp(opt_session_name, DEFAULT_SESSION_NAME "-",
+                                       strlen(DEFAULT_SESSION_NAME) + 1) == 0) ||
+                               (strncmp(opt_session_name, DEFAULT_SESSION_NAME,
                                        strlen(DEFAULT_SESSION_NAME)) == 0 &&
-                               strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME)) {
+                               strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME))) {
                        ERR("%s is a reserved keyword for default session(s)",
                                        DEFAULT_SESSION_NAME);
                        ret = CMD_ERROR;
@@ -351,6 +358,9 @@ static int create_session(void)
                case LTTNG_ERR_EXIST_SESS:
                        WARN("Session %s already exists", session_name);
                        break;
+               default:
+                       ERR("%s", lttng_strerror(ret));
+                       break;
                }
                goto error;
        }
This page took 0.025073 seconds and 4 git commands to generate.