mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-20 07:10:08 +01:00
Fix init_by_name to allow unknown cipher format in dm-crypt as null context.
Deactivation code should deactivate dm-crypt device even if it is unknown for libcryptsetup. Previous fix for cipher specification was too strict. Let's allow initialization as null context, that allow status and deactivate to be usable again.
This commit is contained in:
@@ -1276,6 +1276,12 @@ static int _init_by_name_crypt(struct crypt_device *cd, const char *name)
|
|||||||
r = crypt_parse_name_and_mode(tgt->type == DM_LINEAR ? "null" : tgt->u.crypt.cipher, cipher,
|
r = crypt_parse_name_and_mode(tgt->type == DM_LINEAR ? "null" : tgt->u.crypt.cipher, cipher,
|
||||||
&key_nums, cipher_mode);
|
&key_nums, cipher_mode);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
/* Allow crypt null context with unknown cipher string */
|
||||||
|
if (tgt->type == DM_CRYPT && !tgt->u.crypt.integrity) {
|
||||||
|
crypt_set_null_type(cd);
|
||||||
|
r = 0;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
log_err(cd, _("No known cipher specification pattern detected for active device %s."), name);
|
log_err(cd, _("No known cipher specification pattern detected for active device %s."), name);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,9 +190,8 @@ echo $PASSWORD | $CRYPTSETUP create -h sha256 -c 'capi:xts(aes)-plain64' -s 256
|
|||||||
$CRYPTSETUP close "$DEV_NAME"_tstdev || fail
|
$CRYPTSETUP close "$DEV_NAME"_tstdev || fail
|
||||||
echo $PASSWORD | $CRYPTSETUP create -h sha256 -c 'capi:xts(ecb(aes-generic))-plain64' -s 256 "$DEV_NAME"_tstdev /dev/mapper/$DEV_NAME 2>/dev/null && fail
|
echo $PASSWORD | $CRYPTSETUP create -h sha256 -c 'capi:xts(ecb(aes-generic))-plain64' -s 256 "$DEV_NAME"_tstdev /dev/mapper/$DEV_NAME 2>/dev/null && fail
|
||||||
dmsetup create "$DEV_NAME"_tstdev --table "0 8 crypt capi:xts(ecb(aes-generic))-plain64 $KEY 0 /dev/mapper/$DEV_NAME 0" || fail
|
dmsetup create "$DEV_NAME"_tstdev --table "0 8 crypt capi:xts(ecb(aes-generic))-plain64 $KEY 0 /dev/mapper/$DEV_NAME 0" || fail
|
||||||
$CRYPTSETUP status "$DEV_NAME"_tstdev >/dev/null 2>&1 && fail
|
$CRYPTSETUP status "$DEV_NAME"_tstdev 2>/dev/null | grep "type:" | grep -q "n/a" || fail
|
||||||
$CRYPTSETUP close "$DEV_NAME"_tstdev 2>/dev/null && fail
|
$CRYPTSETUP close "$DEV_NAME"_tstdev 2>/dev/null || fail
|
||||||
dmsetup remove "$DEV_NAME"_tstdev || fail
|
|
||||||
echo [OK]
|
echo [OK]
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|||||||
Reference in New Issue
Block a user