mirror of
https://github.com/OpenRC/openrc.git
synced 2024-11-24 02:14:30 +08:00
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=348416
This commit is contained in:
parent
25049d3e80
commit
1d63e85794
@ -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=true
|
||||
f=/proc/self/stat
|
||||
f=/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" = "$b" ]; then
|
||||
if [ "$(VAR=a cat $f)" = "$(VAR=b cat $f)" ]; then
|
||||
eerror "You have cruft in /proc that should be deleted"
|
||||
else
|
||||
einfo "/proc is already mounted, skipping"
|
||||
mountproc=false
|
||||
fi
|
||||
fi
|
||||
unset a b f
|
||||
unset f
|
||||
|
||||
if $mountproc; then
|
||||
procfs="proc"
|
||||
|
Loading…
Reference in New Issue
Block a user