From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Q2ujg-0005yM-4w for garchives@archives.gentoo.org; Fri, 25 Mar 2011 00:18:40 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 20E4E1C083; Fri, 25 Mar 2011 00:18:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E115E1C083 for ; Fri, 25 Mar 2011 00:18:31 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 63E8D1B418C for ; Fri, 25 Mar 2011 00:18:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id BD3A98006A for ; Fri, 25 Mar 2011 00:18:30 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1d63e85794ad850752eec95fa077e5895295f3b7.williamH@gentoo> Subject: [gentoo-commits] proj/openrc:master commit in: sh/ X-VCS-Repository: proj/openrc X-VCS-Files: sh/init.sh.Linux.in X-VCS-Directories: sh/ X-VCS-Committer: williamH X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 1d63e85794ad850752eec95fa077e5895295f3b7 Date: Fri, 25 Mar 2011 00:18:30 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 255c04c9f0e0e8941d96617fd1362674 commit: 1d63e85794ad850752eec95fa077e5895295f3b7 Author: William Hubbs gentoo org> AuthorDate: Thu Mar 24 23:27:35 2011 +0000 Commit: William Hubbs gentoo org> CommitDate: Fri Mar 25 00:14:16 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3D1d63e857 rework test for mounted /proc The previous test assumed that we could always rely on the minor fault counter to change between reads of /proc/self/stat, but we found that this is not the case. The new test compares two reads of /proc/self/environ for which we have set the same environment variable to two different values. If the comparison shows the two reads have the same contents, we know that /proc is not working. I would like to thank Robin Johnson and Mike Frysinger for their input for this patch. X-Gentoo-Bug: 348416 X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=3D348416 --- sh/init.sh.Linux.in | 20 +++++++------------- 1 files changed, 7 insertions(+), 13 deletions(-) diff --git a/sh/init.sh.Linux.in b/sh/init.sh.Linux.in index 9b04557..361de0b 100644 --- a/sh/init.sh.Linux.in +++ b/sh/init.sh.Linux.in @@ -65,27 +65,21 @@ mount_svcdir() # By default VServer already has /proc mounted, but OpenVZ does not! # 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 two reads of -# /proc/self/stat. They will not match, because at least the minor fault= count -# field (field 10) should have changed. -# -# We can use any file here that fills the following requirements: -# - changes between sequential reads -# - is world-readable (not blocked in hardened kernel) -# - Is only a single line (ergo entire check is doable with no forks) +# /proc actually works or not. We do this by comparing two reads of +# /proc/self/environ for which we have set the variable VAR to two +# different values. If the comparison comes back equal, we know that +# /proc is not working. mountproc=3Dtrue -f=3D/proc/self/stat +f=3D/proc/self/environ if [ -e $f ]; then - exec 9<$f ; read a <&9 ; exec 9<&- - exec 9<$f ; read b <&9 ; exec 9<&- - if [ "$a" =3D "$b" ]; then + if [ "$(VAR=3Da cat $f)" =3D "$(VAR=3Db cat $f)" ]; then eerror "You have cruft in /proc that should be deleted" else einfo "/proc is already mounted, skipping" mountproc=3Dfalse fi fi -unset a b f +unset f =20 if $mountproc; then procfs=3D"proc"