From: Petr Vorel <pvorel@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] safe_macros.c: set umask to 0 within safe_mount
Date: Fri, 8 Mar 2024 10:16:35 +0100 [thread overview]
Message-ID: <20240308091635.GA261752@pevik> (raw)
In-Reply-To: <20240308083220.19332-1-wegao@suse.com>
Hi Wei, all,
> When system's default umask is 0077, this will trigger following issues:
> chdir01.c:100: TFAIL: nobody: chdir("subdir") returned unexpected value -1: EACCES (13)
> Suggested-by: Martin Doucha <mdoucha@suse.cz>
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> doc/C-Test-API.asciidoc | 4 +++-
> lib/safe_macros.c | 3 +++
> 2 files changed, 6 insertions(+), 1 deletion(-)
> diff --git a/doc/C-Test-API.asciidoc b/doc/C-Test-API.asciidoc
> index 08a76c403..81067b12b 100644
> --- a/doc/C-Test-API.asciidoc
> +++ b/doc/C-Test-API.asciidoc
> @@ -2460,7 +2460,9 @@ with 'open()' or 'creat()' etc, the mode specified as the last parameter *is
> not* the mode the file is created with. The mode depends on current 'umask()'
> settings which may clear some of the bits. If your test depends on specific
> file permissions you need either to change umask to 0 or 'chmod()' the file
> -afterwards or use 'SAFE_TOUCH()' that does the 'chmod()' for you.
> +afterwards or use 'SAFE_TOUCH()' that does the 'chmod()' for you. SAFE_MOUNT
s/SAFE_MOUNT/'SAFE_MOUNT()'/
> +also does similar action such as setting umask(0) and then restoring the
> +original value.
I'm not sure about the wording. Maybe:
Temporarily clearing umask with 'umask(0)' is done before mounting in
'SAFE_MOUNT()' and before creating a new subdir in the cgroup in 'cgroup_dir_mk()'.
(based on my patch
https://lore.kernel.org/ltp/20240307232511.228396-1-pvorel@suse.cz/).
It could be changed before merge.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> 2.2 access()
> ~~~~~~~~~~~~
> diff --git a/lib/safe_macros.c b/lib/safe_macros.c
> index 951e1b064..109268587 100644
> --- a/lib/safe_macros.c
> +++ b/lib/safe_macros.c
> @@ -913,7 +913,10 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
> * the kernel's NTFS driver doesn't have proper write support.
> */
> if (!filesystemtype || strcmp(filesystemtype, "ntfs")) {
> + mode_t old_umask = umask(0);
> +
> rval = mount(source, target, filesystemtype, mountflags, data);
> + umask(old_umask);
> if (!rval)
> return 0;
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-03-08 9:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 10:46 [LTP] [PATCH v1] chdir01.c: set umask to 0 within setup Wei Gao via ltp
2024-03-07 15:18 ` Martin Doucha
2024-03-07 21:33 ` Petr Vorel
2024-03-07 23:08 ` Petr Vorel
2024-03-07 23:21 ` Wei Gao via ltp
2024-03-08 9:31 ` Martin Doucha
2024-03-11 14:11 ` Petr Vorel
2024-03-08 8:32 ` [LTP] [PATCH v2] safe_macros.c: set umask to 0 within safe_mount Wei Gao via ltp
2024-03-08 9:16 ` Petr Vorel [this message]
2024-03-08 10:00 ` Martin Doucha
2024-03-15 10:31 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240308091635.GA261752@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=wegao@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.