[LTP] [PATCH v5 1/2] cgroup_core01.c: Set system default umaks to 0

Petr Vorel pvorel@suse.cz
Fri Mar 1 09:43:11 CET 2024


Hi Li,

> Hi Wei, Petr,

> Seems the problem Wei met is the default umask of 0077,
> any new files or directories that are created will have their
> permission bits modified by this umask.

> After looking though what you both discussed, I think maybe
> another better choice is to set the umask to '0000' temporarily
> before creating the directory, and then restoring the previous
> umask right after.

> All these operations are just put into cgroup_dir_mk function.

LGTM this approach, please send a patch.

> Something like this:

> --- a/lib/tst_cgroup.c
> +++ b/lib/tst_cgroup.c
> @@ -368,8 +368,11 @@ static void cgroup_dir_mk(const struct cgroup_dir
> *const parent,
>         new->ctrl_field = parent->ctrl_field;
>         new->we_created_it = 0;

> +       mode_t old_umask = umask(0000);
nit: umask(0) is the same right?

Kind regards,
Petr

> +
>         if (!mkdirat(parent->dir_fd, dir_name, 0777)) {
>                 new->we_created_it = 1;
> +               umask(old_umask);
>                 goto opendir;
>         }


More information about the ltp mailing list