From: Christian Brauner Date: Sat, 7 Dec 2019 23:38:16 +0000 (+0100) Subject: cgroups/cgfsng: rework cgfsng_chown() X-Git-Tag: lxc-4.0.0~78^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c98bbf7106469d4577f6bca8843ddc4b9e6bcb81;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 db458c682..38513ca57 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; }