]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Fix commit 17a40d649c9dfc539b18784c644d8a45916ecd68
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 15 Dec 2010 17:20:42 +0000 (22:50 +0530)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 15 Dec 2010 17:20:42 +0000 (22:50 +0530)
Commit 17a40d649c9dfc539b18784c644d8a45916ecd68 had a patch, that I failed
to push as a part of that commit (stg ref went missing). Fix it correctly
this time

Signed-off-by: Ciju Rajan K <ciju@linux.vnet.ibm.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
src/api.c

index 859190a97b670dd515b6e3116aa6299d033203d4..fa4f02e4b99466cbc0279ea188cfbdee89bdbae8 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -1991,6 +1991,8 @@ static int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgroup,
        char *ctrl_file = NULL;
        char *ctrl_value = NULL;
        char *d_name = NULL;
+       char *tmp_path = NULL;
+       int tmp_len = 0;
        char path[FILENAME_MAX+1];
        char *buffer = NULL;
        int error = 0;
@@ -2019,8 +2021,33 @@ static int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgroup,
                goto fill_error;
        }
 
-       cgroup->control_uid = stat_buffer.st_uid;
-       cgroup->control_gid = stat_buffer.st_gid;
+       /*
+        * We have already stored the tasks_uid & tasks_gid.
+        * This check is to avoid the overwriting of the values
+        * stored in control_uid & cotrol_gid. tasks file will
+        * have the uid and gid of the user who is capable of
+        * putting a task to this cgroup. control_uid and control_gid
+        * is meant for the users who are capable of managing the
+        * cgroup shares.
+        *
+        * The strstr() function will return the pointer to the
+        * beginning of the sub string "/tasks".
+        */
+       tmp_len = strlen(path) - strlen("/tasks");
+
+       /*
+        * tmp_path would be pointing to the last six characters
+        */
+       tmp_path = (char *)path + tmp_len;
+
+       /*
+        * Checking to see, if this is actually a 'tasks' file
+        * We need to compare the last 6 bytes
+        */
+       if (strcmp(tmp_path, "/tasks")){
+               cgroup->control_uid = stat_buffer.st_uid;
+               cgroup->control_gid = stat_buffer.st_gid;
+       }
 
        ctrl_name = strtok_r(d_name, ".", &buffer);