]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(99base): adjust to allow mksh as initrd shell
authorFrederick Grose <fgrose@sugarlabs.org>
Tue, 28 Mar 2023 02:16:04 +0000 (22:16 -0400)
committerAntonio Álvarez Feijoo <antonio.feijoo@suse.com>
Wed, 29 Mar 2023 06:11:36 +0000 (08:11 +0200)
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.)

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

index 0df22b82cb4bd0b086b7967b05c815cd2eb91ffe..63265f21013183fbc94eaff6fb8a9e27b6bca279 100755 (executable)
@@ -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
index 344455596e631d8412f2d4e7f7739eb4baf77f32..ca1df90d570e7b02e64c6f8fb74d2073c9eb823f 100755 (executable)
@@ -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
         }