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 llllCCCCccccCCCCcccc 5 6 15 # 123456789012345678901234567890123456789012345678901234567890123456789 16 17 export TCID=smack_set_cipso 18 export TST_TOTAL=1 19 20 . test.sh 21 22 . smack_common.sh 23 24 rule_a="TheOne 2 0 " 25 rule_b="TheOne 3 1 55 " 26 rule_c="TheOne 4 2 17 33 " 27 28 old_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null) 29 30 echo -n "$rule_a" 2>/dev/null > "$smackfsdir/cipso" 31 new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null) 32 if [ "$new_rule" = "" ]; then 33 tst_brkm TFAIL "Rule did not get set." 34 fi 35 right=$(echo "$new_rule" | grep ' 2') 36 if [ "$right" = "" ]; then 37 tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly." 38 fi 39 40 echo -n "$rule_b" 2>/dev/null > "$smackfsdir/cipso" 41 new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null) 42 if [ "$new_rule" = "" ]; then 43 tst_brkm TFAIL "Rule did not get set." 44 fi 45 right=$(echo $new_rule | grep '/55') 46 if [ "$right" = "" ]; then 47 tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly." 48 fi 49 50 echo -n "$rule_c" 2>/dev/null > "$smackfsdir/cipso" 51 new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null) 52 if [ "$new_rule" = "" ]; then 53 tst_brkm TFAIL "Rule did not get set." 54 fi 55 right=$(echo "$new_rule" | grep '/17,33') 56 if [ "$right" = "" ]; then 57 tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly." 58 fi 59 60 if [ "$old_rule" != "$new_rule" ]; then 61 tst_resm TINFO "Notice: Test access rule changed from \"$old_rule\"" \ 62 "to \"$new_rule\"." 63 fi 64 65 tst_resm TPASS "Test \"$TCID\" success." 66 tst_exit 67