1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 4f08c3bdfSopenharmony_ci * AUTHOR : William Roske 5f08c3bdfSopenharmony_ci * CO-PILOT : Dave Fenner 6f08c3bdfSopenharmony_ci */ 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ci/*\ 9f08c3bdfSopenharmony_ci * [Description] 10f08c3bdfSopenharmony_ci * 11f08c3bdfSopenharmony_ci * Call getgid() and expects that the gid returned correctly. 12f08c3bdfSopenharmony_ci */ 13f08c3bdfSopenharmony_ci 14f08c3bdfSopenharmony_ci#include <pwd.h> 15f08c3bdfSopenharmony_ci#include "tst_test.h" 16f08c3bdfSopenharmony_ci#include "compat_tst_16.h" 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_cistatic struct passwd *ltpuser; 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_cistatic void run(void) 21f08c3bdfSopenharmony_ci{ 22f08c3bdfSopenharmony_ci TEST(GETGID()); 23f08c3bdfSopenharmony_ci if (TST_RET != ltpuser->pw_gid) 24f08c3bdfSopenharmony_ci tst_res(TFAIL, "getgid failed, returned %ld", TST_RET); 25f08c3bdfSopenharmony_ci else 26f08c3bdfSopenharmony_ci tst_res(TPASS, "getgid returned as expectedly"); 27f08c3bdfSopenharmony_ci} 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_cistatic void setup(void) 30f08c3bdfSopenharmony_ci{ 31f08c3bdfSopenharmony_ci ltpuser = SAFE_GETPWNAM("nobody"); 32f08c3bdfSopenharmony_ci SAFE_SETGID(ltpuser->pw_gid); 33f08c3bdfSopenharmony_ci} 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_cistatic struct tst_test test = { 36f08c3bdfSopenharmony_ci .needs_root = 1, 37f08c3bdfSopenharmony_ci .test_all = run, 38f08c3bdfSopenharmony_ci .setup = setup, 39f08c3bdfSopenharmony_ci}; 40