]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
bindings: adapt caller_is_in_ancestor()
authorChristian Brauner <cbrauner@suse.de>
Fri, 5 Aug 2016 22:45:07 +0000 (00:45 +0200)
committerChristian Brauner <cbrauner@suse.de>
Mon, 8 Aug 2016 18:00:40 +0000 (20:00 +0200)
Signed-off-by: Christian Brauner <cbrauner@suse.de>
bindings.c

index 63c3d1e733c0f188ebc57e47fbbff03692020f3c..7f15cade8581bb15ab606a85930f24702b0dca07 100644 (file)
@@ -1323,10 +1323,18 @@ static bool caller_is_in_ancestor(pid_t pid, const char *contrl, const char *cg,
        prune_init_slice(c2);
 
        /*
-        * callers pass in '/' for root cgroup, otherwise they pass
-        * in a cgroup without leading '/'
+        * callers pass in '/' or './' (openat()) for root cgroup, otherwise
+        * they pass in a cgroup without leading '/'
+        *
+        * The original line here was:
+        *      linecmp = *cg == '/' ? c2 : c2+1;
+        * TODO: I'm not sure why you'd want to increment when *cg != '/'?
+        *       Serge, do you know?
         */
-       linecmp = *cg == '/' ? c2 : c2+1;
+       if (*cg == '/' || !strncmp(cg, "./", 2))
+               linecmp = c2;
+       else
+               linecmp = c2 + 1;
        if (strncmp(linecmp, cg, strlen(linecmp)) != 0) {
                if (nextcg) {
                        *nextcg = get_next_cgroup_dir(linecmp, cg);