• 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 access rules
8#
9# Environment:
10#	CAP_MAC_ADMIN
11#
12# "%-23s %-23s %4s"
13#
14#               1         2         3         4         5         6
15#      123456789012345678901234567890123456789012345678901234567890123456789
16
17export TCID=smack_set_load
18export TST_TOTAL=1
19
20. test.sh
21
22. smack_common.sh
23
24rule_a="TheOne                  TheOther                rwxa"
25rule_b="TheOne                  TheOther                r---"
26
27old_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
28
29echo -n "$rule_a" 2>/dev/null > "$smackfsdir/load"
30new_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
31if [ "$new_rule" = "" ]; then
32	tst_brkm TFAIL "Rule did not get set."
33fi
34mode=$(echo "$new_rule" | sed -e 's/.* //')
35if [ "$mode" != "rwxa" ]; then
36	tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
37fi
38
39echo -n "$rule_b" 2>/dev/null > "$smackfsdir/load"
40new_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
41if [ "$new_rule" = "" ]; then
42	tst_brkm TFAIL "Rule did not get set."
43fi
44mode=$(echo "$new_rule" | sed -e 's/.* //')
45if [ "$mode" != "r" ]; then
46	tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
47fi
48
49if [ "$old_rule" != "$new_rule" ]; then
50	tst_resm TINFO "Notice: Test access rule changed from \"$old_rule\"" \
51		       "to \"$new_rule\"."
52fi
53
54tst_resm TPASS "Test \"$TCID\" success."
55tst_exit
56