Skip to contentSkip to conversation

setgroups03: Fix running more iterations (-i 2)

PATCH zhaogongyi 1 participant 1 message Oct 14, 2021

lore
Share & tools
lore

zhaogongyi

author
#0 lore raw

Hi,

Yes, in this testcase, the groups_list is redundant and can be removed.

I am sorry for my late reply.

Thanks so much!

Quoted 59 lines
Quoted 14 lines
Quoted 13 lines
(quoted diff) +2 -10
-int setup1(void)
+void setup1(const char *uid, uid_t euid)
 {
-	struct passwd *user_info;	/* struct. to hold test user info */
-
-/* Switch to nobody user for correct error code collection */
-	ltpuser = getpwnam(nobody_uid);
-	if (seteuid(ltpuser->pw_uid) == -1) {
-		tst_resm(TINFO, "setreuid failed to "
-			 "to set the effective uid to %d", ltpuser->pw_uid);
-		perror("setreuid");
-	}
+	struct passwd *user_info;
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +0 -2
-	if ((user_info = getpwnam(TESTUSER)) == NULL) {
-		tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed",

TESTUSER);

Quoted 11 lines

Review

Quoted 4 lines
(quoted diff) +3 -1
-	}
+	SAFE_SETEUID(cleanup, euid);
+
+	user_info = SAFE_GETPWNAM(cleanup, uid);

I still do not get why we call SAFE_GETPWNAM() here. We should do that in the setup and prepare two different group_list[] lists, if that is really needed.

But I guess that all we need in this test is:

Quoted 7 lines

* Run the EINVAL test as a root

* Run the EPERM test as a nobody

The content of the list should not matter, as a matter of a fact we pass unitialized data in the EINVAL case. What matters is the size argument, it should be 1 for the EPERM test and max+1 for the EINVAL

case.

Good point, thank you!

@Zhao feel free to let me know you're doing to implement it. Otherwise I'll have look on Monday.

Kind regards,
Petr

Quoted 4 lines

Review

Quoted 4 lines
(quoted diff) +0 -0
 	if (!GID_SIZE_CHECK(user_info->pw_gid)) {
 		tst_brkm(TBROK,
 			 cleanup,
 			 "gid returned from getpwnam is too large for testing

setgroups16");

Quoted 9 lines
Quoted 9 lines
(quoted diff) +1 -2
 	}
+
 	groups_list[0] = user_info->pw_gid;
-	return 0;
 }
 
 /*
--

2.33.0

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