From: Christian Brauner Date: Sat, 7 Dec 2019 23:38:16 +0000 (+0100) Subject: cgroups/cgfsng: rework cgfsng_chown() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=48ee0f070a33b3ba93b09cc7a4353ff35b3828a5;p=thirdparty%2Flxc.git cgroups/cgfsng: rework cgfsng_chown() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index ec826c19e..0f130ecf6 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -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; }