1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci#
3f08c3bdfSopenharmony_ci# Copyright (c) 2009 Casey Schaufler under the terms of the
4f08c3bdfSopenharmony_ci# GNU General Public License version 2, as published by the
5f08c3bdfSopenharmony_ci# Free Software Foundation
6f08c3bdfSopenharmony_ci#
7f08c3bdfSopenharmony_ci# Test reading of the current process Smack label
8f08c3bdfSopenharmony_ci#
9f08c3bdfSopenharmony_ci# Environment:
10f08c3bdfSopenharmony_ci#	CAP_MAC_ADMIN
11f08c3bdfSopenharmony_ci#	/smack/onlycap unset
12f08c3bdfSopenharmony_ci#
13f08c3bdfSopenharmony_ci
14f08c3bdfSopenharmony_ciexport TCID=smack_set_current
15f08c3bdfSopenharmony_ciexport TST_TOTAL=1
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ci. test.sh
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_ci. smack_common.sh
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_cinot_floor_label="XYZZY"
22f08c3bdfSopenharmony_cistart_label=$(cat /proc/self/attr/current 2>/dev/null)
23f08c3bdfSopenharmony_ci
24f08c3bdfSopenharmony_ciecho "$not_floor_label" 2>/dev/null > /proc/self/attr/current
25f08c3bdfSopenharmony_ci
26f08c3bdfSopenharmony_cilabel=$(cat /proc/self/attr/current 2>/dev/null)
27f08c3bdfSopenharmony_ciif [ "$label" != "$not_floor_label" ]; then
28f08c3bdfSopenharmony_ci	tst_brkm TFAIL "The smack label reported for the current process is" \
29f08c3bdfSopenharmony_ci		       "\"$label\", not the expected \"$not_floor_label\"."
30f08c3bdfSopenharmony_cifi
31f08c3bdfSopenharmony_ci
32f08c3bdfSopenharmony_ciecho "$start_label" 2>/dev/null > /proc/self/attr/current
33f08c3bdfSopenharmony_ci
34f08c3bdfSopenharmony_cilabel=$(cat /proc/self/attr/current 2> /dev/null)
35f08c3bdfSopenharmony_ciif [ "$label" != "$start_label" ]; then
36f08c3bdfSopenharmony_ci	tst_brkm TFAIL "The smack label reported for the current process is" \
37f08c3bdfSopenharmony_ci		       "\"$label\", not the expected \"$start_label\"."
38f08c3bdfSopenharmony_cifi
39f08c3bdfSopenharmony_ci
40f08c3bdfSopenharmony_citst_resm TPASS "Test \"$TCID\" success."
41f08c3bdfSopenharmony_citst_exit
42