#include <common/consumer.h>
#include <common/consumer-timer.h>
#include <common/compat/poll.h>
+#include <common/compat/getenv.h>
#include <common/sessiond-comm/sessiond-comm.h>
#include <common/utils.h>
return;
}
- lttng_consumer_should_exit(ctx);
+ if (ctx) {
+ lttng_consumer_should_exit(ctx);
+ }
}
/*
}
break;
case 'c':
- snprintf(command_sock_path, PATH_MAX, "%s", optarg);
+ if (lttng_is_setuid_setgid()) {
+ WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
+ "-c, --consumerd-cmd-sock");
+ } else {
+ snprintf(command_sock_path, PATH_MAX, "%s", optarg);
+ }
break;
case 'e':
- snprintf(error_sock_path, PATH_MAX, "%s", optarg);
+ if (lttng_is_setuid_setgid()) {
+ WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
+ "-e, --consumerd-err-sock");
+ } else {
+ snprintf(error_sock_path, PATH_MAX, "%s", optarg);
+ }
break;
case 'd':
opt_daemon = 1;
break;
case 'g':
- tracing_group_name = optarg;
+ if (lttng_is_setuid_setgid()) {
+ WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
+ "-g, --group");
+ } else {
+ tracing_group_name = optarg;
+ }
break;
case 'h':
usage(stdout);
{
int ret = 0, retval = 0;
void *status;
+ struct lttng_consumer_local_data *tmp_ctx;
if (set_signal_handler()) {
retval = -1;
exit_health_pipe:
exit_init_data:
- lttng_consumer_destroy(ctx);
+ tmp_ctx = ctx;
+ ctx = NULL;
+ cmm_barrier(); /* Clear ctx for signal handler. */
+ lttng_consumer_destroy(tmp_ctx);
lttng_consumer_cleanup();
if (health_consumerd) {
exit_options:
exit_set_signal_handler:
+ /* Ensure all prior call_rcu are done. */
+ rcu_barrier();
+
if (!retval) {
exit(EXIT_SUCCESS);
} else {