From: Wei Gao via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v1] chdir01.c: set umask to 0 within setup
Date: Wed, 6 Mar 2024 05:46:09 -0500 [thread overview]
Message-ID: <20240306104609.17141-1-wegao@suse.com> (raw)
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)
Signed-off-by: Wei Gao <wegao@suse.com>
---
testcases/kernel/syscalls/chdir/chdir01.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/chdir/chdir01.c b/testcases/kernel/syscalls/chdir/chdir01.c
index d50a8f50c..97a707199 100644
--- a/testcases/kernel/syscalls/chdir/chdir01.c
+++ b/testcases/kernel/syscalls/chdir/chdir01.c
@@ -56,12 +56,15 @@ static struct test_case {
static void setup(void)
{
+ mode_t old_umask = umask(0);
+
+ SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL);
+ SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, 0);
+
char *cwd;
int fd;
struct stat statbuf;
- umask(0);
-
cwd = SAFE_GETCWD(NULL, 0);
workdir = SAFE_MALLOC(strlen(cwd) + strlen(MNTPOINT) + 2);
sprintf(workdir, "%s/%s", cwd, MNTPOINT);
@@ -89,6 +92,7 @@ static void setup(void)
if (!ltpuser)
ltpuser = SAFE_GETPWNAM(TESTUSER);
+ umask(old_umask);
}
static void check_result(const char *user, const char *name, int retval,
@@ -146,13 +150,14 @@ static void cleanup(void)
{
SAFE_CHDIR("..");
free(workdir);
+ SAFE_UMOUNT(MNTPOINT);
}
static struct tst_test test = {
.needs_root = 1,
- .mount_device = 1,
.mntpoint = MNTPOINT,
.all_filesystems = 1,
+ .needs_device = 1,
.test = run,
.tcnt = ARRAY_SIZE(testcase_list),
.setup = setup,
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2024-03-06 10:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 10:46 Wei Gao via ltp [this message]
2024-03-07 15:18 ` [LTP] [PATCH v1] chdir01.c: set umask to 0 within setup 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
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=20240306104609.17141-1-wegao@suse.com \
--to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).