Bug#290708: initrd-tools: dm-crypt devices initialized with wrong arguments for cryptsetup
hello tino,
thanks for your patch,
i had a look at it, but got mad with all the
"x$foo" = "xtrue" and reworked it a bit.
> On Sat, Apr 23, 2005 at 22:32:24 +0200, Tino Keitel wrote:
> > here is a patch for mkinitrd to parse the cryptsetup options from
> > /etc/cryptdisks, as it is already done by the initscript from the
> > cryptsetup package.
> >
> > Regards,
> > Tino
could you please give it some more testing.
in the cleanup version i might push into the initrd-tools.
if i get postive feedback.
i guess that the patch is somehow related to #303403,
as i don't use cryptsetup atm it would be cool if some
of you guys could followup also on this one.
#296464 seems a candidate for reassignement to cryptsetup,
unless i'm misguided?
--
maks
diff -ur initrd-tools-0.1.78.orig/mkinitrd initrd-tools-0.1.78/mkinitrd
--- initrd-tools-0.1.78.orig/mkinitrd 2005-04-10 16:06:44.000000000 +0200
+++ initrd-tools-0.1.78/mkinitrd 2005-04-23 22:30:03.000000000 +0200
@@ -322,6 +322,66 @@
fi
}
+dmcrypt_parse_crypttab() {
+ TABFILE=/etc/crypttab
+
+ egrep "^$dmname" $TABFILE | while read dst src key opt ; do
+ if [ -n $key ] && [ "$key" != "none" ]; then
+ INTERACTIVE="no"
+ else
+ INTERACTIVE="yes"
+ fi
+
+ PARAMS=""
+
+ # Parse the options field, convert to cryptsetup parameters
+ # and contruct the command line
+ while [ -n $opt ] ; do
+ ARG=`echo $opt | sed "s/,.*//"`
+ opt=${opt##$ARG}
+ opt=${opt##,}
+ PARAM=`echo $ARG | sed "s/=.*//"`
+ VALUE=${ARG##$PARAM=}
+
+ case "$PARAM" in
+ cipher)
+ PARAM=-c
+ if [ ! -n $VALUE ] ; then
+ echo "No value for cipher option." >&2
+ exit 1
+ fi
+ ;;
+ size)
+ PARAM=-s
+ if [ ! -n $VALUE ] ; then
+ echo "No value for size option." >&2
+ exit 1
+ fi
+ ;;
+ hash)
+ PARAM=-h
+ if [ ! -n $VALUE ] ; then
+ echo "No value for hash option." >&2
+ exit 1
+ fi
+ ;;
+ verify)
+ PARAM=-y
+ VALUE=""
+ ;;
+ esac
+
+ PARAMS="$PARAMS $PARAM $VALUE"
+ done
+
+ if [ "$INTERACTIVE" = "yes" ] ; then
+ echo "$PARAMS"
+ else
+ echo "$PARAMS -d $key"
+ fi
+ done
+}
+
dmcrypt() {
local cipher_mode devname submajor subminor
@@ -340,6 +400,8 @@
exit 1
fi
+ export dmname
+ cryptcmd=`dmcrypt_parse_crypttab`
eval "$(stat -c 'submajor=$((0x%t)); subminor=$((0x%T))' $(readlink -f "$devname"))"
if [ $submajor != $(dmsetup deps $dmname | sed 's/^.*(\([0-9]*\), \([0-9]*\))$/\1/') \
@@ -349,7 +411,6 @@
fi
getroot $devname
-
cat <<EOF >&5
mount_tmpfs dev2
@@ -364,6 +425,7 @@
export device
export dmname="$dmname"
export cipher_mode="$cipher_mode"
+export cryptcmd="$cryptcmd"
for i in /keyscripts/*; do
[ -f "\$i" ] || continue
case "\$i" in
@@ -376,7 +438,7 @@
esac
done
[ -b /dev/mapper/\$dmname ] || \\
- /sbin/cryptsetup -c \$cipher_mode create \$dmname \$device
+ /sbin/cryptsetup \$cryptcmd create \$dmname \$device
umount -n dev2
EOF
Only in initrd-tools-0.1.78: mkinitrd~
Reply to: