1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 4 * William Roske, Dave Fenner 5 * Copyright (C) 2023 SUSE LLC Andrea Cervesato <[email protected]> 6 */ 7 8 /*\ 9 * [Description] 10 * 11 * This test checks if getegid() returns the same effective group given by 12 * passwd entry via getpwuid(). 13 */ 14 15 #include <pwd.h> 16 17 #include "tst_test.h" 18 #include "compat_tst_16.h" 19 run(void)20static void run(void) 21 { 22 uid_t euid; 23 gid_t egid; 24 struct passwd *pwent; 25 26 UID16_CHECK((euid = geteuid()), "geteuid"); 27 28 pwent = getpwuid(euid); 29 if (!pwent) 30 tst_brk(TBROK | TERRNO, "getpwuid() error"); 31 32 GID16_CHECK((egid = getegid()), "getegid"); 33 34 TST_EXP_EQ_LI(pwent->pw_gid, egid); 35 } 36 37 static struct tst_test test = { 38 .test_all = run, 39 }; 40