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