]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix check whether the rootfs init is usable
authorNorbert Lange <norbert.lange@andritz.com>
Thu, 13 Dec 2018 15:20:30 +0000 (16:20 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Fri, 25 Oct 2019 09:30:43 +0000 (11:30 +0200)
this now correctly handles:
-   plain files
-   relative symlinks
-   absolute symlinks

modules.d/99base/init.sh

index e4f7cff1622221617646f928fa695775deab9fce..1111d09b5a6f198033afc16ace65048b0916130b 100755 (executable)
@@ -277,12 +277,18 @@ getarg 'rd.break=cleanup' -d 'rdbreak=cleanup' && emergency_shell -n cleanup "Br
 source_hook cleanup
 
 # By the time we get here, the root filesystem should be mounted.
-# Try to find init. 
+# Try to find init.
 for i in "$(getarg real_init=)" "$(getarg init=)" $(getargs rd.distroinit=) /sbin/init; do
     [ -n "$i" ] || continue
 
-    __p=$(readlink -f "${NEWROOT}/${i}")
-    if [ -x "$__p" -o -x "${NEWROOT}/${__p}" ]; then
+    __p="${NEWROOT}/${i}"
+    if [ -h "$__p" ]; then
+        # relative links need to be left alone,
+        # while absolute links need to be resolved and prefixed.
+        __pt=$(readlink "$__p")
+        [ "${__pt#/}" = "$__pt" ] || __p="${NEWROOT}/$__pt"
+    fi
+    if [ -x "$__p" ]; then
         INIT="$i"
         break
     fi