fix selinux context for rc-svcdir (bug #347503)

This commit is contained in:
Robin Johnson 2010-12-03 23:49:34 -06:00 committed by William Hubbs
parent 449080e145
commit 80d5f7d27b

View File

@ -6,6 +6,17 @@
# This basically mounts $RC_SVCDIR as a ramdisk. # This basically mounts $RC_SVCDIR as a ramdisk.
# The tricky part is finding something our kernel supports # The tricky part is finding something our kernel supports
# tmpfs and ramfs are easy, so force one or the other. # tmpfs and ramfs are easy, so force one or the other.
svcdir_restorecon()
{
local rc=0
if [ -x /usr/sbin/selinuxenabled -a -c /selinux/null ] &&
selinuxenabled; then
restorecon $RC_SVCDIR
rc=$?
fi
return $rc
}
mount_svcdir() mount_svcdir()
{ {
# mount from fstab if we can # mount from fstab if we can
@ -16,8 +27,12 @@ mount_svcdir()
# Some buggy kernels report tmpfs even when not present :( # Some buggy kernels report tmpfs even when not present :(
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
mount -n -t tmpfs $fsopts,mode=755,size=${svcsize}k \ local tmpfsopts="${fsopts},mode=755,size=${svcsize}k"
rc-svcdir "$RC_SVCDIR" && return 0 mount -n -t tmpfs $tmpfsopts rc-svcdir "$RC_SVCDIR"
if [ $? -eq 0 ]; then
svcdir_restorecon
[ $? -eq 0 ] && return 0
fi
fi fi
if grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then if grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
@ -38,6 +53,10 @@ mount_svcdir()
fi fi
mount -n -t "$fs" $fsopts rc-svcdir "$RC_SVCDIR" mount -n -t "$fs" $fsopts rc-svcdir "$RC_SVCDIR"
if [ $? -eq 0 ]; then
svcdir_restorecon
[ $? -eq 0 ] && return 0
fi
} }
. "$RC_LIBEXECDIR"/sh/functions.sh . "$RC_LIBEXECDIR"/sh/functions.sh