Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | RC=0 |
| 3 | SMACK_PATH=`grep smack /proc/mounts | awk '{print $2}'` |
| 4 | test_label="test_label" |
| 5 | onlycap_initial=`cat $SMACK_PATH/onlycap` |
| 6 | smack_initial=`cat /proc/self/attr/current` |
| 7 | |
| 8 | # need to set out label to be the same as onlycap, otherwise we lose our smack privileges |
| 9 | # even if we are root |
| 10 | echo "$test_label" > /proc/self/attr/current |
| 11 | |
| 12 | echo "$test_label" > $SMACK_PATH/onlycap || RC=$? |
| 13 | if [ $RC -ne 0 ]; then |
| 14 | echo "Onlycap label could not be set" |
| 15 | return $RC |
| 16 | fi |
| 17 | |
| 18 | if [ `cat $SMACK_PATH/onlycap` != "$test_label" ]; then |
| 19 | echo "Onlycap label was not set correctly." |
| 20 | return 1 |
| 21 | fi |
| 22 | |
| 23 | # resetting original onlycap label |
| 24 | echo "$onlycap_initial" > $SMACK_PATH/onlycap 2>/dev/null |
| 25 | |
| 26 | # resetting our initial's process label |
| 27 | echo "$smack_initial" > /proc/self/attr/current |