1 //SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) International Business Machines Corp., 2001
4 * Copyright (c) Linux Test Project, 2003-2023
5 * Ported by Wayne Boyer
6 */
7
8 /*\
9 *[Description]
10 *
11 * Check that geteuid() return value matches value from /proc/self/status.
12 */
13
14 #include "tst_test.h"
15 #include "compat_tst_16.h"
16
verify_geteuid(void)17 static void verify_geteuid(void)
18 {
19 long uid[4];
20
21 TST_EXP_POSITIVE(GETEUID(), "geteuid()");
22
23 if (!TST_PASS)
24 return;
25
26 SAFE_FILE_LINES_SCANF("/proc/self/status", "Uid: %ld %ld %ld %ld",
27 &uid[0], &uid[1], &uid[2], &uid[3]);
28
29 TST_EXP_EXPR(TST_RET == uid[1],
30 "geteuid() ret %ld == /proc/self/status EUID: %ld",
31 TST_RET, uid[1]);
32 }
33
34 static struct tst_test test = {
35 .test_all = verify_geteuid,
36 };
37