Skip to content

Commit

Permalink
Add dual support for real bash and busybox's bash(ash)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlaurion committed Feb 10, 2023
1 parent 6ae2699 commit 3d65a74
Show file tree
Hide file tree
Showing 49 changed files with 62 additions and 60 deletions.
2 changes: 1 addition & 1 deletion initrd/bin/cbfs-init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/ash
#!/bin/bash
set -e -o pipefail
. /etc/functions

Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/cbfs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e -o pipefail
. /etc/functions
. /tmp/config
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/config-gui.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
set -e -o pipefail
. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/flash-gui.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
set -e -o pipefail
. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/flash.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# based off of flashrom-x230
#
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/flashrom-kgpe-d16-openbmc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
. /etc/functions

ROM="$1"
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/generic-init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Boot from a local disk installation

. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/gpg-gui.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
set -e -o pipefail
. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/gpgv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
#!/bin/bash
# if we are using the full GPG we need a wrapper for the gpgv executable
exec gpg --verify "$@"
2 changes: 1 addition & 1 deletion initrd/bin/gui-init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Boot from a local disk installation

BOARD_NAME=${CONFIG_BOARD_NAME:-${CONFIG_BOARD}}
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-boot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Launches kexec from saved configuration entries
set -e -o pipefail
. /tmp/config
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-insert-key
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Unseal a disk key from TPM and add to a new initramfs
set -e -o pipefail
. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-iso-init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Boot from signed ISO
set -e -o pipefail
. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-parse-bls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e -o pipefail
bootdir="$1"
file="$2"
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-parse-boot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e -o pipefail
bootdir="$1"
file="$2"
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-save-default
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Save these options to be the persistent default
set -e -o pipefail
. /tmp/config
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-save-key
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Generate a TPM key used to unlock LUKS disks
set -e -o pipefail
. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-seal-key
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# This will generate a disk encryption key and seal / ecncrypt
# with the current PCRs and then store it in the TPM NVRAM.
# It will then need to be bundled into initrd that is booted.
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-select-boot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Generic configurable boot script via kexec
set -e -o pipefail
. /tmp/config
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-sign-config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Sign a valid directory of kexec params
set -e -o pipefail
. /tmp/config
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-unseal-key
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# This will unseal and unecncrypt the drive encryption key from the TPM
# The TOTP secret will be shown to the user on each encryption attempt.
# It will then need to be bundled into initrd that is booted with Qubes.
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/key-init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/ash
#!/bin/bash
set -e -o pipefail
. /etc/functions

Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/media-scan
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Scan for USB installation options
set -e -o pipefail
. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/mount-usb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Mount a USB device
. /etc/functions

Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/network-init-recovery
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/ash
#!/bin/bash

. /etc/functions

Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/oem-factory-reset
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Automated setup of TPM, GPG keys, and disk

set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/oem-system-info-xx30
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# System Info

BOARD_NAME=${CONFIG_BOARD_NAME:-${CONFIG_BOARD}}
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/poweroff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Sync all mounted filesystems
echo s > /proc/sysrq-trigger
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/qubes-measure-luks
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Measure all of the luks disk encryption headers into
# a PCR so that we can detect disk swap attacks.

Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/reboot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Sync all mounted filesystems
echo s > /proc/sysrq-trigger
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/seal-hotpkey
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Retrieve the sealed TOTP secret and initialize a USB Security dongle with it

. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/seal-totp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Generate a random secret, seal it with the PCRs
# and write it to the TPM NVRAM.
#
Expand Down
4 changes: 2 additions & 2 deletions initrd/bin/t430-flash.init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Initialize the USB and network device drivers,
# invoke a recovery shell and prompt the user for how to proceed

Expand All @@ -23,4 +23,4 @@ echo ' mount -o ro /dev/sdb1 /media'
echo ' flash.sh /media/t430.rom'
echo ''

exec /bin/ash
exec /bin/bash
2 changes: 1 addition & 1 deletion initrd/bin/tpm-reset
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
. /etc/functions

if [ "$CONFIG_TPM" = "y" ]; then
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/tpmr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# TPM Wrapper - to unify tpm and tpm2 subcommands

. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/uefi-init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/ash
#!/bin/bash
set -e -o pipefail
. /etc/functions

Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/unseal-hotp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Retrieve the sealed file and counter from the NVRAM, unseal it and compute the hotp

. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/unseal-totp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Retrieve the sealed file from the NVRAM, unseal it and compute the totp

. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/usb-init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Boot a USB installation

. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/wget-measure.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# get a file and extend a TPM PCR

die() {
Expand Down
4 changes: 2 additions & 2 deletions initrd/bin/x230-flash.init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Initialize the USB and network device drivers,
# invoke a recovery shell and prompt the user for how to proceed

Expand All @@ -23,4 +23,4 @@ echo ' mount -o ro /dev/sdb1 /media'
echo ' flash.sh /media/x230.rom'
echo ''

exec /bin/ash
exec /bin/bash
6 changes: 3 additions & 3 deletions initrd/etc/functions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Shell functions for most initialization scripts

die() {
Expand Down Expand Up @@ -36,9 +36,9 @@ recovery() {
sleep 1

if [ -x /bin/setsid ]; then
/bin/setsid -c /bin/ash
/bin/setsid -c /bin/bash
else
/bin/ash
/bin/bash
fi
done
}
Expand Down
2 changes: 1 addition & 1 deletion initrd/etc/gui_functions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Shell functions for common operations using fbwhiptail

mount_usb()
Expand Down
2 changes: 1 addition & 1 deletion initrd/etc/luks-functions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Reencrypt LUKS container and change Disk Recovery Key associated passphrase (Slot 0: main slot)

. /etc/functions
Expand Down
2 changes: 1 addition & 1 deletion initrd/etc/passwd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
root:x:0:0:root:/:/bin/ash
root:x:0:0:root:/:/bin/bash
18 changes: 10 additions & 8 deletions initrd/init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/ash
#!/bin/bash
mknod /dev/ttyprintk c 5 3
echo "hello world" > /dev/ttyprintk

Expand Down Expand Up @@ -30,12 +30,14 @@ if [ ! -r /dev/ptmx ]; then
ln -s /dev/pts/ptmx /dev/ptmx
fi


[ -a /dev/stdin ] || ln -s /proc/self/fd/0 /dev/stdin
[ -a /dev/stdout ] || ln -s /proc/self/fd/1 /dev/stdout
[ -a /dev/stderr ] || ln -s /proc/self/fd/2 /dev/stderr
# Needed by bash
[ -a /dev/fd ] || ln -s /proc/self/fd /dev/fd
if ! [ -L /bin/bash ]; then
# /bin/bash is not a symbolink link (not busybox)
[ -a /dev/stdin ] || ln -s /proc/self/fd/0 /dev/stdin
[ -a /dev/stdout ] || ln -s /proc/self/fd/1 /dev/stdout
[ -a /dev/stderr ] || ln -s /proc/self/fd/2 /dev/stderr
[ -a /dev/fd ] || ln -s /proc/self/fd /dev/fd
fi

# Recovery shells will erase anything from here
mkdir -p /tmp/secret
Expand Down Expand Up @@ -114,7 +116,7 @@ if [ "$boot_option" = "r" ]; then
if [ "$CONFIG_TPM" = "y" -o "$CONFIG_TPM2_TOOLS" = "y" ]; then
tpmr extend -ix 4 -ic recovery
fi
exec /bin/ash
exec /bin/bash
exit
fi

Expand Down Expand Up @@ -171,4 +173,4 @@ fi
if [ "$CONFIG_TPM" = "y" -o "$CONFIG_TPM2_TOOLS" = y ]; then
tpmr extend -ix 4 -ic recovery
fi
exec /bin/ash
exec /bin/bash
2 changes: 1 addition & 1 deletion initrd/mount-boot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Extract the GPG signed dmsetup configuration from
# the header of the file system, validate it against
# the trusted key database, and execute it to mount
Expand Down
2 changes: 1 addition & 1 deletion initrd/sbin/config-dhcp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# udhcpc script

Expand Down
2 changes: 1 addition & 1 deletion initrd/sbin/insmod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# extend a TPM PCR with a module and then load it
# any arguments will also be measured.
# The default PCR to be extended is 5, but can be
Expand Down

0 comments on commit 3d65a74

Please sign in to comment.