2020-11-23 21:35:42 +00:00
|
|
|
--- /usr/share/initramfs-tools/scripts/local-top/cryptroot 2020-09-16 22:40:05.000000000 +0200
|
|
|
|
+++ cryptroot 2020-11-23 22:31:48.797985438 +0100
|
|
|
|
@@ -162,8 +162,46 @@
|
2020-05-02 23:50:28 +00:00
|
|
|
# unlock via keyfile
|
|
|
|
unlock_mapping "$CRYPTTAB_KEY"
|
|
|
|
else
|
|
|
|
- # unlock interactively or via keyscript
|
|
|
|
- run_keyscript "$CRYPTTAB_KEY" "$count" | unlock_mapping
|
2020-11-23 21:35:42 +00:00
|
|
|
+ if [ -z "${CRYPTTAB_OPTION_keyscript+x}" ]; then
|
|
|
|
+ # Wait for USB to settle
|
|
|
|
+ /bin/sleep 3
|
|
|
|
+
|
|
|
|
+ # Test all devices
|
|
|
|
+ mkdir /mnt
|
|
|
|
+ echo -n "Searching for cryptkey.txt on available disks... "
|
|
|
|
+ local partition
|
|
|
|
+ for partition in `cat /proc/partitions |awk '{print $4}'|tail -n +3`; do
|
|
|
|
+ if mount /dev/$partition /mnt 2>/dev/null; then
|
|
|
|
+ cat /mnt/cryptkey.txt >> /tmp/cryptkeys.txt 2>/dev/null
|
|
|
|
+ umount /dev/$partition
|
|
|
|
+ fi
|
|
|
|
+ done
|
|
|
|
+ echo "done."
|
|
|
|
+ fi
|
|
|
|
+
|
2020-05-02 23:50:28 +00:00
|
|
|
+ if [ -s /tmp/cryptkeys.txt ]; then
|
|
|
|
+ local keyfound
|
|
|
|
+ keyfound=0
|
|
|
|
+ echo Trying keys from cryptkey.txt
|
|
|
|
+ for key in `cat /tmp/cryptkeys.txt`; do
|
|
|
|
+ if echo -n "$key" | unlock_mapping; then
|
|
|
|
+ # Found the key
|
|
|
|
+ echo Key found in cryptkey.txt
|
|
|
|
+ keyfound=1
|
|
|
|
+ key=""
|
|
|
|
+ fi
|
|
|
|
+ done
|
|
|
|
+ # Remove traces of the key
|
|
|
|
+ rm /tmp/cryptkeys.txt
|
|
|
|
+ unset key
|
|
|
|
+ if [ "$keyfound" = "0" ]; then
|
|
|
|
+ # Fall back to manual entry
|
|
|
|
+ run_keyscript "$CRYPTTAB_KEY" "$count" | unlock_mapping
|
|
|
|
+ fi
|
|
|
|
+ else
|
|
|
|
+ # unlock interactively or via keyscript
|
|
|
|
+ run_keyscript "$CRYPTTAB_KEY" "$count" | unlock_mapping
|
|
|
|
+ fi
|
|
|
|
fi
|
|
|
|
rv=$?
|
|
|
|
count=$(( $count + 1 ))
|