From: Frederick Grose Date: Tue, 28 Mar 2023 02:16:04 +0000 (-0400) Subject: fix(99base): adjust to allow mksh as initrd shell X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a0d14d3bc691b318507c01708bc67d9e3b9d5109;p=thirdparty%2Fdracut.git fix(99base): adjust to allow mksh as initrd shell Use printf instead of echo in str_replace() to preserve escapes. Find command paths while PATH includes /usr/sbin. (switch_root was not found after the original environment is restored on Fedora.) --- diff --git a/modules.d/99base/dracut-dev-lib.sh b/modules.d/99base/dracut-dev-lib.sh index 0df22b82c..63265f210 100755 --- a/modules.d/99base/dracut-dev-lib.sh +++ b/modules.d/99base/dracut-dev-lib.sh @@ -17,7 +17,7 @@ str_replace() { out="${out}${chop}$r" in="${in#*"$s"}" done - echo "${out}${in}" + printf -- '%s' "${out}${in}" } # get a systemd-compatible unit name from a path diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh index 344455596..ca1df90d5 100755 --- a/modules.d/99base/init.sh +++ b/modules.d/99base/init.sh @@ -299,6 +299,9 @@ udevadm info --cleanup-db debug_off # Turn off debugging for this section +CAPSH=$(command -v capsh) +SWITCH_ROOT=$(command -v switch_root) + # unexport some vars export_n root rflags fstype netroot NEWROOT unset CMDLINE @@ -370,8 +373,6 @@ info "Switching root" unset PS4 -CAPSH=$(command -v capsh) -SWITCH_ROOT=$(command -v switch_root) PATH=$OLDPATH export PATH @@ -380,10 +381,10 @@ if [ -f /etc/capsdrop ]; then info "Calling $INIT with capabilities $CAPS_INIT_DROP dropped." unset RD_DEBUG exec "$CAPSH" --drop="$CAPS_INIT_DROP" -- \ - -c "exec switch_root \"$NEWROOT\" \"$INIT\" $initargs" \ + -c "exec \"$SWITCH_ROOT\" \"$NEWROOT\" \"$INIT\" $initargs" \ || { warn "Command:" - warn capsh --drop="$CAPS_INIT_DROP" -- -c exec switch_root "$NEWROOT" "$INIT" "$initargs" + warn capsh --drop="$CAPS_INIT_DROP" -- -c exec "$SWITCH_ROOT" "$NEWROOT" "$INIT" "$initargs" warn "failed." emergency_shell }