Fix: check illegal combinations of ctrl-url/data-url/ouput/set-url
[lttng-tools.git] / src / bin / lttng / commands / create.c
index d2741c37309239697ab9d7b30fed98ee5011f2c9..d3e5b9a84106f84fbde44c50eb8376bcd8faae94 100644 (file)
@@ -616,6 +616,22 @@ end:
        return ret;
 }
 
        return ret;
 }
 
+int validate_url_option_combination(void)
+{
+       int ret = 0;
+       int used_count = 0;
+
+       used_count += !!opt_url;
+       used_count += !!opt_output_path;
+       used_count += (opt_data_url || opt_ctrl_url);
+       if (used_count > 1) {
+               ERR("Only one of the --set-url, --ctrl-url/data-url, or --output options may be used at once.");
+               ret = -1;
+       }
+
+       return ret;
+}
+
 /*
  *  The 'create <options>' first level command
  *
 /*
  *  The 'create <options>' first level command
  *
@@ -687,6 +703,12 @@ int cmd_create(int argc, const char **argv)
                goto end;
        }
 
                goto end;
        }
 
+       ret = validate_url_option_combination();
+       if (ret) {
+               ret = CMD_ERROR;
+               goto end;
+       }
+
        /* Spawn a session daemon if needed */
        if (!opt_no_sessiond) {
                ret = launch_sessiond();
        /* Spawn a session daemon if needed */
        if (!opt_no_sessiond) {
                ret = launch_sessiond();
This page took 0.023291 seconds and 4 git commands to generate.