• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
4  * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
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 IPC_ENV_VAR        "LTP_IPC_PATH"
21 #define MNTPOINT           "mntpoint"
22 #define TESTBIN            "prctl06_execve"
23 #define TEST_REL_BIN_DIR   MNTPOINT"/"
24 #define BIN_PATH           MNTPOINT"/"TESTBIN
25 #define SUID_MODE          (S_ISUID|S_ISGID|S_IXUSR|S_IXGRP|S_IXOTH)
26 
check_no_new_privs(int val,char * name,int flag)27 void check_no_new_privs(int val, char *name, int flag)
28 {
29 	TEST(prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0));
30 	if (TST_RET == val)
31 		tst_res(TPASS,
32 			"%s prctl(PR_GET_NO_NEW_PRIVS) expected %d got %d",
33 			name, val, val);
34 	else
35 		tst_res(TFAIL,
36 			"%s prctl(PR_GET_NO_NEW_PRIVS) expected %d got %ld",
37 			name, val, TST_RET);
38 	if (flag)
39 		TST_ASSERT_FILE_INT(PROC_STATUS, "NoNewPrivs:", val);
40 }
41 
42 #endif
43