]> git.lttng.org Git - lttng-ust.git/commitdiff
Tests: Fix rundir not created in ust-basic-tracing
authorChristian Babeux <christian.babeux@efficios.com>
Wed, 19 Dec 2012 19:41:43 +0000 (14:41 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 19 Dec 2012 19:41:43 +0000 (14:41 -0500)
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/ust-basic-tracing/ust-basic-tracing.c

index 88260181d929f5e767f73788bda29fd1e1e2308d..18fb08789f637b58ac06b6b04acf84bf9cc2455e 100644 (file)
@@ -702,6 +702,8 @@ static void set_ulimit(void)
 int main(int argc, const char **argv)
 {
        const char *home_dir;
+       char home_rundir[PATH_MAX];
+       char *cmd = NULL;
        int ret, wait_shm_fd;
        struct sigaction act;
        mode_t old_umask = 0;
@@ -765,6 +767,21 @@ int main(int argc, const char **argv)
                strcpy(apps_sock_path, DEFAULT_GLOBAL_APPS_UNIX_SOCK);
                old_umask = umask(0);
        } else {
+               home_dir = (const char *) getenv("HOME");
+               if (!home_dir) {
+                       perror("getenv error");
+                       return -ENOENT;
+               }
+
+               snprintf(home_rundir, PATH_MAX,
+                        LTTNG_HOME_RUNDIR, home_dir);
+
+               ret = mkdir(home_rundir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+               if (ret && errno != EEXIST) {
+                       perror("mkdir");
+                       return -1;
+               }
+
                snprintf(local_apps_wait_shm_path, PATH_MAX,
                         DEFAULT_HOME_APPS_WAIT_SHM_PATH, getuid());
                wait_shm_fd = get_wait_shm(local_apps_wait_shm_path,
@@ -773,11 +790,6 @@ int main(int argc, const char **argv)
                        perror("local wait shm error");
                        return -1;
                }
-               home_dir = (const char *) getenv("HOME");
-               if (!home_dir) {
-                       perror("getenv error");
-                       return -ENOENT;
-               }
                snprintf(apps_sock_path, PATH_MAX,
                         DEFAULT_HOME_APPS_UNIX_SOCK, home_dir);
        }
@@ -869,5 +881,22 @@ end:
                return -1;
        }
 
+       if (geteuid()) {
+               printf("Removing %s directory\n", home_rundir);
+               ret = asprintf(&cmd, "rm -rf %s", home_rundir);
+               if (ret < 0) {
+                       printf("asprintf failed. Something is really wrong!\n");
+                       return -1;
+               }
+
+               /* Remove lttng run directory */
+               ret = system(cmd);
+               if (ret < 0) {
+                       printf("Unable to clean %s\n", home_rundir);
+                       return -1;
+               }
+       }
+
+
        return 0;
 }
This page took 0.02964 seconds and 4 git commands to generate.