smack_set_current.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 reading of the current process Smack label
  8. #
  9. # Environment:
  10. # CAP_MAC_ADMIN
  11. # /smack/onlycap unset
  12. #
  13. export TCID=smack_set_current
  14. export TST_TOTAL=1
  15. . test.sh
  16. . smack_common.sh
  17. not_floor_label="XYZZY"
  18. start_label=$(cat /proc/self/attr/current 2>/dev/null)
  19. echo "$not_floor_label" 2>/dev/null > /proc/self/attr/current
  20. label=$(cat /proc/self/attr/current 2>/dev/null)
  21. if [ "$label" != "$not_floor_label" ]; then
  22. tst_brkm TFAIL "The smack label reported for the current process is" \
  23. "\"$label\", not the expected \"$not_floor_label\"."
  24. fi
  25. echo "$start_label" 2>/dev/null > /proc/self/attr/current
  26. label=$(cat /proc/self/attr/current 2> /dev/null)
  27. if [ "$label" != "$start_label" ]; then
  28. tst_brkm TFAIL "The smack label reported for the current process is" \
  29. "\"$label\", not the expected \"$start_label\"."
  30. fi
  31. tst_resm TPASS "Test \"$TCID\" success."
  32. tst_exit