]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
fix cg_access() for controller directories
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 20 Apr 2016 16:25:47 +0000 (11:25 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 20 Apr 2016 16:27:01 +0000 (11:27 -0500)
The previous patch actually didn't handle those, but only
/cgroup itself.

Closes #107

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
bindings.c

index 3f328169e6c752717f96f707c43f7b597284a39b..5393cdc98d9507e7e0478bd9cbf7d80f8f0b69ea 100644 (file)
@@ -1793,7 +1793,9 @@ int cg_access(const char *path, int mode)
        cgroup = find_cgroup_in_path(path);
        if (!cgroup) {
                // access("/sys/fs/cgroup/systemd", mode) - rx allowed, w not
-               return mode & W_OK == 0 ? 0 : -EACCES;
+               if ((mode & W_OK) == 0)
+                       return 0;
+               return -EACCES;
        }
 
        get_cgdir_and_path(cgroup, &cgdir, &last);
@@ -1807,7 +1809,10 @@ int cg_access(const char *path, int mode)
 
        k = cgfs_get_key(controller, path1, path2);
        if (!k) {
-               ret = -EINVAL;
+               if ((mode & W_OK) == 0)
+                       ret = 0;
+               else
+                       ret = -EACCES;
                goto out;
        }
        free_key(k);