Debian Lenny: pam_mount, files and loop devices

When I was trying to automatically mount an encrypted image at login using pam_mount, I encountered a strange problem:
I wasn’t able to find any errors in my configuration (at least none connected to this behaviour), but mount.crypt was unable to mount the image.

Enabling debugging in pam_mount.conf.xml (<debug enable="1" />) revealed the command used for mounting:

pam_mount(misc.c:272) command: mount.crypt [-o loop] [/home/foobar/container] [/home/foobar/crypto]

In Debians libpam-mount 0.44-1+lenny3, /sbin/mount.crypt is a bash script that calls cryptsetup with parameters generated during its runtime.
Debugging it (set -x), I stumpled upon the following command:

cryptsetup -c aes -h ripemd160 -s 256 create _home_foobar_container /home/foobar/container

…which returned the following error message:

Command failed: BLKROGET failed on device: Inappropriate ioctl for device

So mount.crypt has been passed the loop option but cryptsetup was told to mount the encrypted image instead of the associated loopback device (normally mount.crypt executes losetup to create this association in its function _losetup, but this apparently has never been called).

Long story short:
There seems to be a bug in Debians libpam-mount 0.44-1+lenny3.
The case statement at line 110 in /sbin/mount.crypt doesn’t work as expected because the variable $KEY used for option comparison has an ordinary space at its values beginning.
To fix this, you can either change the way how passed options are saved in the OPTION variable (starting at line 60) or change line 110 to the following:

case ${KEY/ /} in

This will remove all spaces.