[Pkg-cryptsetup-devel] Bug#451916: Bug#451916: cryptsetup: loopback device not detached after "/etc/init.d/cryptdisks stop"

Jonas Meurer jonas at freesources.org
Mon Dec 3 17:10:31 UTC 2007


On 20/11/2007 René Pavlík wrote:
> I mean the second case. I set up /etc/crypttab successfully to use a
> regular file for crypto-storage. Turning it on by hand works OK and
> even turning it on by "/etc/init.d/cryptdisks start" created the
> crypto device through a loopback correctly.
> The problem was when I made a little tunning change in the
> configuration and needed to re-create the device again. So I used
> "/etc/init.d/cryptdisks stop" to shut down crypto device. It correctly
> detach crypto device from the loopback but NOT detach the loopback
> from the regular file.
> So I think if the loopback device is allocated by this script it
> should be also freed by this script. There is a do_stop() func in the
> script (mean in the sourced library). This func tries to do detaching
> at the very end:
> 
>                 # Detach loopback device, if attached
>                 if [ -f "$src" ] && [ -n "$loopmajor" ] && [
> "$loopmajor" = "$major" ]; then
>                         losetup -d "/dev/loop$minor" > /dev/null 2>&1
> || true
>                 fi
> 
> but this doesn't work - because of the false condition, especially [
> "$loopmajor" = "$major" ].

You're correct, and i don't understand why this code has been
implemented in the first time. checking for matching $loopmajor and
$major doesn't work at all.

The question is rather how else we could verify that a loopback device
has been used and needs to be deleted at stop.

I cannot imagine any way to get the loopback device from the source file
except something like

	losetup -a | grep -m1 "($src)$" | sed -e 's/:.*//g'

which is a rather unclean solution. David, do you have any better
solution? i guess you do ;-)

greetings,
 jonas





More information about the Pkg-cryptsetup-devel mailing list