• 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
13export TCID=smack_set_netlabel
14export TST_TOTAL=1
15
16. test.sh
17
18. smack_common.sh
19
20rule_a="191.191.191.191 TheOne"
21rule_a1="191.191.191.191/32 TheOne"
22rule_b="191.190.190.0/24 TheOne"
23
24old32=$(grep "^191.191.191.191/32" "$smackfsdir/netlabel" 2>/dev/null)
25old24=$(grep "^191.190.190.0/24" "$smackfsdir/netlabel" 2>/dev/null)
26
27echo -n "$rule_a" 2>/dev/null > "$smackfsdir/netlabel"
28new32=$(grep "$rule_a1" $smackfsdir/netlabel 2>/dev/null)
29if [ "$new32" != "$rule_a1" ]; then
30	tst_brkm TFAIL "Rule \"$rule_a\" did not get set."
31fi
32
33echo -n "$rule_b" 2>/dev/null > "$smackfsdir/netlabel"
34new24=$(grep "$rule_b" "$smackfsdir/netlabel" 2>/dev/null)
35if [ "$new24" != "$rule_b" ]; then
36	tst_brkm TFAIL "Rule \"$rule_b\" did not get set."
37fi
38
39if [ "$old24" != "$new24" ]; then
40	tst_resm TINFO "Notice: Test access rule changed from \"$old24\" to" \
41		       "\"$new24\"."
42fi
43
44if [ "$old32" != "$new32" ]; then
45	tst_resm TINFO "Notice: Test access rule changed from \"$old32\" to \
46\"$new32\"."
47fi
48
49tst_resm TPASS "Test \"$TCID\" success."
50tst_exit
51