[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#916696: initramfs-tools: search for nonexistent resume device



On Wed, 06 Feb 2019 21:21:57 +0000
Ben Hutchings <ben@decadent.org.uk> wrote:

> The RESUME variable doesn't have to be set in any particular file.
> Please check with:
> 
>     grep -rw RESUME /etc/initramfs-tools/initramfs.conf \
>         /etc/initramfs-tools/conf.d \
>         /usr/share/initramfs-tools/conf.d/

it's empty


> If it's definitely not set, then please:
> 
> 1. Upgrade to initramfs-tools version 0.133 (I just uploaded this so
>    you will have to wait a few hours for it to be available)
> 2. Run "update-initramfs -u -v >initramfs.log 2>&1"
> 3. Look in initramfs.log for "Calling hook resume" and send the
>    messages after that

thanks for your help, now I've managed to debug and fix the resume hook:
when all the swaps are ephemeral, it finishes the for-loop, but the
last if-construct doesn't check the ephemeral variable

I include a patch, tested with and without an ephemeral swap:
- the second block (-79,9 +83,10) is the actual fix
- the first one (-63,9 +63,13) is only to be safer, as it
  checks /dev/random too and it stops searching /etc/crypttab when the
  device is found

ciao!
--- a/usr/share/initramfs-tools/hooks/resume	2019-02-06 05:40:30.000000000 +0100
+++ b/usr/share/initramfs-tools/hooks/resume	2019-02-10 05:50:51.270496152 +0100
@@ -63,9 +63,13 @@
 			# shellcheck disable=SC2034
 			while read -r cryptdev srcdev keyfile junk; do
 				report_verbose "Found cryptdev=$cryptdev keyfile=$keyfile"
-				if [ "$cryptdev" = "$dm_name" ] && [ "$keyfile" = /dev/urandom ]; then
-					report_verbose "Rejecting $resume_auto since it has no permanent key"
-					ephemeral=true
+				if [ "$cryptdev" = "$dm_name" ]; then
+					if [ "$keyfile" = /dev/urandom ] || [ "$keyfile" = /dev/random ]; then
+						report_verbose "Rejecting $resume_auto since it has no permanent key"
+						ephemeral=true
+					fi
+
+					break
 				fi
 			done < /etc/crypttab
 		fi
@@ -79,9 +83,10 @@
 		esac
 
 		$ephemeral || break
+		resume_auto=
 	done
 
-	if [ -n "$resume_auto" ] && ! $ephemeral; then
+	if [ -n "$resume_auto" ]; then
 		if [ -n "$dm_name" ]; then
 			resume_auto_canon="/dev/mapper/$dm_name"
 		elif UUID=$(blkid -s UUID -o value "$resume_auto"); then

Reply to: