1#!/bin/sh 2RC=0 3SMACK_PATH=`grep smack /proc/mounts | awk '{print $2}'` 4test_label="test_label" 5onlycap_initial=`cat $SMACK_PATH/onlycap` 6smack_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 10echo "$test_label" > /proc/self/attr/current 11 12echo "$test_label" > $SMACK_PATH/onlycap || RC=$? 13if [ $RC -ne 0 ]; then 14 echo "Onlycap label could not be set" 15 return $RC 16fi 17 18if [ `cat $SMACK_PATH/onlycap` != "$test_label" ]; then 19 echo "Onlycap label was not set correctly." 20 return 1 21fi 22 23# resetting original onlycap label 24echo "$onlycap_initial" > $SMACK_PATH/onlycap 2>/dev/null 25 26# resetting our initial's process label 27echo "$smack_initial" > /proc/self/attr/current 28