From 3f441bc7bec47694a5159df4ddfc1d1093aa8dec Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Wed, 20 Apr 2016 11:25:47 -0500 Subject: [PATCH] fix cg_access() for controller directories The previous patch actually didn't handle those, but only /cgroup itself. Closes #107 Signed-off-by: Serge Hallyn --- bindings.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bindings.c b/bindings.c index 3f32816..5393cdc 100644 --- a/bindings.c +++ b/bindings.c @@ -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); -- 2.39.5