]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
cgroup_fuse: rework cgfs_chmod_file()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 17 Mar 2020 09:18:05 +0000 (10:18 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 17 Mar 2020 09:18:05 +0000 (10:18 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/cgroup_fuse.c

index bebffc000ca55d66cdcb48346413164d7ee7f9c5..691808e3e97c74cc86ac56f00c45538b93e9bfca 100644 (file)
@@ -886,22 +886,17 @@ out:
 
 static bool cgfs_chmod_file(const char *controller, const char *file, mode_t mode)
 {
+       __do_free char *path = NULL;
        int cfd;
-       size_t len;
-       char *pathname;
 
        cfd = get_cgroup_fd_handle_named(controller);
        if (cfd < 0)
                return false;
 
-       /* Make sure we pass a relative path to *at() family of functions.
-        * . + /file + \0
-        */
-       len = strlen(file) + 2;
-       pathname = alloca(len);
-       snprintf(pathname, len, "%s%s", dot_or_empty(file), file);
-       if (fchmodat(cfd, pathname, mode, 0) < 0)
+       path = must_make_path_relative(file, NULL);
+       if (fchmodat(cfd, path, mode, 0) < 0)
                return false;
+
        return true;
 }