1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 4 * 5 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 6 * Mountain View, CA 94043, or: 7 * 8 * http://www.sgi.com 9 * 10 * For further information regarding this notice, see: 11 * 12 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 13 * 14 * Author: William Roske 15 * Co-pilot: Dave Fenner 16 */ 17 18/*\ 19 * [Description] 20 * 21 * Verify the basic functionality of setregid(2) system call. 22 */ 23 24#include "tst_test.h" 25#include "compat_tst_16.h" 26 27static gid_t gid, egid; 28static gid_t neg_one = -1; 29 30static struct tcase { 31 gid_t *arg1; 32 gid_t *arg2; 33 const char *msg; 34} tcases[] = { 35 {&neg_one, &neg_one, "Leave real and effective both gids unchanged" }, 36 {&neg_one, &egid, "Change effective to effective gid" }, 37 {&gid, &neg_one, "Change real to real gid" }, 38 {&neg_one, &gid, "Change effective to real gid" }, 39 {&gid, &gid, "Change real and effective both gids to current real gid" } 40}; 41 42static void run(unsigned int n) 43{ 44 struct tcase *tc = &tcases[n]; 45 46 TST_EXP_PASS(SETREGID(*tc->arg1, *tc->arg2), "%s:", tc->msg); 47} 48 49static void setup(void) 50{ 51 gid = getgid(); 52 GID16_CHECK(gid, setregid); 53 54 egid = getegid(); 55 GID16_CHECK(egid, setregid); 56} 57 58static struct tst_test test = { 59 .tcnt = ARRAY_SIZE(tcases), 60 .test = run, 61 .setup = setup, 62}; 63