oracle: fix chcon warning when selinux disabled

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
Dwight Engen 2013-12-06 09:46:19 -05:00 committed by Stéphane Graber
parent 64994c030c
commit 341c971806

View File

@ -46,6 +46,15 @@ is_btrfs_subvolume()
return 1 return 1
} }
can_chcon()
{
if which chcon >/dev/null 2>&1; then
selinuxenabled >/dev/null 2>&1
return $?
fi
return 1
}
# fix up the container_rootfs # fix up the container_rootfs
container_rootfs_configure() container_rootfs_configure()
{ {
@ -312,7 +321,7 @@ EOF
if [ $container_rootfs != "/" -a -d $dev_path ]; then if [ $container_rootfs != "/" -a -d $dev_path ]; then
rm -rf $dev_path rm -rf $dev_path
mkdir -p $dev_path mkdir -p $dev_path
if which chcon >/dev/null 2>&1 ; then if can_chcon; then
# ensure symlinks created in /dev have the right context # ensure symlinks created in /dev have the right context
chcon -t device_t $dev_path chcon -t device_t $dev_path
fi fi
@ -333,7 +342,7 @@ EOF
mknod -m 600 $dev_path/initctl p mknod -m 600 $dev_path/initctl p
# set selinux labels same as host # set selinux labels same as host
if which chcon >/dev/null 2>&1 ; then if can_chcon; then
for node in null zero random urandom pts shm \ for node in null zero random urandom pts shm \
tty tty0 tty1 tty2 tty3 tty4 full ; tty tty0 tty1 tty2 tty3 tty4 full ;
do do