Skip to contentSkip to conversation

syscalls/chdir: bugfix for syscalls/chdir/chdir01.c

PATCH New Xie Ziyao 2 participants 3 messages Mar 22, 2021 – Mar 30, 2021

lore
Share & tools
lore

Xie Ziyao

author
#0 lore raw

PATCH 1/1 syscalls/chdir: bugfix for syscalls/chdir/chdir01.c

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.

---
 testcases/kernel/syscalls/chdir/chdir01.c | 3 +++
 1 file changed, 3 insertions(+)
testcases/kernel/syscalls/chdir/chdir01.c +3 -0
index 60165a6cb..23cd455d6 100644
@@ -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

#1 lore raw

PATCH 1/1 syscalls/chdir: bugfix for syscalls/chdir/chdir01.c

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/[email protected]/