]> git.proxmox.com Git - mirror_lxc.git/commitdiff
cgroups/cgfsng: rework cgfsng_chown()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 7 Dec 2019 23:38:16 +0000 (00:38 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 7 Dec 2019 23:38:16 +0000 (00:38 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index db458c6820e4d6549b0462c5f4e5130e738ab507..38513ca5753aee07c3dadc982dd19fe25946b972 100644 (file)
@@ -1621,26 +1621,32 @@ static int chown_cgroup_wrapper(void *data)
 }
 
 __cgfsng_ops static bool cgfsng_chown(struct cgroup_ops *ops,
-                                       struct lxc_conf *conf)
+                                     struct lxc_conf *conf)
 {
        struct generic_userns_exec_data wrap;
 
-       if (lxc_list_empty(&conf->id_map))
-               return true;
+       if (!ops)
+               return ret_set_errno(false, ENOENT);
 
        if (!ops->hierarchies)
                return true;
 
+       if (!ops->container_cgroup)
+               return ret_set_errno(false, ENOENT);
+
+       if (!conf)
+               return ret_set_errno(false, EINVAL);
+
+       if (lxc_list_empty(&conf->id_map))
+               return true;
+
        wrap.origuid = geteuid();
        wrap.path = NULL;
        wrap.hierarchies = ops->hierarchies;
        wrap.conf = conf;
 
-       if (userns_exec_1(conf, chown_cgroup_wrapper, &wrap,
-                         "chown_cgroup_wrapper") < 0) {
-               ERROR("Error requesting cgroup chown in new user namespace");
-               return false;
-       }
+       if (userns_exec_1(conf, chown_cgroup_wrapper, &wrap, "chown_cgroup_wrapper") < 0)
+               return log_error_errno(false, errno, "Error requesting cgroup chown in new user namespace");
 
        return true;
 }