Package: cryptsetup
Version: 20050111-3
Severity: normal

hi

I had mentioned this bug in bug 290626:
there is an error in the parsing of the options in crypttab:
 if an option does not have a value, the variable VALUE should be empty,
but it is not.

Since I want to be precise, I want to explain the problem here.

Here is how you can check the bug. Save the attachments in /tmp . Then 
$ cd /tmp
$ cp /etc/init.d/cryptdisks /tmp
$ patch < cryptdisks-test.diff
$ ./cryptdisks start
(it will run on crypttab-test ).

The output will be
vvvvvvvvvvvvvvvvv
/sbin/dmsetup mknodes
Starting crypto disks: A(starting)...
PARAM size VALUE 1
PARAM cipher VALUE blah
/sbin/cryptsetup -s 1 -c blah create A /dev/A
 B(starting)...
PARAM size VALUE size
PARAM cipher VALUE cipher
/sbin/cryptsetup -s size -c cipher create B /dev/B
.
^^^^^^^^^^^^^^^^^^^^^^^^^^^


As you see, the VALUE variable is not empty, even when an option is 
not provided. Moreover, when the option is not given, cryptdisks
should print  " - no value for size option, skipping" , and it does not.

I provide the specific patch for this problem. With this patch,
the output is
vvvvvvvvvvvvvvvvvvvvvvvvvv
$ ./cryptdisks start
/sbin/dmsetup mknodes
Starting crypto disks: A(starting)...
PARAM size VALUE 1
PARAM cipher VALUE blah
/sbin/cryptsetup -s 1 -c blah create A /dev/A
 B(starting)...
PARAM size VALUE
 - no value for size option, skipping
PARAM cipher VALUE
 - no value for cipher option, skipping
.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

(The patch for 290626 will include this one - it would not work
without)

a.

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (650, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.8-2-k7
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages cryptsetup depends on:
ii  dmsetup                     2:1.01.00-4  The Linux Kernel Device Mapper use
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an
ii  libdevmapper1.01            2:1.01.00-4  The Linux Kernel Device Mapper use
ii  libgcrypt11                 1.2.0-4      LGPL Crypto library - runtime libr
ii  libgpg-error0               1.0-1        library for common error values an
ii  libpopt0                    1.7-5        lib for parsing cmdline parameters

-- no debconf information

-- 
Andrea Mennucc
 "E' un mondo difficile. Che vita intensa!" (Tonino Carotone)
--- /etc/init.d/cryptdisks      2005-03-08 17:50:44.000000000 +0100
+++ cryptdisks-test     2005-04-12 20:30:08.437383408 +0200
@@ -3,14 +3,14 @@
 # cryptodisks  Now that all block devices should be available, setup
 #              encrypted block devices
 
-CRYPTCMD=/sbin/cryptsetup
-DEVMAPCMD=/sbin/dmsetup
-TABFILE=/etc/crypttab
+CRYPTCMD="echo /sbin/cryptsetup"
+DEVMAPCMD="echo /sbin/dmsetup"
+TABFILE=crypttab.test
 MAPPER=/dev/mapper
 
-test -x $CRYPTCMD  || exit 0
-test -x $DEVMAPCMD || exit 0
-test -f $TABFILE   || exit 0             
+#test -x $CRYPTCMD  || exit 0
+#test -x $DEVMAPCMD || exit 0
+#test -f $TABFILE   || exit 0             
 
 [ -r /etc/default/cryptdisks ] && . /etc/default/cryptdisks
 
@@ -67,7 +67,7 @@
                                opt=${opt##,}
                                PARAM=`echo $ARG | sed "s/=.*//"`
                                VALUE=${ARG##$PARAM=}
-                               
+                               echo PARAM $PARAM VALUE $VALUE
                                case "$PARAM" in 
                                        readonly)
                                                PARAM=-r
# <target device> <source device> <key file> <options>
A /dev/A  none size=1,cipher=blah
B /dev/B  none size,cipher


--- /etc/init.d/cryptdisks      2005-03-08 17:50:44.000000000 +0100
+++ cryptdisks-value-ok 2005-04-12 21:43:19.741803664 +0200
@@ -62,12 +62,19 @@
                        # Parse the options field, convert to cryptsetup 
parameters
                         # and contruct the command line
                        while test "x$opt" != "x" ; do
-                               ARG=`echo $opt | sed "s/,.*//"`
+                               ARG=${opt/,*}
                                opt=${opt##$ARG}
                                opt=${opt##,}
-                               PARAM=`echo $ARG | sed "s/=.*//"`
-                               VALUE=${ARG##$PARAM=}
-                               
+                                case $ARG in
+                                   *=*)
+                                       PARAM=${ARG/=*}
+                                       VALUE=${ARG##$PARAM=}
+                                       ;;
+                                   *)
+                                       PARAM=$ARG
+                                       VALUE=""
+                                      ;;
+                                esac
                                case "$PARAM" in 
                                        readonly)
                                                PARAM=-r

Attachment: signature.asc
Description: Digital signature

Reply via email to