Make sure selinuxenabled exists before executing it

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
Dan Walsh 2016-10-17 08:48:14 -04:00
parent 0c7f83dd1f
commit 488216f57b

View file

@ -22,7 +22,7 @@ RUNC_PATH=$(command -v runc || true)
RUNC_BINARY=${RUNC_PATH:-/usr/local/sbin/runc} RUNC_BINARY=${RUNC_PATH:-/usr/local/sbin/runc}
TESTDIR=$(mktemp -d) TESTDIR=$(mktemp -d)
if selinuxenabled; then if [ -e /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
. /etc/selinux/config . /etc/selinux/config
filelabel=$(awk -F'"' '/^file.*=.*/ {print $2}' /etc/selinux/${SELINUXTYPE}/contexts/lxc_contexts) filelabel=$(awk -F'"' '/^file.*=.*/ {print $2}' /etc/selinux/${SELINUXTYPE}/contexts/lxc_contexts)
chcon -R ${filelabel} $TESTDIR chcon -R ${filelabel} $TESTDIR