From b35fd719c34cc996c960781b05eb02b57ba718e8 Mon Sep 17 00:00:00 2001 From: Robert Hallgren Date: Wed, 7 Sep 2016 15:35:00 +0200 Subject: [PATCH] Fixed 'Cannot remove device mapper handle ...' error message. In luks.c (row 223) the function isLuksMapperAvailable is called with the full path of the device mapper (including /dev/mapper/). In isLuksMapperAvailable a 'cryptsetup status' is performed with that input. However, if you call 'cryptsetup status' with the full path instead of the actual name of the device mapper it will (at least on RHEL 6) return 1 (wrong parameters) as error code, not 4 (wrong device specified). And the user will receive the "Cannot remove device mapper handle ..." error message. The fix is to strip the /dev/mapper part and only run 'cryptsetup status' using the basename. --- luks.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/luks.c b/luks.c index 466b6d5..6cdad10 100644 --- a/luks.c +++ b/luks.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "exec.h" #include "luks.h" @@ -52,10 +53,13 @@ bool isLuks(const char *aBlockDevice) { /* Returns if the given device mapper name is available (i.e. not active at the * moment) */ bool isLuksMapperAvailable(const char *aMapperName) { + char *bname; + bname = basename(aMapperName); + const char *arguments[] = { "cryptsetup", "status", - aMapperName, + bname, NULL };