Move hash table to common/ directory
[lttng-tools.git] / lttng-sessiond / ust-app.c
index 77dcc71a6fee77bbcc28d1298eb90355566fb630..12e9572455d8385b3cc406fce5be8bef67a4357e 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <runas.h>
 
 #include <urcu/compiler.h>
 #include <lttngerr.h>
 #include <lttng-share.h>
+#include <runas.h>
 
-#include "hashtable.h"
+#include "../common/hashtable.h"
 #include "ust-app.h"
 #include "ust-consumer.h"
 #include "ust-ctl.h"
@@ -1167,7 +1169,6 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess,
                char *pathname, struct ust_app *app)
 {
        int ret = 0;
-       mode_t old_umask;
 
        if (ua_sess->metadata == NULL) {
                /* Allocate UST metadata */
@@ -1193,18 +1194,12 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess,
                        goto error;
                }
 
-               old_umask = umask(0);
-               ret = mkdir(ua_sess->path, S_IRWXU | S_IRWXG);
+               ret = mkdir_run_as(ua_sess->path, S_IRWXU | S_IRWXG,
+                               ua_sess->uid, ua_sess->gid);
                if (ret < 0) {
                        PERROR("mkdir UST metadata");
                        goto error;
                }
-               ret = chown(ua_sess->path, ua_sess->uid, ua_sess->gid);
-               if (ret < 0) {
-                       ERR("Unable to change owner of %s", ua_sess->path);
-                       perror("chown");
-               }
-               umask(old_umask);
 
                ret = snprintf(ua_sess->metadata->pathname, PATH_MAX,
                                "%s/metadata", ua_sess->path);
This page took 0.024853 seconds and 4 git commands to generate.