From: Weng Meiling Date: Fri, 27 Sep 2013 05:27:30 +0000 (+0200) Subject: cgcreate: fix the wrong uid/gid set. X-Git-Tag: v0.41~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4399023a9d19129459a19e863070f03aa8150ac0;p=thirdparty%2Flibcgroup.git cgcreate: fix the wrong uid/gid set. When setting the cgconfig.conf as follow: mount { memory = /cgroup/memory; } group . { perm { task { gid = w00227741; uid = w00227741; fperm =755; } admin { gid = w00227741; uid = w00227741; fperm =755; dperm = 755; } } memory { } } and restart the cgconfig service. Then switch to the user w00227741 and cgcreate cgroup like this: # lscgroup memory:/ # cgcreate -g memory:test cgcreate: can't create cgroup test: Operation not permitted the command report the error, but the cgroup test has created: # lscgroup memory:/ memory:/test this patch fix the problem. Signed-off-by: Weng Meiling Acked-by: Ivana Hutarova Varekova --- diff --git a/src/api.c b/src/api.c index e5e1959f..d0eb10a4 100644 --- a/src/api.c +++ b/src/api.c @@ -119,9 +119,9 @@ static const char const *cgroup_ignored_tasks_files[] = { "tasks", NULL }; static int cg_chown(const char *filename, uid_t owner, gid_t group) { if (owner == NO_UID_GID) - owner = 0; + owner = getuid(); if (group == NO_UID_GID) - group = 0; + group = getgid(); return chown(filename, owner, group); } static int cg_chown_file(FTS *fts, FTSENT *ent, uid_t owner, gid_t group)