Skip to contentSkip to conversation

syscalls/chdir01: Add umask before mkdir

PATCH New Zhao Gongyi 2 participants 2 messages Mar 17, 2021 – Mar 30, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/chdir01: Add umask before mkdir

When uid is nobody, umask is not 022, the test process might has not permmission to access the file which created by SAFE_MKDIR with mode 0755.

---
 testcases/kernel/syscalls/chdir/chdir01.c | 9 +++++++++
 1 file changed, 9 insertions(+)
testcases/kernel/syscalls/chdir/chdir01.c +9 -0
index 60165a6cb..a378b260c 100644
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include <pwd.h>
 
@@ -55,6 +56,14 @@ static void setup(void)
 	sprintf(workdir, "%s/%s", cwd, MNTPOINT);
 	free(cwd);
 	SAFE_CHDIR(workdir);
+
+	/*
+	 * When uid is nobody, umask is not 022, the test process might
+	 * has not permmission to access the file which created by SAFE_MKDIR
+	 * with mode 0755.
+	 */
+	umask(022);
+
 	SAFE_MKDIR(DIR_NAME, 0755);
 	SAFE_MKDIR(BLOCKED_NAME, 0644);
 

--
2.17.1

#1 lore raw

PATCH 1/1 syscalls/chdir01: Add umask before mkdir

Quoted 1 line

When uid is nobody, umask is not 022, the test process might

Not sure if I understand "When uid is nobody, umask is not 022", umask setup depends usually on the system. I wonder which system has different setup for nobody.

BTW later was posted another solution, see my comments there.

Kind regards,
Petr

[2] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

Quoted 2 lines

has not permmission to access the file which created by SAFE_MKDIR with mode 0755.