From 1aa2d1eddf06b686340f64283110b585b4166330 Mon Sep 17 00:00:00 2001 From: Norbert Lange Date: Thu, 13 Dec 2018 16:20:30 +0100 Subject: [PATCH] fix check whether the rootfs init is usable this now correctly handles: - plain files - relative symlinks - absolute symlinks --- modules.d/99base/init.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 -- 2.47.3