mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-20 21:43:11 +00:00
7baeebe9bf
Update_checksum was already changing files in /boot, befor checking for gpg card. If no card is present, the user will end up in the recovery next time instead of getting the same dialog again. Therefore, the confirm_gpg_card should be checked before altering files. The dead -u flag/$update_counter is used to mark the necessisty to update the hash files now.
71 lines
1.6 KiB
Bash
Executable File
71 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Generate a TPM key used to unlock LUKS disks
|
|
set -e -o pipefail
|
|
. /etc/functions
|
|
|
|
lvm_volume_group=""
|
|
skip_sign="n"
|
|
while getopts "sp:d:l:" arg; do
|
|
case $arg in
|
|
s) skip_sign="y" ;;
|
|
p) paramsdir="$OPTARG" ;;
|
|
d) paramsdev="$OPTARG" ;;
|
|
l) lvm_volume_group="$OPTARG" ;;
|
|
esac
|
|
done
|
|
shift `expr $OPTIND - 1`
|
|
key_devices="$@"
|
|
|
|
if [ -z "$paramsdir" ]; then
|
|
die "Usage: $0 [-s] -p /boot [-l qubes_dom0] [/dev/sda2 /dev/sda5 ...] "
|
|
fi
|
|
|
|
if [ -z "$paramsdev" ]; then
|
|
paramsdev="$paramsdir"
|
|
fi
|
|
|
|
paramsdev="${paramsdev%%/}"
|
|
paramsdir="${paramsdir%%/}"
|
|
|
|
if [ -n "$lvm_volume_group" ]; then
|
|
lvm vgchange -a y $lvm_volume_group \
|
|
|| die "Failed to activate the LVM group"
|
|
|
|
for dev in /dev/$lvm_volume_group/*; do
|
|
key_devices="$key_devices $dev"
|
|
done
|
|
fi
|
|
|
|
if [ -z "$key_devices" ]; then
|
|
die "No devices specified for TPM key insertion"
|
|
fi
|
|
|
|
# try to switch to rw mode
|
|
mount -o rw,remount $paramsdev
|
|
|
|
rm -f $paramsdir/kexec_key_lvm.txt || true
|
|
if [ -n "$lvm_volume_group" ]; then
|
|
echo "$lvm_volume_group" > $paramsdir/kexec_key_lvm.txt \
|
|
|| die "Failed to write lvm group to key config "
|
|
fi
|
|
|
|
rm -f $paramsdir/kexec_key_devices.txt || true
|
|
for dev in $key_devices; do
|
|
uuid=`cryptsetup luksUUID "$dev" 2>/dev/null` \
|
|
|| die "Failed to get UUID for device $dev"
|
|
echo "$dev $uuid" >> $paramsdir/kexec_key_devices.txt \
|
|
|| die "Failed to add $dev:$uuid to key devices config"
|
|
done
|
|
|
|
kexec-seal-key $paramsdir \
|
|
|| die "Failed to save and generate key in TPM"
|
|
|
|
if [ "$skip_sign" != "y" ]; then
|
|
# sign and auto-roll config counter
|
|
kexec-sign-config -p $paramsdir -r \
|
|
|| die "Failed to sign updated config"
|
|
fi
|
|
|
|
# switch back to ro mode
|
|
mount -o ro,remount $paramsdev
|