]> gitweb.fluxo.info Git - backupninja.git/commitdiff
fix luks header backup to properly detect partitions
authorMicah Anderson <micah@riseup.net>
Fri, 20 Sep 2013 17:44:11 +0000 (13:44 -0400)
committerMicah Anderson <micah@riseup.net>
Fri, 20 Sep 2013 17:44:11 +0000 (13:44 -0400)
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

index 92998cc476b4610c1fb8daf656a1569bf2ec4fe9..42108735575285fb2912ef1285cec43a0ede14bb 100644 (file)
@@ -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=$?