From: Norbert Lange Date: Thu, 13 Dec 2018 15:20:30 +0000 (+0100) Subject: fix check whether the rootfs init is usable X-Git-Tag: 050~124 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1aa2d1eddf06b686340f64283110b585b4166330;p=thirdparty%2Fdracut.git fix check whether the rootfs init is usable this now correctly handles: - plain files - relative symlinks - absolute symlinks --- diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh index e4f7cff16..1111d09b5 100755 --- a/modules.d/99base/init.sh +++ b/modules.d/99base/init.sh @@ -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