*/
#define NO_PERMS (-1U)
+/**
+ * Uninitialized UID/GID used for task/control files.
+ */
+#define NO_UID_GID (-1U)
+
/**
* Allocate new cgroup structure. This function itself does not create new
* control group in kernel, only new <tt>struct cgroup</tt> inside libcgroup!
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;
+ if (group == NO_UID_GID)
+ group = 0;
+ return chown(filename, owner, group);
+}
static int cg_chown_file(FTS *fts, FTSENT *ent, uid_t owner, gid_t group)
{
int ret = 0;
case FTS_DP:
case FTS_F:
case FTS_DEFAULT:
- ret = chown(filename, owner, group);
+ ret = cg_chown(filename, owner, group);
break;
}
if (ret < 0) {
error = ECGOTHER;
goto err;
}
- error = chown(path, cgroup->tasks_uid,
+ error = cg_chown(path, cgroup->tasks_uid,
cgroup->tasks_gid);
if (!error && cgroup->task_fperm != NO_PERMS)
error = cg_chmod_path(path, cgroup->task_fperm,
static void init_cgroup(struct cgroup *cgroup)
{
cgroup->task_fperm = cgroup->control_fperm = cgroup->control_dperm = NO_PERMS;
+ cgroup->control_gid = cgroup->control_uid = cgroup->tasks_gid =
+ cgroup->tasks_uid = NO_UID_GID;
}
void init_cgroup_table(struct cgroup *cgroups, size_t count)