psss / rpms / libselinux

Forked from rpms/libselinux 5 years ago
Clone
aba7ab1
#!/bin/bash
aba7ab1
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
aba7ab1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aba7ab1
#
aba7ab1
#   runtest.sh of /CoreOS/libselinux/Sanity/getsebool
aba7ab1
#   Description: Does getsebool work as expected?
aba7ab1
#   Author: Milos Malik <mmalik@redhat.com>
aba7ab1
#
aba7ab1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aba7ab1
#
aba7ab1
#   Copyright (c) 2017 Red Hat, Inc.
aba7ab1
#
aba7ab1
#   This copyrighted material is made available to anyone wishing
aba7ab1
#   to use, modify, copy, or redistribute it subject to the terms
aba7ab1
#   and conditions of the GNU General Public License version 2.
aba7ab1
#
aba7ab1
#   This program is distributed in the hope that it will be
aba7ab1
#   useful, but WITHOUT ANY WARRANTY; without even the implied
aba7ab1
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
aba7ab1
#   PURPOSE. See the GNU General Public License for more details.
aba7ab1
#
aba7ab1
#   You should have received a copy of the GNU General Public
aba7ab1
#   License along with this program; if not, write to the Free
aba7ab1
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
aba7ab1
#   Boston, MA 02110-1301, USA.
aba7ab1
#
aba7ab1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aba7ab1
aba7ab1
# Include Beaker environment
aba7ab1
. /usr/share/beakerlib/beakerlib.sh || exit 1
aba7ab1
aba7ab1
PACKAGE="libselinux"
aba7ab1
if rlIsRHEL 5 6 ; then
aba7ab1
    SELINUX_FS_MOUNT="/selinux"
aba7ab1
else # RHEL-7 and above
aba7ab1
    SELINUX_FS_MOUNT="/sys/fs/selinux"
aba7ab1
fi
aba7ab1
aba7ab1
rlJournalStart
aba7ab1
    rlPhaseStartSetup
aba7ab1
        rlAssertRpm ${PACKAGE}
aba7ab1
        rlAssertRpm ${PACKAGE}-utils
aba7ab1
        rlRun "getsebool" 0,1
aba7ab1
        OUTPUT_FILE=`mktemp`
aba7ab1
    rlPhaseEnd
aba7ab1
aba7ab1
    rlPhaseStartTest 
aba7ab1
        rlRun "getsebool -a"
aba7ab1
        rlRun "umount ${SELINUX_FS_MOUNT}"
aba7ab1
        rlRun "getsebool -a 2>&1 | tee ${OUTPUT_FILE}"
aba7ab1
        rlAssertGrep "selinux.*disabled" ${OUTPUT_FILE} -i
aba7ab1
        rlRun "mount -t selinuxfs none ${SELINUX_FS_MOUNT}"
aba7ab1
        rlRun "mkdir booleans"
aba7ab1
        rlRun "mount --bind ./booleans ${SELINUX_FS_MOUNT}/booleans"
aba7ab1
        rlRun "getsebool -a 2>&1 | tee ${OUTPUT_FILE}"
aba7ab1
        rlAssertGrep "unable to get boolean name.*no such file or directory" ${OUTPUT_FILE} -i
aba7ab1
        rlRun "getsebool xen_use_nfs 2>&1 | tee ${OUTPUT_FILE}"
aba7ab1
        rlAssertGrep "error getting active value for" ${OUTPUT_FILE} -i
aba7ab1
        rlRun "umount ${SELINUX_FS_MOUNT}/booleans"
aba7ab1
        rlRun "rmdir booleans"
aba7ab1
    rlPhaseEnd
aba7ab1
aba7ab1
    rlPhaseStartCleanup
aba7ab1
        rm -f ${OUTPUT_FILE}
aba7ab1
    rlPhaseEnd
aba7ab1
rlJournalPrintText
aba7ab1
rlJournalEnd
aba7ab1