Jonas Meurer wrote:
> Thanks for your great debugging work, Christian. I wouldn't have been
> able to track down this bug that soon without your invaluable help.
> Same goes to Ben Hutchings and Yves-Alexis Perez. You rock!
>   

Thanks for the credit.

> I've just prepared cryptsetup 1.0.6-7 with this bug and several others
> fixed. Would you mind testing the packages before I actually upload them
> to unstable and ask for inclusion in lenny? Many changes since 1.0.6-6
> are documentation improvements, but there are also some code fixes in
> initscripts, initramfs scripts and keyscripts.
>
> you can find the packages at http://people.debian.org/~mejo/cryptsetup/
>   

I've tested with my now usual "cheap" approach, i.e. checking the
contents of the generated initrd (I can't boot right now because of some
other ongoing work). Your version didn't work according to this testing,
as can be seen from the attached observation log. I've then done one
change, namely remove the double quotes from $depnode

http://christianjaeger.ch/dyn/pubgit/gitweb?p=cryptroot-debugging.git;a=commitdiff;h=ac6be141ffbb8bf05d6f6a3f57bf67c4fb2a8dbf

and with this it now works. When I made my comment about not using
double quotes there I really meant it, I saw from the debugging session
that $depnode has like 5-10 spaces and/or tabs appended.

(I'm somewhat surprised that it doesn't seem to need my find hacks
anymore, don't know what's going on there, either it was because I only
tested as standalone script during debugging, or you did maybe change
something else.)

Christian.

ch...@novo:/SRCREBUILD$ wget 
http://people.debian.org/~mejo/cryptsetup/cryptsetup_1.0.6-7.diff.gz 
http://people.debian.org/~mejo/cryptsetup/cryptsetup_1.0.6-7.dsc

(unpack, commit as new import to my Git repo, as branch "mejo", build)

with
  --- Logical volume ---
  LV Name                /dev/main/snap_test
  VG Name                main
  LV UUID                IAHJXv-8owg-qZLK-fGEy-51hV-fWcD-RCO9j0
  LV Write Access        read/write
  LV snapshot status     active destination for /dev/main/root


(verify with my old version:

novo:/usr/src/linux# linux-initrd-createinstall 2.6.27.9
update-initramfs: Generating /boot/initrd.img-2.6.27.9
cryptsetup: WARNING: found more than one resume device candidate:
                     /dev/mapper/main-swap
                     /dev/mapper/plain-plainswap
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.

novo:/tmp/root/t2# rm -rf *; gunzip < /boot/initrd.img-2.6.27.9|cpio --extract 
&& find |sort > ../i
35897 blocks
novo:/tmp/root# diff -u a i
novo:/tmp/root# 

also, to see other changes:

novo:/tmp/root# diff -ruN t t2
novo:/tmp/root#

)

(verify with downgraded version:

novo:/usr/src/linux# aptinstall cryptsetup=2:1.0.6-6
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be DOWNGRADED:
  cryptsetup
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 156 not upgraded.
Need to get 0B/308kB of archives.
After this operation, 135kB of additional disk space will be used.
Do you want to continue [Y/n]? 
dpkg - warning: downgrading cryptsetup from 2:1.0.6-6.cj to 2:1.0.6-6.
(Reading database ... 235730 files and directories currently installed.)
Preparing to replace cryptsetup 2:1.0.6-6.cj (using 
.../cryptsetup_2%3a1.0.6-6_amd64.deb) ...
Unpacking replacement cryptsetup ...
Processing triggers for man-db ...
Setting up cryptsetup (2:1.0.6-6) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-2.6.27.9
cryptsetup: WARNING: found more than one resume device candidate:
                     /dev/mapper/main-swap
                     /dev/mapper/plain-plainswap
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.

novo:/tmp/root# diff -ruN t t2
diff -ruN t/conf/conf.d/cryptroot t2/conf/conf.d/cryptroot
--- t/conf/conf.d/cryptroot     2008-12-16 03:19:16.958349654 +0100
+++ t2/conf/conf.d/cryptroot    1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-target=sda8_crypt,source=/dev/sda8,key=none,lvm=main-root
Binary files t/sbin/cryptsetup and t2/sbin/cryptsetup differ

as expected / previously seen, the cryptroot file is missing; the cryptsetup 
did change, which is not surprising.

)


Now verify the new version:

