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:
Milan Broz
2023-06-05 16:02:06 +02:00
parent 2712882aa3
commit 53aa5f6c4f
2 changed files with 8 additions and 3 deletions

View File

@@ -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,
&key_nums, cipher_mode);
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);
goto out;
}