This patch remove the permission change for newly created group.
Using mkdir and kernel api the new control group directory has permissions
755. cgconfigparser and cgcreate create new groups with permissions 775
and all files in these groups have permissions 777,
(It overrides the default permissions which was set by kernel api).
I don't see any reason for this change.
The patch changes the behavior of several function to preserve the permissions
which was set by kernel.

EXAMPLE:
OLD
# mkdir /cgroup/cpuacct/kernel
# cgcreate -g cpuacct:/libcg
# ll /cgroup/cpuacct/
total 0
--w--w--w-. 1 root root 0 Oct 20 07:56 cgroup.event_control
-r--r--r--. 1 root root 0 Oct 20 07:56 cgroup.procs
-r--r--r--. 1 root root 0 Oct 20 07:56 cpuacct.stat
-rw-r--r--. 1 root root 0 Oct 20 07:56 cpuacct.usage
-r--r--r--. 1 root root 0 Oct 20 07:56 cpuacct.usage_percpu
drwxr-xr-x. 2 root root 0 Oct 20 07:56 kernel
drwxrwxr-x. 2 root root 0 Oct 20 07:56 libcg
-rw-r--r--. 1 root root 0 Oct 20 07:56 notify_on_release
-rw-r--r--. 1 root root 0 Oct 20 07:56 release_agent
-rw-r--r--. 1 root root 0 Oct 20 07:56 tasks
# ll /cgroup/cpuacct/libcg/
total 0
-rwxrwxr-x. 1 root root 0 Oct 20 07:56 cgroup.event_control
-rwxrwxr-x. 1 root root 0 Oct 20 07:56 cgroup.procs
-rwxrwxr-x. 1 root root 0 Oct 20 07:56 cpuacct.stat
-rwxrwxr-x. 1 root root 0 Oct 20 07:56 cpuacct.usage
-rwxrwxr-x. 1 root root 0 Oct 20 07:56 cpuacct.usage_percpu
-rwxrwxr-x. 1 root root 0 Oct 20 07:56 notify_on_release
-rwxrwxr-x. 1 root root 0 Oct 20 07:56 tasks


NEW
# mkdir /cgroup/cpuacct/kernel
# cgcreate -g cpuacct:/libcg
# ll /cgroup/cpuacct/
total 0
--w--w--w-. 1 root root 0 Oct 20 06:45 cgroup.event_control
-r--r--r--. 1 root root 0 Oct 20 06:45 cgroup.procs
-r--r--r--. 1 root root 0 Oct 20 06:45 cpuacct.stat
-rw-r--r--. 1 root root 0 Oct 20 06:45 cpuacct.usage
-r--r--r--. 1 root root 0 Oct 20 06:45 cpuacct.usage_percpu
drwxr-xr-x. 2 root root 0 Oct 20 06:48 kernel
drwxr-xr-x. 2 root root 0 Oct 20 06:49 libcg
-rw-r--r--. 1 root root 0 Oct 20 06:45 notify_on_release
-rw-r--r--. 1 root root 0 Oct 20 06:45 release_agent
-rw-r--r--. 1 root root 0 Oct 20 06:45 tasks
# ll /cgroup/cpuacct/libcg/
total 0
--w--w--w-. 1 root root 0 Oct 20 06:49 cgroup.event_control
-r--r--r--. 1 root root 0 Oct 20 06:49 cgroup.procs
-r--r--r--. 1 root root 0 Oct 20 06:49 cpuacct.stat
-rw-r--r--. 1 root root 0 Oct 20 06:49 cpuacct.usage
-r--r--r--. 1 root root 0 Oct 20 06:49 cpuacct.usage_percpu
-rw-r--r--. 1 root root 0 Oct 20 06:49 notify_on_release
-rw-r--r--. 1 root root 0 Oct 20 06:49 tasks

Signed-off-by: Ivana Hutarova Varekova <[email protected]>
---

 src/api.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/api.c b/src/api.c
index b9a906f..2551a43 100644
--- a/src/api.c
+++ b/src/api.c
@@ -135,19 +135,11 @@ static int cg_chown_file(FTS *fts, FTSENT *ent, uid_t 
owner, gid_t group)
        case FTS_NS:
        case FTS_DNR:
        case FTS_DP:
-               ret = chown(filename, owner, group);
-               if (ret)
-                       goto fail_chown;
-               ret = chmod(filename, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
-                                       S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH);
-               break;
        case FTS_F:
        case FTS_DEFAULT:
                ret = chown(filename, owner, group);
                if (ret)
                        goto fail_chown;
-               ret = chmod(filename, S_IRUSR | S_IWUSR |  S_IRGRP |
-                                               S_IWGRP | S_IROTH);
                break;
        }
 fail_chown:
@@ -1046,7 +1038,8 @@ int cg_mkdir_p(const char *path)
                        i++;
                pos = real_path[i];
                real_path[i] = '\0';            /* Temporarily overwrite "/" */
-               ret = mkdir(real_path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+               ret = mkdir(real_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH
+                       | S_IXOTH);
                real_path[i] = pos;
                if (ret) {
                        switch (errno) {


------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to