novo:/SRCREBUILD/mejo# dpkg -i cryptsetup_1.0.6-7_amd64.deb
(Reading database ... 235730 files and directories currently installed.)
Preparing to replace cryptsetup 2:1.0.6-6 (using cryptsetup_1.0.6-7_amd64.deb) 
...
Unpacking replacement cryptsetup ...
Setting up cryptsetup (2:1.0.6-7) ...
Installing new version of config file /etc/default/cryptdisks ...
Installing new version of config file /etc/init.d/cryptdisks ...
Installing new version of config file /etc/init.d/cryptdisks-early ...
Installing new version of config file /etc/bash_completion.d/cryptsetup ...
update-initramfs: deferring update (trigger activated)
Processing triggers for man-db ...
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-2.6.27.9
cryptsetup: WARNING: found more than one resume device candidate:
                     /dev/mapper/main-swap
                     /dev/mapper/plain-plainswap
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.

novo:/tmp/root/t2# rm -rf *; gunzip < /boot/initrd.img-2.6.27.9|cpio --extract 
&& find |sort > ../k
35897 blocks

novo:/tmp/root# diff -ruN t t2
diff -ruN t/conf/conf.d/cryptroot t2/conf/conf.d/cryptroot
--- t/conf/conf.d/cryptroot     2008-12-16 03:19:16.958349654 +0100
+++ t2/conf/conf.d/cryptroot    1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-target=sda8_crypt,source=/dev/sda8,key=none,lvm=main-root
Binary files t/sbin/cryptsetup and t2/sbin/cryptsetup differ
diff -ruN t/scripts/local-top/cryptroot t2/scripts/local-top/cryptroot
--- t/scripts/local-top/cryptroot       2008-12-16 03:19:16.730368930 +0100
+++ t2/scripts/local-top/cryptroot      2008-12-16 19:35:53.719564802 +0100
@@ -124,7 +124,7 @@
        vg="${1#/dev/mapper/}"
 
        # Sanity checks
-       if [ ! -x /sbin/vgchange ] || [ "$vg" = "$1" ]; then
+       if [ ! -x /sbin/lvm ] || [ "$vg" = "$1" ]; then
                return 1
        fi
 
@@ -139,7 +139,7 @@
        # Reduce padded --'s to -'s
        vg=$(echo ${vg} | sed -e 's#--#-#g')
 
-       vgchange -ay ${vg}
+       lvm vgchange -ay ${vg}
        return $?
 }
 


hm not good, cryptroot is missing.

novo:/tmp/root# diff -u a k
--- a   2008-12-16 03:05:35.100636522 +0100
+++ k   2008-12-16 19:35:54.011556701 +0100
@@ -39,7 +39,6 @@
 ./conf
 ./conf/arch.conf
 ./conf/conf.d
-./conf/conf.d/cryptroot
 ./conf/conf.d/md
 ./conf/conf.d/resume
 ./conf/conf.d/uswsusp

that won't work.



Checking the diff with Git:
master is my branch, mejo is the import of cryptsetup_1.0.6-7

