vmojzis / tests / selinux

Forked from tests/selinux 4 years ago
Clone
26ce71b
#!/bin/bash
26ce71b
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
26ce71b
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26ce71b
#
26ce71b
#   runtest.sh of /CoreOS/policycoreutils/Sanity/booleans
26ce71b
#   Description: Basic operations with booleans
26ce71b
#   Author: Jan Zarsky <jzarsky@redhat.com>
26ce71b
#
26ce71b
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26ce71b
#
26ce71b
#   Copyright (c) 2018 Red Hat, Inc.
26ce71b
#
26ce71b
#   This program is free software: you can redistribute it and/or
26ce71b
#   modify it under the terms of the GNU General Public License as
26ce71b
#   published by the Free Software Foundation, either version 2 of
26ce71b
#   the License, or (at your option) any later version.
26ce71b
#
26ce71b
#   This program is distributed in the hope that it will be
26ce71b
#   useful, but WITHOUT ANY WARRANTY; without even the implied
26ce71b
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
26ce71b
#   PURPOSE.  See the GNU General Public License for more details.
26ce71b
#
26ce71b
#   You should have received a copy of the GNU General Public License
26ce71b
#   along with this program. If not, see http://www.gnu.org/licenses/.
26ce71b
#
26ce71b
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26ce71b
26ce71b
# Include Beaker environment
26ce71b
. /usr/bin/rhts-environment.sh || exit 1
26ce71b
. /usr/share/beakerlib/beakerlib.sh || exit 1
26ce71b
26ce71b
PACKAGE="policycoreutils"
26ce71b
26ce71b
rlJournalStart
26ce71b
    rlPhaseStartSetup
26ce71b
        rlAssertRpm $PACKAGE
26ce71b
26ce71b
        cat << EOF >test_module.cil
26ce71b
(boolean test_bool_on true)
26ce71b
(boolean test_bool_off false)
26ce71b
EOF
26ce71b
        rlRun "semodule -i test_module.cil"
26ce71b
26ce71b
        BOOL_ON=test_bool_on
26ce71b
        BOOL_OFF=test_bool_off
26ce71b
    rlPhaseEnd
26ce71b
26ce71b
    rlPhaseStartTest "listing"
26ce71b
        rlRun "semanage boolean -l >stdout"
26ce71b
26ce71b
        rlRun "grep -E '$BOOL_ON *\(on   ,   on\) ' stdout"
26ce71b
        rlRun "grep -E '$BOOL_OFF *\(off  ,  off\) ' stdout"
26ce71b
26ce71b
        rlRun "getsebool -a >stdout"
26ce71b
26ce71b
        rlRun "grep 'test_bool_on --> on' stdout"
26ce71b
        rlRun "grep 'test_bool_off --> off' stdout"
26ce71b
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> on'"
26ce71b
        rlRun "getsebool $BOOL_OFF | grep '$BOOL_OFF --> off'"
26ce71b
    rlPhaseEnd
26ce71b
26ce71b
    rlPhaseStartTest "setting"
26ce71b
        # temporary via setsebool
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> on'"
26ce71b
26ce71b
        rlRun "setsebool $BOOL_ON off"
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> off'"
26ce71b
26ce71b
        rlRun "setsebool $BOOL_ON on"
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> on'"
26ce71b
26ce71b
        # permanent via setsebool
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> on'"
26ce71b
26ce71b
        rlRun "setsebool -P $BOOL_ON off"
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> off'"
26ce71b
26ce71b
        rlRun "setsebool -P $BOOL_ON on"
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> on'"
26ce71b
26ce71b
        # permanent via semanage boolean
26ce71b
        rlRun "semanage boolean -m $BOOL_ON --off"
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> off'"
26ce71b
        rlRun "semanage boolean -l -C | grep -E '$BOOL_ON *\(off  ,  off\) '"
26ce71b
26ce71b
        rlRun "semanage boolean -m $BOOL_ON --on"
26ce71b
        rlRun "getsebool $BOOL_ON | grep '$BOOL_ON --> on'"
26ce71b
        rlRun "semanage boolean -l -C | grep -E '$BOOL_ON *\(on   ,   on\) '"
26ce71b
    rlPhaseEnd
26ce71b
26ce71b
    rlPhaseStartCleanup
26ce71b
        rlRun "semodule -r test_module"
26ce71b
        rlRun "rm stdout test_module.cil"
26ce71b
    rlPhaseEnd
26ce71b
rlJournalPrintText
26ce71b
rlJournalEnd