• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) International Business Machines  Corp., 2001
3  *  Ported by Wayne Boyer
4  *
5  * This program is free software;  you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY;  without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13  * the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program;  if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #include <pwd.h>
21 #include <errno.h>
22 
23 #include "test.h"
24 #include "compat_16.h"
25 
26 TCID_DEFINE(geteuid02);
27 int TST_TOTAL = 1;
28 
29 static void setup(void);
30 static void cleanup(void);
31 
main(int ac,char ** av)32 int main(int ac, char **av)
33 {
34 	struct passwd *pwent;
35 	int lc;
36 	uid_t uid;
37 
38 	tst_parse_opts(ac, av, NULL, NULL);
39 
40 	setup();
41 
42 	for (lc = 0; TEST_LOOPING(lc); lc++) {
43 		tst_count = 0;
44 
45 		TEST(GETEUID(cleanup));
46 
47 		if (TEST_RETURN == -1)
48 			tst_brkm(TBROK | TTERRNO, cleanup, "geteuid* failed");
49 
50 		uid = geteuid();
51 		pwent = getpwuid(uid);
52 
53 		if (pwent == NULL)
54 			tst_resm(TFAIL | TERRNO, "getpwuid failed");
55 
56 		UID16_CHECK(pwent->pw_uid, geteuid, cleanup);
57 		if (pwent->pw_uid != TEST_RETURN)
58 			tst_resm(TFAIL, "getpwuid value, %d, "
59 				 "does not match geteuid "
60 				 "value, %ld", pwent->pw_uid,
61 				 TEST_RETURN);
62 		else
63 			tst_resm(TPASS, "values from geteuid "
64 				 "and getpwuid match");
65 	}
66 
67 	cleanup();
68 	tst_exit();
69 }
70 
setup(void)71 static void setup(void)
72 {
73 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
74 	TEST_PAUSE;
75 }
76 
cleanup(void)77 static void cleanup(void)
78 {
79 }
80