This works for me, but it's a gross hack so I'm not going to apply
this version.
Ben.
---
If only one console device is enabled, we can open a shell on that
rather than /dev/console and it will have full control over the tty.
For example, this allows pagers to work.
Unfortunately this depends on 'setsid -c' which is not provided by
busybox or klibc-utils.
Closes: #512679
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
mkinitramfs | 4 ++++
scripts/functions | 21 ++++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/mkinitramfs b/mkinitramfs
index b64c7fb..b818751 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -315,6 +315,10 @@ if [ ! -e "${DESTDIR}/bin/sh" ]; then
copy_exec /bin/sh "${DESTDIR}/bin/"
fi
+# HACK replace busybox setsid with util-linux version
+rm -f "${DESTDIR}/bin/setsid"
+copy_exec /usr/bin/setsid /bin/
+
# Remove any looping or broken symbolic links, since they break cpio.
[ "${verbose}" = y ] && xargs_verbose="-t"
(cd "${DESTDIR}" && find . -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \
diff --git a/scripts/functions b/scripts/functions
index aa53010..7bf346e 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -33,6 +33,8 @@ log_end_msg()
panic()
{
+ local console tty_dev rest setsid
+
if command -v chvt >/dev/null 2>&1; then
chvt 1
fi
@@ -56,7 +58,24 @@ panic()
run_scripts /scripts/panic
- REASON="$@" PS1='(initramfs) ' /bin/sh -i </dev/console >/dev/console 2>&1
+ # Do not use built-in setsid
+ if [ -x /bin/setsid ]; then
+ setsid='/bin/setsid -c'
+ while read console rest; do
+ if [ -z "$tty_dev" ]; then
+ # Single console, so use it directly to enable
+ # full tty control
+ tty_dev="/dev/$console"
+ else
+ # Multiple consoles, so write to them all
+ tty_dev=/dev/console
+ fi
+ done < /proc/consoles
+ else
+ setsid=
+ tty_dev=/dev/console
+ fi
+ REASON="$@" PS1='(initramfs) ' $setsid /bin/sh -i <"$tty_dev" >"$tty_dev" 2>&1
}
maybe_break()
--
Ben Hutchings
I'm always amazed by the number of people who take up solipsism because
they heard someone else explain it. - E*Borg on alt.fan.pratchettAttachment:
signature.asc
Description: This is a digitally signed message part