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 * Copyright (c) 2022 SUSE LLC Avinesh Kumar <avinesh.kumar@suse.com> 7f08c3bdfSopenharmony_ci */ 8f08c3bdfSopenharmony_ci 9f08c3bdfSopenharmony_ci/*\ 10f08c3bdfSopenharmony_ci * [Description] 11f08c3bdfSopenharmony_ci * 12f08c3bdfSopenharmony_ci * Verify the basic functionality of setreuid(2) system call when executed 13f08c3bdfSopenharmony_ci * as non-root user. 14f08c3bdfSopenharmony_ci */ 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci#include "tst_test.h" 17f08c3bdfSopenharmony_ci#include "compat_tst_16.h" 18f08c3bdfSopenharmony_ci 19f08c3bdfSopenharmony_cistatic uid_t ruid, euid; 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_cistatic void run(void) 22f08c3bdfSopenharmony_ci{ 23f08c3bdfSopenharmony_ci ruid = getuid(); 24f08c3bdfSopenharmony_ci UID16_CHECK(ruid, setreuid); 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci euid = geteuid(); 27f08c3bdfSopenharmony_ci UID16_CHECK(euid, setreuid); 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci TST_EXP_PASS(SETREUID(-1, -1)); 30f08c3bdfSopenharmony_ci TST_EXP_PASS(SETREUID(-1, euid)); 31f08c3bdfSopenharmony_ci TST_EXP_PASS(SETREUID(ruid, -1)); 32f08c3bdfSopenharmony_ci TST_EXP_PASS(SETREUID(-1, ruid)); 33f08c3bdfSopenharmony_ci TST_EXP_PASS(SETREUID(euid, -1)); 34f08c3bdfSopenharmony_ci TST_EXP_PASS(SETREUID(euid, euid)); 35f08c3bdfSopenharmony_ci TST_EXP_PASS(SETREUID(ruid, ruid)); 36f08c3bdfSopenharmony_ci} 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_cistatic struct tst_test test = { 39f08c3bdfSopenharmony_ci .test_all = run 40f08c3bdfSopenharmony_ci}; 41