Fix LUKS1 repair to repair wrong ECB mode.

1) Crypsetup repair should try to call crypt_repair() even
if crypt_load is ok - it has no validate system unlike LUKS2
and some errors cannot be hard load errors.

2) Move ECB fix to repair code, do not try magic on load that
no longer works.

And do not use ECB :)

Fixes: #664
This commit is contained in:
Milan Broz
2021-08-25 09:22:46 +02:00
parent 46b70d7317
commit 0066f9dd83
3 changed files with 27 additions and 8 deletions

View File

@@ -1235,7 +1235,11 @@ static int action_luksRepair(void)
crypt_set_log_callback(cd, quiet_log, &log_parms);
r = crypt_load(cd, luksType(device_type), NULL);
crypt_set_log_callback(cd, tool_log, &log_parms);
if (r == 0) {
if (r == 0 && isLUKS2(crypt_get_type(cd))) {
/*
* LUKS2 triggers autorepair in crypt_load() above
* LUKS1 need to call crypt_repair() even if crypt_load() is ok
*/
log_verbose(_("No known problems detected for LUKS header."));
goto out;
}