diff options
author | Jonathan Bauer | 2018-12-04 14:38:55 +0100 |
---|---|---|
committer | Jonathan Bauer | 2018-12-04 14:38:55 +0100 |
commit | a98a26129413ba796de32e03702e9d50b42048b4 (patch) | |
tree | f5750821ce1b4507467bfa283a154327d8fadfb4 | |
parent | [slx-part] fix swapped argument for fallback (diff) | |
download | systemd-init-a98a26129413ba796de32e03702e9d50b42048b4.tar.gz systemd-init-a98a26129413ba796de32e03702e9d50b42048b4.tar.xz systemd-init-a98a26129413ba796de32e03702e9d50b42048b4.zip |
[slx-part] sanitize crypt & fix snapshot fallback
-rwxr-xr-x | builder/modules.d/slx-partitioner/scripts/slx_partitioner | 11 |
1 files 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 |