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 /*
21 * Testcase to test the basic functionality of the setfsuid(2) system call.
22 */
23
24 #include <sys/types.h>
25 #include <sys/fsuid.h>
26 #include <stdio.h>
27 #include <unistd.h>
28 #include <errno.h>
29
30 #include "test.h"
31 #include "compat_16.h"
32
33 static void setup(void);
34 static void cleanup(void);
35
36 TCID_DEFINE(setfsuid01);
37 int TST_TOTAL = 1;
38
main(int ac,char ** av)39 int main(int ac, char **av)
40 {
41 int lc;
42
43 uid_t uid;
44
45 tst_parse_opts(ac, av, NULL, NULL);
46
47 setup();
48
49 uid = geteuid();
50 UID16_CHECK(uid, setfsuid, cleanup);
51
52 for (lc = 0; TEST_LOOPING(lc); lc++) {
53
54 tst_count = 0;
55
56 TEST(SETFSUID(cleanup, uid));
57
58 if (TEST_RETURN == -1) {
59 tst_resm(TFAIL | TTERRNO,
60 "setfsuid() failed unexpectedly");
61 continue;
62 }
63
64 if (TEST_RETURN != uid) {
65 tst_resm(TFAIL, "setfsuid() returned %ld, expected %d",
66 TEST_RETURN, uid);
67 } else {
68 tst_resm(TPASS,
69 "setfsuid() returned expected value : %ld",
70 TEST_RETURN);
71 }
72 }
73
74 cleanup();
75 tst_exit();
76 }
77
setup(void)78 static void setup(void)
79 {
80 tst_sig(NOFORK, DEF_HANDLER, cleanup);
81
82 TEST_PAUSE;
83 }
84
cleanup(void)85 static void cleanup(void)
86 {
87 }
88