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