Skip to contentSkip to conversation

chdir01: Skip nobody when problems on umask 0070

PATCH In review Petr Vorel 1 participant 2 messages Mar 31, 2021 – Jan 12, 2022

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 chdir01: Skip nobody when problems on umask 0070

FAT and exFAT from Samsung have EACCES for nobody on umask 0070.

---
 testcases/kernel/syscalls/chdir/chdir01.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/chdir/chdir01.c +13 -3
index 23cd455d6..57b92f3f8 100644
@@ -27,7 +27,7 @@
 #define LINK_NAME2 "symloop2"
 
 static char *workdir;
-static int skip_symlinks, skip_blocked;
+static int skip_symlinks, skip_blocked, skip_umask;
 static struct passwd *ltpuser;
 
 static struct test_case {
@@ -57,6 +57,11 @@ static void setup(void)
 	SAFE_CHDIR(workdir);
 
 	mode_t sys_umask = umask(0);
+
+	/* FAT and exFAT from Samsung have EACCES for nobody on umask 0070 */
+	if (sys_umask & S_IRWXG)
+		skip_umask = 1;
+
 	SAFE_MKDIR(DIR_NAME, 0755);
 	SAFE_MKDIR(BLOCKED_NAME, 0644);
 	umask(sys_umask);
@@ -118,8 +123,7 @@ static void run(unsigned int n)
 	check_result("root", tc->name, tc->root_ret, tc->root_err);
 
 	if (tc->nobody_err == EACCES && skip_blocked) {
-		tst_res(TCONF, "Skipping unprivileged permission test, "
-			"FS mangles dir mode");
+		tst_res(TCONF, "Skipping unprivileged permission test, FS mangles dir mode");
 		return;
 	}
 
@@ -127,6 +131,12 @@ static void run(unsigned int n)
 	SAFE_SETEUID(ltpuser->pw_uid);
 	TEST(chdir(tc->name));
 	SAFE_SETEUID(0);
+
+	if (skip_blocked && skip_umask && TST_ERR == EACCES) {
+		tst_res(TCONF, "Skipping unprivileged permission test, FS mangles dir mode on umask");
+		return;
+	}
+
 	check_result("nobody", tc->name, tc->nobody_ret, tc->nobody_err);
 }
 
Signature · 1 line
2.30.2
author
#1 lore raw

Hi,

FYI fixed by Cyril in e18dee565c ("chdir01: Fix on more restrictive umask") => rejecting this in patchwork.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp