]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
check root candidates more carefully
authorMichal Soltys <soltys@ziu.info>
Mon, 17 Oct 2011 21:36:33 +0000 (23:36 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 19 Oct 2011 12:23:54 +0000 (14:23 +0200)
This is from the following thread:

http://thread.gmane.org/gmane.linux.raid/35753/focus=35795

Additional tests + more specific info.

Signed-off-by: Michal Soltys <soltys@ziu.info>
[harald@redhat.com: usable_root(): relaxed check for root]

modules.d/99base/dracut-lib.sh
modules.d/99base/init

index bc4d7c938f9dc31ddd41488781cfee33822a7d48..2cfaf933fc9bc00c65ec2c02f46ebc48ba985640 100755 (executable)
@@ -544,3 +544,12 @@ foreach_uuid_until() (
 
     return 1
 )
+
+usable_root() {
+    local _d
+    [ -d $1 ] || return 1
+    for _d in proc sys dev; do
+        [ -e "$1"/$_d ] || return 1
+    done
+    return 0
+}
index 06d61a8b18278aa9e0500ec4d77c39a3978a9e0e..556ac681cc70a7f3eb4609611510e51ee4bf1fe2 100755 (executable)
@@ -286,10 +286,18 @@ getarg 'rd.break=mount' 'rdbreak=mount' && emergency_shell -n mount "Break mount
 # be sourced any number of times. As soon as one suceeds, no more are sourced.
 i=0
 while :; do
-    [ -d "$NEWROOT/proc" ] && break;
+    if ismounted "$NEWROOT"; then
+        usable_root "$NEWROOT" && break;
+        umount "$NEWROOT"
+    fi
     for f in $hookdir/mount/*.sh; do
         [ -f "$f" ] && . "$f"
-        [ -d "$NEWROOT/proc" ] && break;
+        if ismounted "$NEWROOT"; then
+            usable_root "$NEWROOT" && break;
+            warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
+            umount "$NEWROOT"
+            rm -f "$f"
+        fi
     done
 
     i=$(($i+1))