X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fcreate.c;h=fe659d08747394de4d62cd2ea7da8c030513ef26;hb=ec64e6c1a008526fa9854cebac13e5e6ed308c26;hp=08b12a46eee2b95e6093f738a97a5b0f01936551;hpb=04965770958ef684f0e40d948264dc3283b4bcdc;p=lttng-tools.git diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 08b12a46e..fe659d087 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -52,9 +52,9 @@ static struct poptOption long_options[] = { {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL}, {"output", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL}, {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, - {"set-uri", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0}, - {"ctrl-uri", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0}, - {"data-uri", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0}, + {"set-url", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0}, + {"ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0}, + {"data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0}, {"no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0}, {"disable-consumer", 0, POPT_ARG_VAL, &opt_disable_consumer, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0} @@ -112,7 +112,7 @@ static void usage(FILE *ofp) fprintf(ofp, " TCP for both control (PORT1) and data port (PORT2).\n"); fprintf(ofp, " The default ports are respectively 5342 and 5343.\n"); fprintf(ofp, "\n"); - fprintf(ofp, " > tcp[4|6]://...\n"); + fprintf(ofp, " > tcp[6]://...\n"); fprintf(ofp, " Can only be used with -C and -D together\n"); fprintf(ofp, "\n"); fprintf(ofp, "NOTE: IPv6 address MUST be enclosed in brackets '[]' (rfc2732)\n"); @@ -254,7 +254,7 @@ static int create_session(void) int ret; char *session_name = NULL, *traces_path = NULL, *alloc_path = NULL; char *alloc_url = NULL, *url = NULL, datetime[16]; - char session_name_date[NAME_MAX], *print_str_url = NULL; + char session_name_date[NAME_MAX + 17], *print_str_url = NULL; time_t rawtime; struct tm *timeinfo; @@ -274,6 +274,12 @@ static int create_session(void) session_name = session_name_date; DBG("Auto session name set to %s", session_name_date); } else { + if (strlen(opt_session_name) > NAME_MAX) { + ERR("Session name too long. Length must be lower or equal to %d", + NAME_MAX); + ret = LTTNG_ERR_SESSION_FAIL; + goto error; + } if (strncmp(opt_session_name, DEFAULT_SESSION_NAME, strlen(DEFAULT_SESSION_NAME)) == 0 && strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME)) { @@ -350,9 +356,11 @@ static int create_session(void) } MSG("Session %s created.", session_name); - MSG("Traces will be written in %s", print_str_url); + if (print_str_url) { + MSG("Traces will be written in %s", print_str_url); + } - if (opt_ctrl_url || opt_data_url) { + if (opt_ctrl_url && opt_data_url) { /* Setting up control URI (-C or/and -D opt) */ ret = set_consumer_url(session_name, opt_ctrl_url, opt_data_url); if (ret < 0) { @@ -363,6 +371,11 @@ static int create_session(void) if (ret < 0) { goto error; } + } else if ((!opt_ctrl_url && opt_data_url) || + (opt_ctrl_url && !opt_data_url)) { + ERR("You need both control and data URL."); + ret = CMD_ERROR; + goto error; } if (opt_disable_consumer && !opt_no_consumer) {