1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) International Business Machines Corp., 2001 4 */ 5 6 /* DESCRIPTION 7 * This test will verify that setuid(2) syscall basic functionality. 8 * setuid(2) returns a value of 0 and uid has been set successfully 9 * as a normal or super user. 10 */ 11 12 #include <errno.h> 13 #include <unistd.h> 14 #include <sys/types.h> 15 #include "tst_test.h" 16 #include "compat_tst_16.h" 17 verify_setuid(void)18static void verify_setuid(void) 19 { 20 uid_t uid; 21 22 /* Set the effective user ID to the current real uid */ 23 uid = getuid(); 24 UID16_CHECK(uid, setuid); 25 26 TEST(SETUID(uid)); 27 if (TST_RET == -1) 28 tst_res(TFAIL | TTERRNO, "setuid(%d) failed", uid); 29 else 30 tst_res(TPASS, "setuid(%d) successfully", uid); 31 } 32 33 static struct tst_test test = { 34 .test_all = verify_setuid, 35 }; 36