};
/* command line options */
-char *opt_output_path;
+char *opt_output_path, *opt_working_directory;
static int opt_daemon, opt_background;
+int opt_group_output_by_session;
+int opt_group_output_by_host;
/*
* We need to wait for listener and live listener threads, as well as
{ "verbose", 0, 0, 'v', },
{ "config", 1, 0, 'f' },
{ "version", 0, 0, 'V' },
+ { "working-directory", 1, 0, 'w', },
+ { "group-output-by-session", 0, 0, 's', },
+ { "group-output-by-host", 0, 0, 'p', },
{ NULL, 0, 0, 0, },
};
}
}
break;
+ case 'w':
+ if (lttng_is_setuid_setgid()) {
+ WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
+ "-w, --working-directory");
+ } else {
+ ret = asprintf(&opt_working_directory, "%s", arg);
+ if (ret < 0) {
+ ret = -errno;
+ PERROR("asprintf working_directory");
+ goto end;
+ }
+ }
+ break;
+
case 'v':
/* Verbose level can increase using multiple -v */
if (arg) {
}
}
break;
+ case 's':
+ if (opt_group_output_by_host) {
+ ERR("Cannot set --group-output-by-session, --group-output-by-host already defined");
+ exit(EXIT_FAILURE);
+ }
+ opt_group_output_by_session = 1;
+ break;
+ case 'p':
+ if (opt_group_output_by_session) {
+ ERR("Cannot set --group-output-by-host, --group-output-by-session already defined");
+ exit(EXIT_FAILURE);
+ }
+ opt_group_output_by_host = 1;
+ break;
default:
/* Unknown option or other error.
* Error is printed by getopt, just return */
return ret;
}
+static void parse_env_options(void)
+{
+ char *value = NULL;
+
+ value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_WORKING_DIRECTORY_ENV);
+ if (value) {
+ opt_working_directory = value;
+ }
+}
+
static int set_options(int argc, char **argv)
{
int c, ret = 0, option_index = 0, retval = 0;
}
}
+ if (!opt_group_output_by_session && !opt_group_output_by_host) {
+ /* Group by host by default */
+ opt_group_output_by_host = 1;
+ }
+
exit:
free(optstring);
return retval;
switch (session->minor) {
case 1: /* LTTng sessiond 2.1. Allocates path_name and channel_name. */
ret = cmd_recv_stream_2_1(payload, &path_name,
- &channel_name);
+ &channel_name, session);
break;
case 2: /* LTTng sessiond 2.2. Allocates path_name and channel_name. */
default:
ret = cmd_recv_stream_2_2(payload, &path_name,
- &channel_name, &tracefile_size, &tracefile_count);
+ &channel_name, &tracefile_size, &tracefile_count,
+ session);
break;
}
if (ret < 0) {
int ret = 0, retval = 0;
void *status;
- /* Parse arguments */
+ /* Parse environment variables */
+ parse_env_options();
+
+ /*
+ * Parse arguments.
+ * Command line arguments overwrite environment.
+ */
progname = argv[0];
if (set_options(argc, argv)) {
retval = -1;
}
}
+
+ if (opt_working_directory) {
+ ret = utils_change_working_dir(opt_working_directory);
+ if (ret) {
+ ERR("Changing working directory");
+ goto exit_options;
+ }
+ }
+
/* Initialize thread health monitoring */
health_relayd = health_app_create(NR_HEALTH_RELAYD_TYPES);
if (!health_relayd) {