public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Li Wang <liwang@redhat.com>, Cyril Hrubis <chrubis@suse.cz>,
	Martin Doucha <martin.doucha@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] tst_test.c: Set system default umaks to 0022
Date: Wed, 21 Feb 2024 17:19:07 +0100	[thread overview]
Message-ID: <20240221161907.GA1266903@pevik> (raw)
In-Reply-To: <ZdW1UDq17nHx0eE2@wegao>

Hi all,

> On Tue, Feb 20, 2024 at 10:18:37AM +0100, Petr Vorel wrote:
> > Hi Wei,

> > >  	char *tdebug_env = getenv("LTP_ENABLE_DEBUG");

> > > +	umask(0022);

> > I don't think this is a good idea. Changing umask() in the library can influent
> > tests. Could you please instead add umask(0) (to reset umask) on the tests which
> > need it? The way it's done in open07.c.

First I thought that modifying umask (either with umask(0022) or just reset with
umask(0)) is not a good idea, but now I'm not sure:

1) We have quite a few tests, which will needs it:
NEW API tests:
$ git grep '^\s*umask(0' $(git grep -l tst_test.h) | wc -l
15

All tests:
$ git grep '^\s*umask(0' testcases/ | wc -l
34

And for sure some other, which will fail when too restrictive umask is set.

Wouldn't be better to have it in the library? Hopefully fewer tests would be
influenced this setup (and would need to set different umask()).

> cgroup_core01.c and statx07.c can use umask(0) in tests and i have updated the patch.

> But chdir01 will still failed on vfat and exfat. Like following error msg:
> chdir01.c:100: TFAIL: nobody: chdir("subdir") returned unexpected value -1: EACCES (13)

FYI test fails on vfat and ntfs when umask is 0077 (because override file and
directory permissions) (other filesystems are ok).

> The reason is umask(0) should set before mount /dev/loop0 to /tmp/xxx/mntpoint, otherwise you 
> have no chance modify permission of file. What's your suggestion?

> susetest:/tmp/LTP_chd5JtblL/mntpoint # mount | grep loop0
> /dev/loop0 on /tmp/LTP_chd5JtblL/mntpoint type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
> /dev/loop0 on /var/tmp/LTP_chd5JtblL/mntpoint type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

2) tests, which set .mount_device = 1 and have more restrictive umask will not
work. Workaround would be to not use it and mount manually in the setup().
Or, reset umask with umask(0).

WDYT?

Kind regards,
Petr

> susetest:/tmp/LTP_chd5JtblL # chmod 777 mntpoint <<<< 
> susetest:/tmp/LTP_chd5JtblL # ll
> total 307216
> drwx------ 4 root root     16384 Dec 31  1969 mntpoint  <<<<<<<< group and other has no any permission even try chmod
> -rw------- 1 root root 314572800 Feb 19 04:51 test_dev.img

> susetest:/tmp/LTP_chd5JtblL/mntpoint # touch aa
> susetest:/tmp/LTP_chd5JtblL/mntpoint # ll
> total 16
> -rwx------ 1 root root    0a
> drwx------ 2 root root 8192 Feb 19 04:50 keep_out
> drwx------ 2 root root 8192 Feb 19 04:50 subdir
> -rwx------ 1 root root    0 Feb 19 04:50 testfile <<<<<<

> Thanks.


> > Kind regards,
> > Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-02-21 16:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04  0:26 [LTP] [PATCH v1] cgroup_core01.c: Set umask before create directory Wei Gao via ltp
2024-02-12 11:54 ` Andrea Cervesato via ltp
2024-02-19 13:48 ` [LTP] [PATCH v2] tst_test.c: Set system default umaks to 0022 Wei Gao via ltp
2024-02-20  9:18   ` Petr Vorel
2024-02-21  8:33     ` Wei Gao via ltp
2024-02-21 16:19       ` Petr Vorel [this message]
2024-02-22 13:53         ` Wei Gao via ltp
2024-02-21  7:16   ` [LTP] [PATCH v3 0/2] " Wei Gao via ltp
2024-02-21  7:16     ` [LTP] [PATCH v3 1/2] cgroup_core01.c: " Wei Gao via ltp
2024-02-21  7:16     ` [LTP] [PATCH v3 2/2] statx07.c: set umask " Wei Gao via ltp
2024-02-21  7:32       ` Petr Vorel
2024-02-21  8:42     ` [LTP] [PATCH v3 0/2] Set system default umaks to 0 Wei Gao via ltp
2024-02-21  8:42       ` [LTP] [PATCH v4 1/2] cgroup_core01.c: " Wei Gao via ltp
2024-02-21  8:42       ` [LTP] [PATCH v4 2/2] statx07.c: set umask " Wei Gao via ltp
2024-02-22  3:10       ` [LTP] [PATCH v5 0/2] Set system default umaks " Wei Gao via ltp
2024-02-22  3:10         ` [LTP] [PATCH v5 1/2] cgroup_core01.c: " Wei Gao via ltp
2024-03-01  7:26           ` Li Wang
2024-03-01  8:43             ` Petr Vorel
2024-03-01 10:07               ` Li Wang
2024-02-22  3:10         ` [LTP] [PATCH v5 2/2] statx07.c: set umask " Wei Gao via ltp
2024-03-01  7:28           ` Li Wang
2024-03-01 11:52             ` 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=20240221161907.GA1266903@pevik \
    --to=pvorel@suse.cz \
    --cc=chrubis@suse.cz \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    --cc=martin.doucha@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox