1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
4 * Author: Yang Xu <[email protected]>
5 */
6 #ifndef PRCTL06_H
7 #define PRCTL06_H
8
9 #include <errno.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <sys/prctl.h>
13 #include <pwd.h>
14 #include <sys/types.h>
15 #include <unistd.h>
16 #include <lapi/prctl.h>
17 #include "tst_test.h"
18
19 #define PROC_STATUS "/proc/self/status"
20 #define MNTPOINT "mntpoint"
21 #define TESTBIN "prctl06_execve"
22 #define TEST_REL_BIN_DIR MNTPOINT"/"
23 #define BIN_PATH MNTPOINT"/"TESTBIN
24 #define SUID_MODE (S_ISUID|S_ISGID|S_IXUSR|S_IXGRP|S_IXOTH)
25
check_no_new_privs(int val,char * name,int flag)26 static void check_no_new_privs(int val, char *name, int flag)
27 {
28 TEST(prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0));
29 if (TST_RET == val)
30 tst_res(TPASS,
31 "%s prctl(PR_GET_NO_NEW_PRIVS) expected %d got %d",
32 name, val, val);
33 else
34 tst_res(TFAIL,
35 "%s prctl(PR_GET_NO_NEW_PRIVS) expected %d got %ld",
36 name, val, TST_RET);
37 if (flag)
38 TST_ASSERT_FILE_INT(PROC_STATUS, "NoNewPrivs:", val);
39 }
40
41 #endif
42