From 994fa64fa6931b256e76caef3d35a9caf1a3d2a6 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 6 May 2013 14:41:17 -0400 Subject: [PATCH] Fix: don't start the relayd with a wrong --output dir The -o, --output option never supported a relative path but still the relayd was able to start. This makes sure the relayd does not start without an absolute pathname. The help and man are also updated to document this behavior. Ticket #523 has been opened as a feature request to support relative path. Fixes #481 Acked-by: Julien Desfossez Signed-off-by: David Goulet --- doc/man/lttng-relayd.8 | 6 +++--- src/bin/lttng-relayd/main.c | 17 +++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/doc/man/lttng-relayd.8 b/doc/man/lttng-relayd.8 index cd1aa7845..44631b1b2 100644 --- a/doc/man/lttng-relayd.8 +++ b/doc/man/lttng-relayd.8 @@ -51,13 +51,13 @@ There is three debugging level which will print on stderr. Maximum verbosity is Start as a daemon .TP .BR "-C, --control-port" -Control port URI (tcp://0.0.0.0:5342 is the default) +Control port URL (tcp://0.0.0.0:5342 is the default) .TP .BR "-D, --data-port" -Data port URI (tcp://0.0.0.0:5343 is the default) +Data port URL (tcp://0.0.0.0:5343 is the default) .TP .BR "-o, --output" -Output base directory (~/lttng-traces is the default) +Output base directory. Must use an absolute path (~/lttng-traces is the default) .TP .BR "-V, --version" Show version number diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 71c9f2b49..3b9f6708a 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -105,12 +105,12 @@ static void usage(void) { fprintf(stderr, "Usage: %s OPTIONS\n\nOptions:\n", progname); - fprintf(stderr, " -h, --help Display this usage.\n"); - fprintf(stderr, " -d, --daemonize Start as a daemon.\n"); - fprintf(stderr, " -C, --control-port Control port listening (URI)\n"); - fprintf(stderr, " -D, --data-port Data port listening (URI)\n"); - fprintf(stderr, " -o, --output Output path for traces (PATH)\n"); - fprintf(stderr, " -v, --verbose Verbose mode. Activate DBG() macro.\n"); + fprintf(stderr, " -h, --help Display this usage.\n"); + fprintf(stderr, " -d, --daemonize Start as a daemon.\n"); + fprintf(stderr, " -C, --control-port URL Control port listening.\n"); + fprintf(stderr, " -D, --data-port URL Data port listening.\n"); + fprintf(stderr, " -o, --output PATH Output path for traces. Must use an absolute path.\n"); + fprintf(stderr, " -v, --verbose Verbose mode. Activate DBG() macro.\n"); } static @@ -2071,6 +2071,11 @@ int main(int argc, char **argv) /* Try to create directory if -o, --output is specified. */ if (opt_output_path) { + if (*opt_output_path != '/') { + ERR("Please specify an absolute path for -o, --output PATH"); + goto exit; + } + ret = utils_mkdir_recursive(opt_output_path, S_IRWXU | S_IRWXG); if (ret < 0) { ERR("Unable to create %s", opt_output_path); -- 2.34.1