Create output directory at session creation command
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 21 Dec 2011 02:46:48 +0000 (21:46 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 21 Dec 2011 02:46:48 +0000 (21:46 -0500)
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>
lttng-sessiond/session.c
tests/Makefile.am

index 7a580fdd9b07cfb6ff9b31f4eb5b529f306fc4d4..246b60903f86164e9da44ff5659d3444c4c13c2c 100644 (file)
 #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"
@@ -217,6 +220,16 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid)
        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);
index f64ca5291ac0efdd7fe18ed45ccf13c49b0b7957..382a772250389d9d554905a849fd14bf80a43c58 100644 (file)
@@ -14,6 +14,7 @@ LIBLTTNG=$(top_srcdir)/liblttngctl/lttngctl.c \
                 $(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)
 
This page took 0.030739 seconds and 4 git commands to generate.