When cgroup_create_cgroup() is called with different control_fperm and
task_fperm, libcgroup first changes permissions of *all* files to match
the control_fperm, which includes the also the tasks file and it might
loose some permission bits. The tasks file is then modulated by
control_fperm, but because umask-style of control_fperm, it might get
lower permissions that users would expect.

Therefore 'tasks' file must be skipped when using control_fperm.

Signed-off-by: Jan Safranek <jsafr...@redhat.com>
---

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

diff --git a/src/api.c b/src/api.c
index 098d2e3..9c45c5b 100644
--- a/src/api.c
+++ b/src/api.c
@@ -240,8 +240,9 @@ int cg_chmod_file(FTS *fts, FTSENT *ent, mode_t dir_mode,
 }
 
 
-/*
- * TODO: Need to decide a better place to put this function.
+/**
+ * Changes permissions of all directories and control files (i.e. all
+ * files except 'tasks') in given path.
  */
 static int cg_chmod_recursive_controller(char *path, mode_t dir_mode,
                int dirm_change, mode_t file_mode, int filem_change,
@@ -273,11 +274,14 @@ static int cg_chmod_recursive_controller(char *path, 
mode_t dir_mode,
                        }
                        break;
                }
-               ret = cg_chmod_file(fts, ent, dir_mode, dirm_change,
-                       file_mode, filem_change, owner_is_umask);
-               if (ret) {
-                       last_errno = errno;
-                       final_ret = ECGOTHER;
+               if (strcmp(ent->fts_name, "tasks") != 0) {
+                       ret = cg_chmod_file(fts, ent, dir_mode, dirm_change,
+                                       file_mode, filem_change,
+                                       owner_is_umask);
+                       if (ret) {
+                               last_errno = errno;
+                               final_ret = ECGOTHER;
+                       }
                }
        }
        fts_close(fts);


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to