From a98a26129413ba796de32e03702e9d50b42048b4 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 4 Dec 2018 14:38:55 +0100 Subject: [slx-part] sanitize crypt & fix snapshot fallback --- builder/modules.d/slx-partitioner/scripts/slx_partitioner | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/builder/modules.d/slx-partitioner/scripts/slx_partitioner b/builder/modules.d/slx-partitioner/scripts/slx_partitioner index 8c003787..db17399b 100755 --- a/builder/modules.d/slx-partitioner/scripts/slx_partitioner +++ b/builder/modules.d/slx-partitioner/scripts/slx_partitioner @@ -77,8 +77,12 @@ parse_config() { max=$(( $max * ( 1024 ** $potency) / 512 )) ;; esac + if ! [[ "$crypt" =~ ^[01]$ ]]; then + echo "$0: Disabling encryption due to invalid crypt argument: $line" + crypt=0 + fi # finally save it to the global array for this type - eval "${type}"'+=("'${name} ${crypt:-0} ${min} ${max}'")' + eval "${type}"'+=("'${name} ${crypt} ${min} ${max}'")' done <<< "$1" } @@ -135,7 +139,6 @@ ramdisk_fallback() { while [ -b "/dev/mapper/$cow_device_candidate" ]; do cow_device_candidate="root.$RANDOM" done - # TODO fallback on thin-snapshot and not snapshot if [ -z "$writable_device" ] || ! create_snapshot "$cow_device_candidate N"; then emergency_shell "CRITICAL: failed to setup RAMdisk fallback." exit 1 @@ -184,7 +187,7 @@ if [ -n "$SLX_WRITABLE_DEVICE_PARTITION_TABLE" ]; then fi # Default to thin-snapshot, if none were configured if [ -z "$snapshot" ] && [ -z "$thin_snapshot" ]; then - thin_snapshot="thin-snapshot root 10G 0" + parse_config "thin-snapshot root 10G 0" fi # Sanity checks for weird configurations @@ -208,7 +211,7 @@ fi # start allocating spaces to the configured devices declare -g writable_device_allocated=0 # reserve the space for the snapshot (of either type)... -read -r name crypt min max ignore <<< "${snapshot:-${thin_snapshot}}" +read -r name crypt min max ignore <<< "${thin_snapshot:-${snapshot}}" declare -g scratch_device_size=0 if (( $min <= $writable_device_size )); then -- cgit v1.2.3-55-g7522