]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfsng: fix lxc.pivot directory creation
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 9 Oct 2018 22:02:46 +0000 (00:02 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 9 Oct 2018 22:02:46 +0000 (00:02 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 71dfe72e6f5add916c0bafe614f59982dbcb4283..cc8bf8f2b212044b8bc8e7ed25b2b09ab1fec47d 100644 (file)
@@ -1152,6 +1152,7 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
 
        for (int i = 0; ops->hierarchies[i]; i++) {
                int ret;
+               char *chop;
                struct hierarchy *h = ops->hierarchies[i];
 
                if (!h->monitor_full_path)
@@ -1169,10 +1170,17 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
                                                    PIVOT_CGROUP,
                                                    "cgroup.procs", NULL);
 
+               chop = strrchr(pivot_path, '/');
+               if (chop)
+                       *chop = '\0';
+
                ret = mkdir_p(pivot_path, 0755);
                if (ret < 0 && errno != EEXIST)
                        goto next;
 
+               if (chop)
+                       *chop = '/';
+
                /* Move ourselves into the pivot cgroup to delete our own
                 * cgroup.
                 */