Fix: streamline ret/errno of run_as()
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry.c
index f9ddd25a5928e197d15834446fa9710ec665a44b..35911e322f49175a29e58f0784b32c966ca7f7db 100644 (file)
@@ -572,6 +572,8 @@ int ust_registry_session_init(struct ust_registry_session **sessionp,
        session->long_alignment = long_alignment;
        session->byte_order = byte_order;
        session->metadata_fd = -1;
+       session->uid = euid;
+       session->gid = egid;
        strncpy(session->root_shm_path, root_shm_path,
                sizeof(session->root_shm_path));
        session->root_shm_path[sizeof(session->root_shm_path) - 1] = '\0';
@@ -597,9 +599,9 @@ int ust_registry_session_init(struct ust_registry_session **sessionp,
        }
        if (session->metadata_path[0]) {
                /* Create metadata file */
-               ret = open(session->metadata_path,
+               ret = run_as_open(session->metadata_path,
                        O_WRONLY | O_CREAT | O_EXCL,
-                       S_IRUSR | S_IWUSR);
+                       S_IRUSR | S_IWUSR, euid, egid);
                if (ret < 0) {
                        PERROR("Opening metadata file");
                        goto error;
@@ -675,7 +677,8 @@ void ust_registry_session_destroy(struct ust_registry_session *reg)
                if (ret) {
                        PERROR("close");
                }
-               ret = unlink(reg->metadata_path);
+               ret = run_as_unlink(reg->metadata_path,
+                               reg->uid, reg->gid);
                if (ret) {
                        PERROR("unlink");
                }
@@ -684,6 +687,7 @@ void ust_registry_session_destroy(struct ust_registry_session *reg)
                /*
                 * Try deleting the directory hierarchy.
                 */
-               (void) utils_recursive_rmdir(reg->root_shm_path);
+               (void) run_as_recursive_rmdir(reg->root_shm_path,
+                               reg->uid, reg->gid);
        }
 }
This page took 0.024987 seconds and 4 git commands to generate.