From 58faaa5b1d4339c23b0da83577823f70b9cd414f Mon Sep 17 00:00:00 2001 From: ading2210 Date: Fri, 10 Nov 2023 23:49:59 -0800 Subject: [PATCH] improve crossystem implementation --- README.md | 2 +- bootloader/bin/bootstrap.sh | 7 +++-- bootloader/opt/crossystem | 53 +++++++++++++++++-------------------- website/index.html | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 24209ac..745ca48 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Driver support depends on the device you are using shimboot on. This list is for 3. Enable developer mode on your Chromebook. If the Chromebook is enrolled, follow the instructions on the [sh1mmer website](https://sh1mmer.me) (see the "Executing on Chromebook" section). 4. Plug the USB into your Chromebook and enter recovery mode. It should detect the USB and run the shimboot bootloader. 5. Boot into Debian and log in with the username and password that you configured earlier. The default username/password for the prebuilt images is `user/user`. -6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX` to expand the filesystem. +6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX4` to expand the filesystem. ## FAQ: diff --git a/bootloader/bin/bootstrap.sh b/bootloader/bin/bootstrap.sh index e2771b3..a24eeef 100755 --- a/bootloader/bin/bootstrap.sh +++ b/bootloader/bin/bootstrap.sh @@ -243,7 +243,7 @@ get_donor_selection() { if [ "$selection" = "$i" ]; then echo "selected $part_path as the donor partition" - read -p "would you like to spoof verfied mode? this is useful if you're planning on using chrome os while enrolled. (y/n): " use_crossystem + read -p "would you like to spoof verified mode? this is useful if you're planning on using chrome os while enrolled. (y/n): " use_crossystem if [ "$use_crossystem" = "y" ] || [ "$use_crossystem" = "n" ]; then boot_chromeos $target $part_path $use_crossystem @@ -306,9 +306,12 @@ boot_chromeos() { rm -rf $donor_mount if [ -e "/newroot/etc/init/tpm-probe.conf" ]; then - echo "hiding the tpm from upstart" + echo "applying chrome os flex patches" mkdir -p /newroot/tmp/empty mount -o bind /newroot/tmp/empty /sys/class/tpm + + cat /newroot/etc/lsb-release | sed "s/DEVICETYPE=OTHER/DEVICETYPE=CHROMEBOOK/" > /newroot/tmp/lsb-release + mount -o bind /newroot/tmp/lsb-release /newroot/etc/lsb-release fi echo "patching chrome os rootfs" diff --git a/bootloader/opt/crossystem b/bootloader/opt/crossystem index 9a6a087..26706e5 100755 --- a/bootloader/opt/crossystem +++ b/bootloader/opt/crossystem @@ -3,27 +3,23 @@ #a much cleaner implemenation of fakemurk's crossystem.sh crossystem_old=/tmp/crossystem_old -crossystem_dict="cros_debug 0 -dev_boot_legacy 0 -dev_boot_signed_only 1 -dev_boot_usb 0 -devsw_boot 0 -devsw_cur 0 -block_devmode 1 -mainfw_act A -mainfw_type normal -recovery_reason 0 -recovery_request 0 -recoverysw_boot 0 -recoverysw_cur 0" - -dict_set() { - local newline=$'\n' - crossystem_dict="$crossystem_dict$newline$1 $2" -} +declare -A crossystem_dict=( + ["cros_debug"]="1" + ["dev_boot_legacy"]="0" + ["dev_boot_signed_only"]="1" + ["devsw_boot"]="0" + ["devsw_cur"]="0" + ["block_devmode"]="1" + ["mainfw_act"]="A" + ["mainfw_type"]="normal" + ["recovery_reason"]="0" + ["recovery_request"]="0" + ["recoverysw_boot"]="0" + ["recoverysw_cur"]="0" +) dict_get() { - echo "$crossystem_dict" | grep "^$1 " | cut -d " " -f 2- + echo "${crossystem_dict[$1]}" } parse_arg() { @@ -37,13 +33,13 @@ parse_arg() { elif [[ "$arg" =~ "?" ]]; then key=$(echo $arg | cut -d "?" -f 1) query=$(echo $arg | cut -d "?" -f 2) - if ! [ "$(dict_get $key)" = "$query" ]; then + if ! [ "${crossystem_dict[$key]}" = "$query" ]; then exit 1 fi #get value mode - elif [ "$(dict_get $arg)" ]; then - printf "$(dict_get $arg)" + elif [ "${crossystem_dict[$arg]}" ]; then + printf "${crossystem_dict[$arg]}" #value not found - print help and exit else @@ -60,18 +56,19 @@ while IFS= read -r line; do line=$(echo $line | cut -d "#" -f 1) key=$(echo $line | cut -d "=" -f 1 | xargs) value=$(echo $line | cut -d "=" -f 2 | xargs) - if [ -z "$(dict_get $key)" ]; then - dict_set "$key" "$value" + if [ -z "${crossystem_dict[$key]}" ]; then + crossystem_dict["$key"]="$value" fi done <<< "$crossystem_out" #crossystem called with no arguments, print out all properties if [ -z "$1" ] || [ "$1" = "--all" ]; then - while IFS= read -r line; do - key=$(echo $line | cut -d " " -f 1) - value=$(echo $line | cut -d " " -f 2-) + keys="${!crossystem_dict[@]}" + keys="$(echo "$keys" | tr " " "\n" | sort)" + for key in $keys; do + value="${crossystem_dict[$key]}" echo "$key = $value" - done <<< "$crossystem_dict" + done exit 0 fi diff --git a/website/index.html b/website/index.html index 2171bda..c16844a 100644 --- a/website/index.html +++ b/website/index.html @@ -87,7 +87,7 @@ For these images, the root password is "root". The name of the default user is " 3. Enable developer mode on your Chromebook. If the Chromebook is enrolled, follow the instructions on the sh1mmer website (see the "Executing on Chromebook" section). 4. Plug the USB into your Chromebook and enter recovery mode. It should detect the USB and run the shimboot bootloader. 5. Boot into Debian and log in with the username and password that you configured earlier. The default username/password for the prebuilt images is `user/user`. -6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX` to expand the filesystem. +6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX4` to expand the filesystem. Copyright: Shimboot is licensed under the GNU GPL v3. Unless otherwise indicated, all code has been written by me, ading2210.