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 setting access rules 8f08c3bdfSopenharmony_ci# 9f08c3bdfSopenharmony_ci# Environment: 10f08c3bdfSopenharmony_ci# CAP_MAC_ADMIN 11f08c3bdfSopenharmony_ci# 12f08c3bdfSopenharmony_ci# "%-23s %-23s %4s" 13f08c3bdfSopenharmony_ci# 14f08c3bdfSopenharmony_ci# 1 2 3 4 5 6 15f08c3bdfSopenharmony_ci# 123456789012345678901234567890123456789012345678901234567890123456789 16f08c3bdfSopenharmony_ci 17f08c3bdfSopenharmony_ciexport TCID=smack_set_load 18f08c3bdfSopenharmony_ciexport TST_TOTAL=1 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_ci. test.sh 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci. smack_common.sh 23f08c3bdfSopenharmony_ci 24f08c3bdfSopenharmony_cirule_a="TheOne TheOther rwxa" 25f08c3bdfSopenharmony_cirule_b="TheOne TheOther r---" 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ciold_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ') 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ciecho -n "$rule_a" 2>/dev/null > "$smackfsdir/load" 30f08c3bdfSopenharmony_cinew_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ') 31f08c3bdfSopenharmony_ciif [ "$new_rule" = "" ]; then 32f08c3bdfSopenharmony_ci tst_brkm TFAIL "Rule did not get set." 33f08c3bdfSopenharmony_cifi 34f08c3bdfSopenharmony_cimode=$(echo "$new_rule" | sed -e 's/.* //') 35f08c3bdfSopenharmony_ciif [ "$mode" != "rwxa" ]; then 36f08c3bdfSopenharmony_ci tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly." 37f08c3bdfSopenharmony_cifi 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ciecho -n "$rule_b" 2>/dev/null > "$smackfsdir/load" 40f08c3bdfSopenharmony_cinew_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ') 41f08c3bdfSopenharmony_ciif [ "$new_rule" = "" ]; then 42f08c3bdfSopenharmony_ci tst_brkm TFAIL "Rule did not get set." 43f08c3bdfSopenharmony_cifi 44f08c3bdfSopenharmony_cimode=$(echo "$new_rule" | sed -e 's/.* //') 45f08c3bdfSopenharmony_ciif [ "$mode" != "r" ]; then 46f08c3bdfSopenharmony_ci tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly." 47f08c3bdfSopenharmony_cifi 48f08c3bdfSopenharmony_ci 49f08c3bdfSopenharmony_ciif [ "$old_rule" != "$new_rule" ]; then 50f08c3bdfSopenharmony_ci tst_resm TINFO "Notice: Test access rule changed from \"$old_rule\"" \ 51f08c3bdfSopenharmony_ci "to \"$new_rule\"." 52f08c3bdfSopenharmony_cifi 53f08c3bdfSopenharmony_ci 54f08c3bdfSopenharmony_citst_resm TPASS "Test \"$TCID\" success." 55f08c3bdfSopenharmony_citst_exit 56