Integrate parts of meta-intel-iot-security
[AGL/meta-agl.git] / meta-security / lib / oeqa / runtime / files / test_privileged_change_self_label.sh
1 #!/bin/sh
2
3 initial_label=`cat /proc/self/attr/current 2>/dev/null`
4 modified_label="test_label"
5
6 echo "$modified_label" >/proc/self/attr/current 2>/dev/null
7
8 new_label=`cat /proc/self/attr/current 2>/dev/null`
9
10 if [ "$new_label" != "$modified_label" ]; then
11         # restore proper label
12         echo $initial_label >/proc/self/attr/current
13         echo "Privileged process could not change its label"
14         exit 1
15 fi
16
17 echo "$initial_label" >/proc/self/attr/current 2>/dev/null
18 exit 0