• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
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
6#
7# Test reading of the current process Smack label
8#
9# Environment:
10#	CAP_MAC_ADMIN
11#	/smack/onlycap unset
12#
13
14export TCID=smack_set_current
15export TST_TOTAL=1
16
17. test.sh
18
19. smack_common.sh
20
21not_floor_label="XYZZY"
22start_label=$(cat /proc/self/attr/current 2>/dev/null)
23
24echo "$not_floor_label" 2>/dev/null > /proc/self/attr/current
25
26label=$(cat /proc/self/attr/current 2>/dev/null)
27if [ "$label" != "$not_floor_label" ]; then
28	tst_brkm TFAIL "The smack label reported for the current process is" \
29		       "\"$label\", not the expected \"$not_floor_label\"."
30fi
31
32echo "$start_label" 2>/dev/null > /proc/self/attr/current
33
34label=$(cat /proc/self/attr/current 2> /dev/null)
35if [ "$label" != "$start_label" ]; then
36	tst_brkm TFAIL "The smack label reported for the current process is" \
37		       "\"$label\", not the expected \"$start_label\"."
38fi
39
40tst_resm TPASS "Test \"$TCID\" success."
41tst_exit
42