]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: fix fallback logic when attaching to cgroups
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 4 Feb 2021 14:01:09 +0000 (15:01 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 4 Feb 2021 14:59:53 +0000 (15:59 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index d30c0d7f58b9fa79212e4098eab304d29ab8dbe9..03b29338da579d3abb3d0eb4fed98cd374fd9460 100644 (file)
@@ -1636,9 +1636,14 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
                 * enough.
                 */
                ret = cgroup_attach(conf, name, lxcpath, pid);
-               if (ret == -ENOCGROUP2) {
+               if (ret) {
                        call_cleaner(cgroup_exit) struct cgroup_ops *cgroup_ops = NULL;
 
+                       if (ret != -ENOCGROUP2) {
+                               SYSERROR("Failed to attach cgroup");
+                               goto on_error;
+                       }
+
                        cgroup_ops = cgroup_init(conf);
                        if (!cgroup_ops)
                                goto on_error;
@@ -1646,6 +1651,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
                        if (!cgroup_ops->attach(cgroup_ops, conf, name, lxcpath, pid))
                                goto on_error;
                }
+
                TRACE("Moved intermediate process %d into container's cgroups", pid);
        }