From d94d68767aab2b05d369092111338e25ba69e027 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 23 May 2007 14:12:06 +0000 Subject: Harden testing of /proc being valid --- sh.Linux/init.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sh.Linux/init.sh b/sh.Linux/init.sh index bbc5e2c6..4aac61b4 100755 --- a/sh.Linux/init.sh +++ b/sh.Linux/init.sh @@ -100,7 +100,24 @@ fi check_statedir /proc # 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" [ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs" 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} eend $? fi +unset mountproc # 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 -- cgit v1.2.3