All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/chdir: bugfix for syscalls/chdir/chdir01.c
@ 2021-03-22  9:15 Xie Ziyao
  2021-03-30 13:04 ` Petr Vorel
  2021-03-30 16:55 ` Petr Vorel
  0 siblings, 2 replies; 3+ messages in thread
From: Xie Ziyao @ 2021-03-22  9:15 UTC (permalink / raw)
  To: ltp

Add umask(0) before SAFE_MKDIR(DIR_NAME, 0755) to prevent the unexpected case failure when the system umask is set to some values, such as 0077.

Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
 testcases/kernel/syscalls/chdir/chdir01.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/testcases/kernel/syscalls/chdir/chdir01.c b/testcases/kernel/syscalls/chdir/chdir01.c
index 60165a6cb..23cd455d6 100644
--- a/testcases/kernel/syscalls/chdir/chdir01.c
+++ b/testcases/kernel/syscalls/chdir/chdir01.c
@@ -55,8 +55,11 @@ static void setup(void)
 	sprintf(workdir, "%s/%s", cwd, MNTPOINT);
 	free(cwd);
 	SAFE_CHDIR(workdir);
+
+	mode_t sys_umask = umask(0);
 	SAFE_MKDIR(DIR_NAME, 0755);
 	SAFE_MKDIR(BLOCKED_NAME, 0644);
+	umask(sys_umask);

 	/* FAT and NTFS override file and directory permissions */
 	SAFE_STAT(BLOCKED_NAME, &statbuf);
--
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] syscalls/chdir: bugfix for syscalls/chdir/chdir01.c
  2021-03-22  9:15 [LTP] [PATCH] syscalls/chdir: bugfix for syscalls/chdir/chdir01.c Xie Ziyao
@ 2021-03-30 13:04 ` Petr Vorel
  2021-03-30 16:55 ` Petr Vorel
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-03-30 13:04 UTC (permalink / raw)
  To: ltp

Hi,

NOTE, there was already another solution posted before [1].

I slightly prefer this one as it reverts back previous setup, which is a good
habit, but no hard feeling because it's probably not needed in this case.

I wonder what I'm missing, because although I set system umask 222 (in
/etc/pam.d/common-session and verified it's working) I was not able to trigger
any problem.

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/patch/20210317072652.26974-1-zhaogongyi@huawei.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] syscalls/chdir: bugfix for syscalls/chdir/chdir01.c
  2021-03-22  9:15 [LTP] [PATCH] syscalls/chdir: bugfix for syscalls/chdir/chdir01.c Xie Ziyao
  2021-03-30 13:04 ` Petr Vorel
@ 2021-03-30 16:55 ` Petr Vorel
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-03-30 16:55 UTC (permalink / raw)
  To: ltp

Hi Ziyao,

thanks, merged!

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-30 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22  9:15 [LTP] [PATCH] syscalls/chdir: bugfix for syscalls/chdir/chdir01.c Xie Ziyao
2021-03-30 13:04 ` Petr Vorel
2021-03-30 16:55 ` Petr Vorel

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.