From 0df3c9939da0132f82af2ba806d070c37b7bfe8c Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Fri, 20 Sep 2013 13:44:11 -0400 Subject: fix luks header backup to properly detect partitions previously the code was modeled off of the partition backup methodology, this resulted in the code only attempting to detect luks on actual devices, and not on partitions. The code would step through every disk on the system (sda, sdb, etc.) and do a 'cryptsetup isLuks' on that device, and then based on that output save the luks header for any device that had one. Unfortunately, in many cases, luks headers are found on the partitions of those disks. So we were failing to detect any luks partitions and thus failing to backup their luks headers. this commit changes that, it now will look for luks headers on the devices themselves (for cases where a full disk is used without partitions), and on any partitions that are detected --- handlers/sys.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/handlers/sys.in b/handlers/sys.in index 92998cc..4210873 100644 --- a/handlers/sys.in +++ b/handlers/sys.in @@ -595,8 +595,10 @@ fi if [ "$luksheaders" == "yes" ]; then devices=`LC_ALL=C $SFDISK -l 2>/dev/null | grep "^Disk /dev" | @AWK@ '{print $2}' | cut -d: -f1` [ -n "$devices" ] || warning "No block device found" + partitions=`LC_ALL=C $SFDISK -l 2>/dev/null |grep "^/dev" | @AWK@ '{print $1}'` + [ -n "$partitions" ] || warning "No partitions found" targetdevices="" - for dev in $devices; do + for dev in $devices $partitions; do [ -b $dev ] || continue debug "$CRYPTSETUP isLuks $dev" $CRYPTSETUP isLuks $dev @@ -611,13 +613,13 @@ if [ "$luksheaders" == "yes" ]; then debug "$CRYPTSETUP luksDump \"$dev\" | grep '^Payload offset:' | @AWK@ '{print $3}'" headersize=`$CRYPTSETUP luksDump "$dev" | grep '^Payload offset:' | @AWK@ '{print $3}'` if [ $? -ne 0 ]; then - warning "Could not compute the size of Luks header, skipping device $dev" + warning "Could not compute the size of Luks header, skipping $dev" continue elif [ -z "$headersize" -o -n "`echo \"$headersize\" | sed 's/[0-9]*//g'`" ]; then - warning "The computed size of Luks header is not an integer, skipping device $dev" + warning "The computed size of Luks header is not an integer, skipping $dev" continue fi - debug "Let us backup the Luks header of device $dev" + debug "Let us backup the Luks header of $dev" debug "$DD if=\"${dev}\" of=\"${outputfile}\" bs=512 count=\"${headersize}\"" output=`$DD if="${dev}" of="${outputfile}" bs=512 count="${headersize}" 2>&1` exit_code=$? -- cgit v1.2.3