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

2019-02-10 Thread Ben Hutchings
Control: tag -1 - moreinfo
Control: tag -1 patch

On Sun, 2019-02-10 at 23:35 +0100, Trek wrote:
[...]
> my fix is to reset the resume_auto variable if the device is ephemeral,
> thus removing the need to check the ephemeral variable in the two
> if-construct after the for-loop
> 
>   $ephemeral || break # exit the for-loop if ephemeral=true
>   resume_auto=# otherwise empty resume_auto
> 
> 
> that's it :)
> thanks again for your time
> ciao!

OK, I understand now, thanks.

Ben.

-- 
Ben Hutchings
The world is coming to an end.  Please log off.




signature.asc
Description: This is a digitally signed message part


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

2019-02-10 Thread Trek
On Sun, 10 Feb 2019 17:32:08 +
Ben Hutchings  wrote:

> > I include a patch, tested with and without an ephemeral swap:
> > - the second block (-79,9 +83,10) is the actual fix
> If you would actually send me the log messages I might understand this
> fix, but as it is I don't.  I do need to understand it before I will
> apply it.

yes, sorry, you're right

here the log:

Calling hook resume
I: Configuration sets RESUME=
I: Checking swap device /dev/dm-1
I: /dev/dm-1 has device-mapper name sdb5_crypt; checking crypttab
I: Found cryptdev=sda5_crypt keyfile=/dev/urandom
I: Found cryptdev=sdb5_crypt keyfile=/dev/urandom
I: Rejecting /dev/dm-1 since it has no permanent key
I: Checking swap device /dev/dm-0
I: /dev/dm-0 has device-mapper name sda5_crypt; checking crypttab
I: Found cryptdev=sda5_crypt keyfile=/dev/urandom
I: Rejecting /dev/dm-0 since it has no permanent key
I: Found cryptdev=sdb5_crypt keyfile=/dev/urandom
Calling hook thermal


it ends up with the initrd file /main/conf/conf.d/zz-resume-auto
containing:

RESUME=/dev/dm-0


running resume with set -x explain what's going on:

+ report_verbose Rejecting /dev/dm-0 since it has no permanent key
+ test y != y
+ echo I: Rejecting /dev/dm-0 since it has no permanent key
I: Rejecting /dev/dm-0 since it has no permanent key
+ ephemeral=true
+ read -r cryptdev srcdev keyfile junk
+ report_verbose Found cryptdev=sdb5_crypt keyfile=/dev/urandom
+ test y != y
+ echo I: Found cryptdev=sdb5_crypt keyfile=/dev/urandom
I: Found cryptdev=sdb5_crypt keyfile=/dev/urandom
+ [ sdb5_crypt = sda5_crypt ]
+ read -r cryptdev srcdev keyfile junk
+ true
+ [ -n /dev/dm-0 ]
+ true
+ [  = auto ]
+ [ -n /dev/dm-0 ]
+ [ -z /dev/dm-0 ]
+ echo RESUME=/dev/dm-0


basically, it finishes the while-loop
  while read -r cryptdev srcdev keyfile junk; do
  + read -r cryptdev srcdev keyfile junk
then it checks the ephemeral variable inside the for-loop
  $ephemeral || break
  + true
now the for-loop is finished and it evaluates the first if-construct
  if [ -n "$resume_auto" ] && ! $ephemeral; then
  + [ -n /dev/dm-0 ]
  + true
it evaluates the second if-construct (the bug is here, as it doesn't
account for ephemeral)
  if [ "$RESUME" = auto ] || [ -n "$resume_auto" ]; then
  + [  = auto ]
  + [ -n /dev/dm-0 ]
then the inner if-construct 
  if [ -z "$resume_auto" ]; then
  + [ -z /dev/dm-0 ]
and finally it writes the resume file
  echo "RESUME=${resume_auto}" > "${DESTDIR}/conf/conf.d/zz-resume-auto"
  + echo RESUME=/dev/dm-0


my fix is to reset the resume_auto variable if the device is ephemeral,
thus removing the need to check the ephemeral variable in the two
if-construct after the for-loop

  $ephemeral || break   # exit the for-loop if ephemeral=true
  resume_auto=  # otherwise empty resume_auto


that's it :)
thanks again for your time
ciao!



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

2019-02-10 Thread Ben Hutchings
On Sun, 2019-02-10 at 06:31 +0100, Trek wrote:
> On Wed, 06 Feb 2019 21:21:57 +
> Ben Hutchings  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

If you would actually send me the log messages I might understand this
fix, but as it is I don't.  I do need to understand it before I will apply it.

Ben.

> - 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!
-- 
Ben Hutchings
The world is coming to an end.  Please log off.




signature.asc
Description: This is a digitally signed message part


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

2019-02-09 Thread Trek
On Wed, 06 Feb 2019 21:21:57 +
Ben Hutchings  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.0 +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


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

2019-02-06 Thread Ben Hutchings
Control: tag -1 moreinfo

On Mon, 17 Dec 2018 15:48:12 +0100 Trek  wrote:
> Package: initramfs-tools
> Version: 0.132
> 
> at boot, initramfs blocks searching for a resume device
> 
> Begin: Waiting for suspend/resume device ...
> Begin: Running /scripts/local-block ... done.
> 
> 
> I'm using sysvinit and two encrypted swap partitions
> 
> the file /etc/initramfs-tools/conf.d/resume does not exist
> 
> the contents of /etc/crypttab are:
> 
> sda5_crypt /dev/disk/by-id/ata-XX-XX_-part5 /dev/urandom
> cipher=aes-xts-plain64,size=256,swap
> sdb5_crypt /dev/disk/by-id/ata-XX-XX_-part5 /dev/urandom
> cipher=aes-xts-plain64,size=256,swap
> 
> 
> if I disable swap (swapoff -a) and rebuild the initrd, the problem
> disappears
> 
> 
> can I do something to further investigate the issue?

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/

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

Ben.

-- 
Ben Hutchings
Man invented language to satisfy his deep need to complain.
  - Lily Tomlin



signature.asc
Description: This is a digitally signed message part


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

2018-12-17 Thread Trek
Package: initramfs-tools
Version: 0.132

at boot, initramfs blocks searching for a resume device

Begin: Waiting for suspend/resume device ...
Begin: Running /scripts/local-block ... done.


I'm using sysvinit and two encrypted swap partitions

the file /etc/initramfs-tools/conf.d/resume does not exist

the contents of /etc/crypttab are:

sda5_crypt /dev/disk/by-id/ata-XX-XX_-part5 /dev/urandom
cipher=aes-xts-plain64,size=256,swap
sdb5_crypt /dev/disk/by-id/ata-XX-XX_-part5 /dev/urandom
cipher=aes-xts-plain64,size=256,swap


if I disable swap (swapoff -a) and rebuild the initrd, the problem
disappears


can I do something to further investigate the issue?

thank you!