Imported Upstream version 20091031
[ltp-debian.git] / testcases / kernel / security / smack / smack_set_ambient.sh
blobaa48b62f2263ab64ece0766e17ef49044759837c
1 #!/bin/sh
3 # Copyright (c) 2009 Casey Schaufler under the terms of the
4 # GNU General Public License version 2, as published by the
5 # Free Software Foundation
7 # Test reading of the current process Smack label
9 # Environment:
10 # CAP_MAC_ADMIN
13 source smack_common.sh
15 NotTheFloorLabel="XYZZY"
16 StartLabel=`cat "$smackfsdir/ambient" 2>/dev/null`
18 echo "$NotTheFloorLabel" 2>/dev/null > "$smackfsdir/ambient"
20 label=`cat "$smackfsdir/ambient" 2>/dev/null`
21 if [ "$label" != "$NotTheFloorLabel" ]; then
22 cat <<EOM
23 The smack label reported for the current process is "$label", not the expected
24 "$NotTheFloorLabel".
25 EOM
26 exit 1
29 echo "$StartLabel" 2>/dev/null > "$smackfsdir/ambient"
31 label=`cat "$smackfsdir/ambient" 2>/dev/null`
32 if [ "$label" != "$StartLabel" ]; then
33 cat <<EOM
34 The smack label reported for the current process is "$label", not the expected "$StartLabel".
35 EOM
36 exit 1