On Thu 16-06-11 08:34:53, Jan Safranek wrote:
> 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.

Thanks for catching that. The solution looks one shot only, though.
Wouldn't something like function pointer parameter ((*exclude_filer)(const char 
*))
be better?

> 
> 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);
> 

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

------------------------------------------------------------------------------
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