Feature debug-shell (#1028)
* Changed usb-shell behavior, it wait for some user action before continue booting * Rename usb-shell to debug-shell and changed port to 23 * Add `20-debug-shell.sh` script to static code analysis * Enable eth0 interface in initramfs (qemu) * Add additional script to run a shell in order to be able to kill it from a telnet session
This commit is contained in:
parent
ab99e27262
commit
0c63ff041c
8 changed files with 84 additions and 44 deletions
|
@ -0,0 +1,56 @@
|
|||
#!/bin/sh
|
||||
# shellcheck disable=SC1091
|
||||
. ./init_functions.sh
|
||||
TELNET_PORT=23
|
||||
|
||||
setup_usb_network
|
||||
start_udhcpd
|
||||
|
||||
show_splash /splash-debug-shell.ppm.gz
|
||||
|
||||
echo "Create 'pmos_continue_boot' script"
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo "pkill -f pmos_shell"
|
||||
echo "pkill -f pmos_loop_forever"
|
||||
echo "pkill -f telnetd.*:${TELNET_PORT}"
|
||||
} >/usr/bin/pmos_continue_boot
|
||||
chmod +x /usr/bin/pmos_continue_boot
|
||||
|
||||
echo "Create 'pmos_shell' script"
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo "sh"
|
||||
} >/usr/bin/pmos_shell
|
||||
chmod +x /usr/bin/pmos_shell
|
||||
|
||||
echo "Create 'pmos_loop_forever' script"
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo '. /init_functions.sh'
|
||||
echo "loop_forever"
|
||||
} >/usr/bin/pmos_loop_forever
|
||||
chmod +x /usr/bin/pmos_loop_forever
|
||||
|
||||
echo "Start the telnet daemon"
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo "echo \"Type 'pmos_continue_boot' to continue booting:\""
|
||||
echo "sh"
|
||||
} >/telnet_connect.sh
|
||||
chmod +x /telnet_connect.sh
|
||||
telnetd -b "${IP}:${TELNET_PORT}" -l /telnet_connect.sh
|
||||
|
||||
echo "---"
|
||||
echo "WARNING: debug-shell is active on ${IP}:${TELNET_PORT}."
|
||||
echo "This is a security hole! Only use it for debugging, and"
|
||||
echo "uninstall the debug-shell hook afterwards!"
|
||||
echo "---"
|
||||
|
||||
if tty -s; then
|
||||
echo "Exit the shell to continue booting:"
|
||||
pmos_shell
|
||||
else
|
||||
echo "No tty attached, looping forever."
|
||||
pmos_loop_forever
|
||||
fi
|
16
main/postmarketos-mkinitfs-hook-debug-shell/APKBUILD
Normal file
16
main/postmarketos-mkinitfs-hook-debug-shell/APKBUILD
Normal file
|
@ -0,0 +1,16 @@
|
|||
pkgname=postmarketos-mkinitfs-hook-debug-shell
|
||||
pkgver=0.1.1
|
||||
pkgrel=0
|
||||
pkgdesc="Root shell in the initramfs (security hole, for debugging only)"
|
||||
url="https://github.com/postmarketOS"
|
||||
depends="postmarketos-mkinitfs"
|
||||
source="20-debug-shell.sh"
|
||||
arch="noarch"
|
||||
license="GPL2"
|
||||
|
||||
package() {
|
||||
mkdir -p "$pkgdir"/etc/postmarketos-mkinitfs/hooks/
|
||||
install -Dm644 "$srcdir"/20-debug-shell.sh \
|
||||
"$pkgdir"/etc/postmarketos-mkinitfs/hooks/
|
||||
}
|
||||
sha512sums="30df4a3e2f8a82c8c83e80e645fb10516bfae51bc014c28b7d73d48bd0b2f238c186909a0727e5636cf7087aa1e4a348c83a6cf26e99552cea80922d4086627f 20-debug-shell.sh"
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh
|
||||
. ./init_functions.sh
|
||||
TELNET_PORT=24
|
||||
|
||||
setup_usb_network
|
||||
start_udhcpd
|
||||
telnetd -b "${IP}:${TELNET_PORT}" -l /bin/sh
|
||||
|
||||
echo "---"
|
||||
echo "WARNING: usb shell is active on ${IP}:${TELNET_PORT}."
|
||||
echo "This is a security hole! Only use it for debugging, and"
|
||||
echo "uninstall the usb-shell hook afterwards!"
|
||||
echo "---"
|
|
@ -1,17 +0,0 @@
|
|||
pkgname=postmarketos-mkinitfs-hook-usb-shell
|
||||
pkgver=0.1.0
|
||||
pkgrel=1
|
||||
pkgdesc="Root shell in the initramfs (security hole, for debugging only)"
|
||||
url="https://github.com/postmarketOS"
|
||||
# multipath-tools: kpartx
|
||||
depends="postmarketos-mkinitfs"
|
||||
source="20-usb-shell.sh"
|
||||
arch="noarch"
|
||||
license="GPL2"
|
||||
|
||||
package() {
|
||||
mkdir -p "$pkgdir"/etc/postmarketos-mkinitfs/hooks/
|
||||
install -Dm644 "$srcdir"/20-usb-shell.sh \
|
||||
"$pkgdir"/etc/postmarketos-mkinitfs/hooks/
|
||||
}
|
||||
sha512sums="40c6c445fdd03f8c76ba39075e9112ca963dd832f392e469057b622826f274604ec950bbbb89620c5c88e5d76caa0fa4665e445e33ebe31d4c566d4359d24935 20-usb-shell.sh"
|
|
@ -1,5 +1,5 @@
|
|||
pkgname=postmarketos-mkinitfs
|
||||
pkgver=0.5.4
|
||||
pkgver=0.5.5
|
||||
pkgrel=0
|
||||
pkgdesc="Tool to generate initramfs images for postmarketOS"
|
||||
url="https://github.com/postmarketOS"
|
||||
|
@ -22,6 +22,6 @@ package() {
|
|||
"$pkgdir/sbin/mkinitfs"
|
||||
mkdir -p "$pkgdir/etc/postmarketos-mkinitfs/hooks/"
|
||||
}
|
||||
sha512sums="e1849a13ee696e76dc6c734eda984bcc6a6e2e3d8a62a4df0778a8e338dc0bf9d967fa263ae6e57c14a0cb516c6004c6e251262a1711ad47f1ce4c622727a1d7 init.sh.in
|
||||
1512d052890d6d8528f6dbca90eacd76664b56a00c24c980a5be900fdf290f24dbf42c8f3ebf43ea2c832046b4a81ed5d69401ddf5cea2516f8265b083a15ff3 init_functions.sh
|
||||
76d0f11fbd7207e3fc7382d2cc554c280a015157b182fe6ddfc31d861066cfba2be39ebc05970207853c9fae81f950c361cae4aaeafff0873ce99f2c3268ad8f mkinitfs.sh"
|
||||
sha512sums="9eaf7c1fa3bd8c4e065b523dbdf98cd5d002629c1691d388feca8ae7784ffc8e901d92265d6538fd92689483673a65e175e8b8b2c893bbe5746a07ff20a65e82 init.sh.in
|
||||
cf2bbf7908032bee827676fe218bebc0171a84417f9e93cf20809b3d9392f4d0d84c33023960519170024d5c38e392d39a77640dbeed324fa4f96a71798920ad init_functions.sh
|
||||
5bb521186c5f6586136ab3edb13d2ba44c00a84e9d18f255f5e92305bf78ff5aa9bd414d7a50eda4168e5c6eadd87d62fd4169f370fd18e0ebd291fcf2103a9f mkinitfs.sh"
|
||||
|
|
|
@ -30,7 +30,7 @@ set_framebuffer_mode
|
|||
show_splash /splash-loading.ppm.gz
|
||||
|
||||
# Always run dhcp daemon/usb networking for now (later this should only
|
||||
# be enabled, when having the usb-shell hook installed for debugging,
|
||||
# be enabled, when having the debug-shell hook installed for debugging,
|
||||
# or get activated after the initramfs is done with an OpenRC service).
|
||||
setup_usb_network
|
||||
start_udhcpd
|
||||
|
@ -55,6 +55,6 @@ umount /dev
|
|||
exec switch_root /sysroot /sbin/init
|
||||
|
||||
echo "ERROR: switch_root failed!"
|
||||
echo "Looping forever. Install and use the usb-shell hook to debug this."
|
||||
echo "For more information, see <https://postmarketos.org/usbhook>"
|
||||
echo "Looping forever. Install and use the debug-shell hook to debug this."
|
||||
echo "For more information, see <https://postmarketos.org/debug-shell>"
|
||||
loop_forever
|
||||
|
|
|
@ -240,6 +240,9 @@ start_udhcpd() {
|
|||
if [ -z $INTERFACE ]; then
|
||||
ifconfig usb0 "$IP" && INTERFACE=usb0
|
||||
fi
|
||||
if [ -z $INTERFACE ]; then
|
||||
ifconfig eth0 "$IP" && INTERFACE=eth0
|
||||
fi
|
||||
|
||||
# Create /etc/udhcpd.conf
|
||||
{
|
||||
|
@ -277,12 +280,6 @@ show_splash() {
|
|||
fbsplash -s /tmp/splash.ppm
|
||||
}
|
||||
|
||||
echo_connect_ssh_message() {
|
||||
echo "Your root partition has been decrypted successfully!"
|
||||
echo "You can connect to your device using SSH in a few seconds:"
|
||||
echo "ssh user@$IP"
|
||||
}
|
||||
|
||||
start_msm_refresher() {
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
if [ "${deviceinfo_msm_refresher}" = "true" ]; then
|
||||
|
|
|
@ -240,7 +240,8 @@ generate_splash_screens()
|
|||
"splash-noboot" "boot partition not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
||||
"splash-noinitramfsextra" "initramfs-extra not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
||||
"splash-nosystem" "system partition not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
||||
"splash-mounterror" "unable to mount root partition\\nhttps://postmarketos.org/troubleshooting" "--center"
|
||||
"splash-mounterror" "unable to mount root partition\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
||||
"splash-debug-shell" "WARNING\\ndebug-shell is active\\nhttps://postmarketos.org/debug-shell" "--center"
|
||||
|
||||
# Ensure cache folder exists
|
||||
mkdir -p "${splash_cache_dir}"
|
||||
|
|
Loading…
Reference in a new issue