ch...@novo:/SRCREBUILD/mejo/cryptsetup-1.0.6$ g-diff master..mejo 
debian/initramfs/cryptroot-hook
diff --git a/debian/initramfs/cryptroot-hook b/debian/initramfs/cryptroot-hook
index 263edf4..b6d3c2b 100644
--- a/debian/initramfs/cryptroot-hook
+++ b/debian/initramfs/cryptroot-hook
@@ -142,7 +142,7 @@ get_lvm_deps() {
                        continue
                fi
                if [ "$(dmsetup table $depnode 2> /dev/null | cut -d' ' -f3)" 
!= "crypt" ]; then
-                       get_lvm_deps $depnode  # no quoting here as above there 
isn't either, and it contains appended whitespace
+                       get_lvm_deps "$depnode"
                        continue
                fi
                echo "$depnode"
@@ -200,8 +200,8 @@ get_device_opts() {
        # We have all the basic options, let's go trough them
        OPTIONS="target=$target,source=$source,key=$key"
        local IFS=", "
-       HASH_FOUND=""
-       LUKS_FOUND=""
+       unset HASH_FOUND
+       unset LUKS_FOUND
        for opt in $rootopts; do
                case $opt in
                        cipher=*)
@@ -351,7 +351,6 @@ add_device() {
                if ! get_device_opts "$node" "$opts"; then
                        continue
                fi
-               mkdir -p "$DESTDIR/conf/conf.d"
                echo "$OPTIONS" >> "$DESTDIR/conf/conf.d/cryptroot"
 
                # If we have a keyscript, make sure it is included
@@ -413,15 +412,6 @@ add_crypto_modules() {
                found="yes"
        done
 
-       if [ -z "$found" ]; then
-               for file in $(find "$MODULESDIR/kernel/drivers/" -name 
"${mod}.ko"); do
-                       altmod="${file##*/}"
-                       altmod="${altmod%.ko}"
-                       manual_add_modules "$altmod"
-                       found="yes"
-               done
-       fi
-
        for file in $(find "$MODULESDIR/kernel/crypto/" -name 
"${mod}_generic.ko"); do
                altmod="${file##*/}"
                altmod="${altmod%.ko}"
@@ -440,12 +430,7 @@ add_crypto_modules() {
        fi
 
        if [ -z "$found" ]; then
-               if echo "$mod"|grep -q _; then
-                       add_crypto_modules "$(echo "$mod"|tr _ -)"
-                       return $?
-               else
-                       return 1
-               fi
+               return 1
        fi
 
        return 0



Ok, so the first change I'm trying is to remove the quotes:
--- a/debian/initramfs/cryptroot-hook
+++ b/debian/initramfs/cryptroot-hook
@@ -142,7 +142,7 @@ get_lvm_deps() {
                        continue
                fi
                if [ "$(dmsetup table $depnode 2> /dev/null | cut -d' ' -f3)" 
!= "crypt" ]; then
-                       get_lvm_deps "$depnode"
+                       get_lvm_deps $depnode
                        continue
                fi
                echo "$depnode"



rebuild as 1.0.6-7.cj

novo:/SRCREBUILD/mejo# dpkg -i cryptsetup_1.0.6-7.cj_amd64.deb

novo:/tmp/root/t2# rm -rf *; gunzip < /boot/initrd.img-2.6.27.9|cpio --extract 
&& find |sort > ../l
35897 blocks

novo:/tmp/root# diff -u a l
novo:/tmp/root# 

novo:/tmp/root# diff -ruN t t2
Binary files t/sbin/cryptsetup and t2/sbin/cryptsetup differ
diff -ruN t/scripts/local-top/cryptroot t2/scripts/local-top/cryptroot
--- t/scripts/local-top/cryptroot       2008-12-16 03:19:16.730368930 +0100
+++ t2/scripts/local-top/cryptroot      2008-12-16 19:46:00.505297120 +0100
@@ -124,7 +124,7 @@
        vg="${1#/dev/mapper/}"
 
        # Sanity checks
-       if [ ! -x /sbin/vgchange ] || [ "$vg" = "$1" ]; then
+       if [ ! -x /sbin/lvm ] || [ "$vg" = "$1" ]; then
                return 1
        fi
 
@@ -139,7 +139,7 @@
        # Reduce padded --'s to -'s
        vg=$(echo ${vg} | sed -e 's#--#-#g')
 
-       vgchange -ay ${vg}
+       lvm vgchange -ay ${vg}
        return $?
 }
 


Now it seems good.

(Surprise, why did you not need these find changes? Ok, I didn't test while in 
the complete package, only ran the debian/initramfs/cryptroot-hook script 
standalone, maybe it was because of that.)

(As confirmation:

novo:/usr/src/linux# linux-initrd-createinstall 2.6.27.9
update-initramfs: Generating /boot/initrd.img-2.6.27.9
cryptsetup: WARNING: found more than one resume device candidate:
                     /dev/mapper/main-swap
                     /dev/mapper/plain-plainswap
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.

novo:/tmp/root/t2# rm -rf *; gunzip < /boot/initrd.img-2.6.27.9|cpio --extract 
&& find |sort > ../m
35897 blocks

novo:/tmp/root# diff -u a m
novo:/tmp/root# 

good
)

(And also as confirmation, remove the snapshot and try again:

novo:/tmp/root/t2# lvremove /dev/main/snap_test 
  /dev/md1: read failed after 0 of 4096 at 0: Input/output error
Do you really want to remove active logical volume "snap_test"? [y/n]: y
  Logical volume "snap_test" successfully removed

novo:/usr/src/linux# linux-initrd-createinstall 2.6.27.9
update-initramfs: Generating /boot/initrd.img-2.6.27.9
cryptsetup: WARNING: found more than one resume device candidate:
                     /dev/mapper/main-swap
                     /dev/mapper/plain-plainswap
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.

novo:/tmp/root/t2# rm -rf *; gunzip < /boot/initrd.img-2.6.27.9|cpio --extract 
&& find |sort > ../n
35897 blocks

novo:/tmp/root# diff -u a n
novo:/tmp/root# 

ok.
)

Reply via email to