xref: /aosp_15_r20/external/ltp/testcases/kernel/security/filecaps/filecapstest.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker#!/bin/sh
2*49cdfc7eSAndroid Build Coastguard Worker################################################################################
3*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
4*49cdfc7eSAndroid Build Coastguard Worker## Copyright (c) International Business Machines  Corp., 2008                 ##
5*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
6*49cdfc7eSAndroid Build Coastguard Worker## This program is free software;  you can redistribute it and#or modify      ##
7*49cdfc7eSAndroid Build Coastguard Worker## it under the terms of the GNU General Public License as published by       ##
8*49cdfc7eSAndroid Build Coastguard Worker## the Free Software Foundation; either version 2 of the License, or          ##
9*49cdfc7eSAndroid Build Coastguard Worker## (at your option) any later version.                                        ##
10*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
11*49cdfc7eSAndroid Build Coastguard Worker## This program is distributed in the hope that it will be useful, but        ##
12*49cdfc7eSAndroid Build Coastguard Worker## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13*49cdfc7eSAndroid Build Coastguard Worker## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
14*49cdfc7eSAndroid Build Coastguard Worker## for more details.                                                          ##
15*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
16*49cdfc7eSAndroid Build Coastguard Worker## You should have received a copy of the GNU General Public License          ##
17*49cdfc7eSAndroid Build Coastguard Worker## along with this program;  if not, write to the Free Software               ##
18*49cdfc7eSAndroid Build Coastguard Worker## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
19*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
20*49cdfc7eSAndroid Build Coastguard Worker################################################################################
21*49cdfc7eSAndroid Build Coastguard Worker
22*49cdfc7eSAndroid Build Coastguard Workerecho "Running in:"
23*49cdfc7eSAndroid Build Coastguard Worker#rm -f print_caps
24*49cdfc7eSAndroid Build Coastguard Worker#cp $LTPROOT/testcases/bin/print_caps .
25*49cdfc7eSAndroid Build Coastguard WorkerFIFOFILE="${TMPDIR:=/tmp}/caps_fifo"
26*49cdfc7eSAndroid Build Coastguard Workerexport FIFOFILE
27*49cdfc7eSAndroid Build Coastguard Workerrm -f $FIFOFILE
28*49cdfc7eSAndroid Build Coastguard Workermkfifo $FIFOFILE
29*49cdfc7eSAndroid Build Coastguard Workerchmod 777 $FIFOFILE
30*49cdfc7eSAndroid Build Coastguard Workerexit_code=0
31*49cdfc7eSAndroid Build Coastguard Workerecho "cap_sys_admin tests"
32*49cdfc7eSAndroid Build Coastguard Workerverify_caps_exec 0
33*49cdfc7eSAndroid Build Coastguard Workertmp=$?
34*49cdfc7eSAndroid Build Coastguard Workerif [ $tmp -ne 0 ]; then
35*49cdfc7eSAndroid Build Coastguard Worker	exit_code=$tmp
36*49cdfc7eSAndroid Build Coastguard Workerfi
37*49cdfc7eSAndroid Build Coastguard Worker
38*49cdfc7eSAndroid Build Coastguard Workerecho "testing for correct caps"
39*49cdfc7eSAndroid Build Coastguard Workerverify_caps_exec 1
40*49cdfc7eSAndroid Build Coastguard Workertmp=$?
41*49cdfc7eSAndroid Build Coastguard Workerif [ $tmp -ne 0 ]; then
42*49cdfc7eSAndroid Build Coastguard Worker	exit_code=$tmp
43*49cdfc7eSAndroid Build Coastguard Workerfi
44*49cdfc7eSAndroid Build Coastguard Worker
45*49cdfc7eSAndroid Build Coastguard Workerecho "testing for correct pI checks"
46*49cdfc7eSAndroid Build Coastguard Workerinh_capped
47*49cdfc7eSAndroid Build Coastguard Workertmp=$?
48*49cdfc7eSAndroid Build Coastguard Workerif [ $tmp -ne 0 ]; then
49*49cdfc7eSAndroid Build Coastguard Worker	exit_code=$tmp
50*49cdfc7eSAndroid Build Coastguard Workerfi
51*49cdfc7eSAndroid Build Coastguard Worker
52*49cdfc7eSAndroid Build Coastguard Workerunlink $FIFOFILE
53*49cdfc7eSAndroid Build Coastguard Workerexit $exit_code
54