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