1#!/bin/sh 2# 3# Copyright (c) 2009 Casey Schaufler under the terms of the 4# GNU General Public License version 2, as published by the 5# Free Software Foundation 6# 7# Test setting access rules 8# 9# Environment: 10# CAP_MAC_ADMIN 11# 12# "%-23s %-23s %4s" 13# 14# 1 2 llllCCCCccccCCCCcccc 5 6 15# 123456789012345678901234567890123456789012345678901234567890123456789 16 17export TCID=smack_set_cipso 18export TST_TOTAL=1 19 20. test.sh 21 22. smack_common.sh 23 24rule_a="TheOne 2 0 " 25rule_b="TheOne 3 1 55 " 26rule_c="TheOne 4 2 17 33 " 27 28old_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null) 29 30echo -n "$rule_a" 2>/dev/null > "$smackfsdir/cipso" 31new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null) 32if [ "$new_rule" = "" ]; then 33 tst_brkm TFAIL "Rule did not get set." 34fi 35right=$(echo "$new_rule" | grep ' 2') 36if [ "$right" = "" ]; then 37 tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly." 38fi 39 40echo -n "$rule_b" 2>/dev/null > "$smackfsdir/cipso" 41new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null) 42if [ "$new_rule" = "" ]; then 43 tst_brkm TFAIL "Rule did not get set." 44fi 45right=$(echo $new_rule | grep '/55') 46if [ "$right" = "" ]; then 47 tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly." 48fi 49 50echo -n "$rule_c" 2>/dev/null > "$smackfsdir/cipso" 51new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null) 52if [ "$new_rule" = "" ]; then 53 tst_brkm TFAIL "Rule did not get set." 54fi 55right=$(echo "$new_rule" | grep '/17,33') 56if [ "$right" = "" ]; then 57 tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly." 58fi 59 60if [ "$old_rule" != "$new_rule" ]; then 61 tst_resm TINFO "Notice: Test access rule changed from \"$old_rule\"" \ 62 "to \"$new_rule\"." 63fi 64 65tst_resm TPASS "Test \"$TCID\" success." 66tst_exit 67