1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) International Business Machines Corp., 2001
4 * Copyright (c) Linux Test Project, 2003-2023
5 * 07/2001 Ported by Wayne Boyer
6 */
7
8 /*\
9 * [Description]
10 *
11 * Check that root process can setgroups() supplementary group ID and verify
12 * that getgroups() returns the previously set ID.
13 */
14
15 #include <pwd.h>
16
17 #include "tst_test.h"
18 #include "compat_tst_16.h"
19
20 static GID_T *groups_get, *groups_set;
21
verify_setgroups(void)22 static void verify_setgroups(void)
23 {
24 groups_set[0] = 42;
25
26 TST_EXP_PASS(SETGROUPS(1, groups_set));
27
28 TST_EXP_VAL(GETGROUPS(1, groups_get), 1);
29
30 TST_EXP_EQ_LI(groups_get[0], groups_set[0]);
31
32 groups_get[0] = 0;
33 }
34
35 static struct tst_test test = {
36 .test_all = verify_setgroups,
37 .bufs = (struct tst_buffers []) {
38 {&groups_get, .size = sizeof(GID_T)},
39 {&groups_set, .size = sizeof(GID_T)},
40 {},
41 },
42 .needs_root = 1,
43 };
44