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