smack_set_load.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. export TCID=smack_set_load
  17. export TST_TOTAL=1
  18. . test.sh
  19. . smack_common.sh
  20. rule_a="TheOne TheOther rwxa"
  21. rule_b="TheOne TheOther r---"
  22. old_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
  23. echo -n "$rule_a" 2>/dev/null > "$smackfsdir/load"
  24. new_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
  25. if [ "$new_rule" = "" ]; then
  26. tst_brkm TFAIL "Rule did not get set."
  27. fi
  28. mode=$(echo "$new_rule" | sed -e 's/.* //')
  29. if [ "$mode" != "rwxa" ]; then
  30. tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
  31. fi
  32. echo -n "$rule_b" 2>/dev/null > "$smackfsdir/load"
  33. new_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
  34. if [ "$new_rule" = "" ]; then
  35. tst_brkm TFAIL "Rule did not get set."
  36. fi
  37. mode=$(echo "$new_rule" | sed -e 's/.* //')
  38. if [ "$mode" != "r" ]; then
  39. tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
  40. fi
  41. if [ "$old_rule" != "$new_rule" ]; then
  42. tst_resm TINFO "Notice: Test access rule changed from \"$old_rule\"" \
  43. "to \"$new_rule\"."
  44. fi
  45. tst_resm TPASS "Test \"$TCID\" success."
  46. tst_exit