Skip to contentSkip to conversation

fchmod05: fix to the group ownership and the effective user

PATCH In review Wei Yongjun 2 participants 2 messages Jun 11, 2009 – Jun 15, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fchmod05: fix to the group ownership and the effective user

This patch fixed the modify of the group ownership before do dir chmod and fixed the effective user when do cleanup. Those problems cause the test failed with the following error message:

  fchmod05    1  FAIL  :  testdir: Incorrect modes 043777, Expected 0777
  fchmod05    0  WARN  :  tst_rmdir(): rmobj(/tmp/fchUout8n) failed: \

remove(/tmp/fchUout8n) failed; errno=1: Operation not permitted

---
 testcases/kernel/syscalls/fchmod/fchmod05.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/fchmod/fchmod05.c +8 -5
index 3573f65..5226858 100644
@@ -154,10 +154,10 @@ int main(int ac, char **av)
 			if ((PERMS & ~S_ISGID) != dir_mode) {
 				tst_resm(TFAIL, "%s: Incorrect modes 0%03o, "
 					 "Expected 0%03o",
-					 TESTDIR, PERMS, MODE_RWX);
+					 TESTDIR, dir_mode, PERMS & ~S_ISGID);
 			} else {
 				tst_resm(TPASS, "Functionality of fchmod(%d, "
-					 "%#o) successful", fd, PERMS);
+					 "%#o) successful", fd, PERMS & ~S_ISGID);
 			}
 		} else {
 			tst_resm(TPASS, "call succeeded");
@@ -218,12 +218,12 @@ void setup()
 		tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", TESTDIR);
 	}
 
-	if (chown(TESTDIR, nobody_u->pw_uid, bin_group->gr_gid) == -1)
+	if (chown(TESTDIR, nobody_u->pw_uid, nobody_u->pw_gid) == -1)
 		tst_brkm(TBROK, cleanup, "Couldn't change owner of testdir: %s",
 				strerror(errno));
 
-	/* change to nobody:nobody */
-	if (setegid(nobody_u->pw_gid) == -1 || seteuid(nobody_u->pw_uid) == -1)
+	/* change to nobody:bin */
+	if (setegid(bin_group->gr_gid) == -1 || seteuid(nobody_u->pw_uid) == -1)
 		tst_brkm(TBROK, cleanup, "Couldn't switch to nobody:nobody: %s",
 				strerror(errno));
 
@@ -258,6 +258,9 @@ void cleanup()
 			 TESTDIR, errno, strerror(errno));
 	}
 
+	setegid(0);
+	seteuid(0);
+
 	/* Remove tmp dir and all files in it */
 	tst_rmdir();
 
Signature · 16 lines
1.6.0.2.530.g67faa





------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw
Quoted 10 lines · Wei Yongjun

This patch fixed the modify of the group ownership before do dir chmod and fixed the effective user when do cleanup. Those problems cause the test failed with the following error message:

  fchmod05    1  FAIL  :  testdir: Incorrect modes 043777, Expected 0777
  fchmod05    0  WARN  :  tst_rmdir(): rmobj(/tmp/fchUout8n) failed: \

remove(/tmp/fchUout8n) failed; errno=1: Operation not permitted

Thanks.

Regards--
Subrata

Quoted 38 lines
---
 testcases/kernel/syscalls/fchmod/fchmod05.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/fchmod/fchmod05.c +5 -5
index 3573f65..5226858 100644
@@ -154,10 +154,10 @@ int main(int ac, char **av)
 			if ((PERMS & ~S_ISGID) != dir_mode) {
 				tst_resm(TFAIL, "%s: Incorrect modes 0%03o, "
 					 "Expected 0%03o",
-					 TESTDIR, PERMS, MODE_RWX);
+					 TESTDIR, dir_mode, PERMS & ~S_ISGID);
 			} else {
 				tst_resm(TPASS, "Functionality of fchmod(%d, "
-					 "%#o) successful", fd, PERMS);
+					 "%#o) successful", fd, PERMS & ~S_ISGID);
 			}
 		} else {
 			tst_resm(TPASS, "call succeeded");
@@ -218,12 +218,12 @@ void setup()
 		tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", TESTDIR);
 	}
 
-	if (chown(TESTDIR, nobody_u->pw_uid, bin_group->gr_gid) == -1)
+	if (chown(TESTDIR, nobody_u->pw_uid, nobody_u->pw_gid) == -1)
 		tst_brkm(TBROK, cleanup, "Couldn't change owner of testdir: %s",
 				strerror(errno));
 
-	/* change to nobody:nobody */
-	if (setegid(nobody_u->pw_gid) == -1 || seteuid(nobody_u->pw_uid) == -1)
+	/* change to nobody:bin */
+	if (setegid(bin_group->gr_gid) == -1 || seteuid(nobody_u->pw_uid) == -1)
 		tst_brkm(TBROK, cleanup, "Couldn't switch to nobody:nobody: %s",
 				strerror(errno));
 

testcases/kernel/syscalls/fchmod/fchmod05.c void cleanup() · line 266

Quoted 9 lines
testcases/kernel/syscalls/fchmod/fchmod05.c +3 -0
@@ -258,6 +258,9 @@ void cleanup()
 			 TESTDIR, errno, strerror(errno));
 	}
 
+	setegid(0);
+	seteuid(0);
+
 	/* Remove tmp dir and all files in it */
 	tst_rmdir();
 

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list