diff mbox series

[2/2] tst_get_free_gid(): Skip GID 0

Message ID 20210830131730.31935-2-mdoucha@suse.cz
State Accepted
Headers show
Series [1/2] Add verbose setup to creat08, creat09 and open10 | expand

Commit Message

Martin Doucha Aug. 30, 2021, 1:17 p.m. UTC
tst_get_free_gid() may return GID 0 on systems where /etc/group (or another
database of user groups) does not exist. But GID 0 exists implicitly and
it may stay after setgid() as a supplemental group of the test process if it
was executed with root privileges. Skip GID 0 to avoid unexpected test
failures.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 lib/tst_uid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cyril Hrubis Aug. 30, 2021, 1:47 p.m. UTC | #1
Hi!
Good catch, both patches pushed, thanks.
diff mbox series

Patch

diff --git a/lib/tst_uid.c b/lib/tst_uid.c
index 2163b1494..dd719d312 100644
--- a/lib/tst_uid.c
+++ b/lib/tst_uid.c
@@ -19,7 +19,7 @@  gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip)
 
 	errno = 0;
 
-	for (ret = 0; ret < MAX_GID; ret++) {
+	for (ret = 1; ret < MAX_GID; ret++) {
 		if (ret == skip || getgrgid(ret))
 			continue;