Harden testing of /proc being valid
This commit is contained in:
parent
f754cfd2a9
commit
d94d68767a
@ -100,7 +100,24 @@ fi
|
|||||||
check_statedir /proc
|
check_statedir /proc
|
||||||
|
|
||||||
# By default VServer already has /proc mounted, but OpenVZ does not!
|
# By default VServer already has /proc mounted, but OpenVZ does not!
|
||||||
if [ ! -e /proc/self/stat ] ; then
|
# However, some of our users have an old proc image in /proc
|
||||||
|
# NFC how they managed that, but the end result means we have to test if
|
||||||
|
# /proc actually works or not. We to this by comparing uptime to one a second
|
||||||
|
# ago
|
||||||
|
mountproc=true
|
||||||
|
if [ -e /proc/uptime ] ; then
|
||||||
|
up="$(cat /proc/uptime)"
|
||||||
|
sleep 1
|
||||||
|
if [ "${up}" = "$(cat /proc/uptime)" ] ; then
|
||||||
|
eerror "You have cruft in /proc that should be deleted"
|
||||||
|
else
|
||||||
|
einfo "/proc is already mounted, skipping"
|
||||||
|
mountproc=false
|
||||||
|
fi
|
||||||
|
unset up
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ${mountproc} ; then
|
||||||
procfs="proc"
|
procfs="proc"
|
||||||
[ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs"
|
[ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs"
|
||||||
ebegin "Mounting ${procfs} at /proc"
|
ebegin "Mounting ${procfs} at /proc"
|
||||||
@ -108,6 +125,7 @@ if [ ! -e /proc/self/stat ] ; then
|
|||||||
try mount -n ${mntcmd:--t ${procfs} -o noexec,nosuid,nodev proc /proc}
|
try mount -n ${mntcmd:--t ${procfs} -o noexec,nosuid,nodev proc /proc}
|
||||||
eend $?
|
eend $?
|
||||||
fi
|
fi
|
||||||
|
unset mountproc
|
||||||
|
|
||||||
# Read off the kernel commandline to see if there's any special settings
|
# Read off the kernel commandline to see if there's any special settings
|
||||||
# especially check to see if we need to set the CDBOOT environment variable
|
# especially check to see if we need to set the CDBOOT environment variable
|
||||||
|
Loading…
Reference in New Issue
Block a user