Otherwise it is weird to see that we are using a directory that we don't
have write access to. Better to fail immediately on the create command.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <urcu.h>
#include <lttng-sessiond-comm.h>
#include <lttngerr.h>
+#include <runas.h>
#include "hashtable.h"
#include "session.h"
new_session->uid = uid;
new_session->gid = gid;
+ ret = mkdir_recursive_run_as(new_session->path, S_IRWXU | S_IRWXG,
+ new_session->uid, new_session->gid);
+ if (ret < 0) {
+ if (ret != -EEXIST) {
+ ERR("Trace directory creation error");
+ ret = LTTCOMM_CREATE_FAIL;
+ goto error;
+ }
+ }
+
/* Add new session to the session list */
session_lock_list();
new_session->id = add_session_list(new_session);
$(top_srcdir)/liblttng-sessiond-comm/lttng-sessiond-comm.c
test_sessions_SOURCES = test_sessions.c $(UTILS) $(SESSIONS)
+test_sessions_LDADD = $(top_builddir)/librunas/librunas.la
test_kernel_data_trace_SOURCES = test_kernel_data_trace.c $(UTILS) $(KERN_DATA_TRACE)