cryptsetup: Skip tokens with JSON parsing errors

The plugin already continues on parsing errors but the fallback path
not. The plugin swallows ENOMEM as well which is too much, though.
Continue on JSON parsing errors by mapping them to EUCLEAN in
cryptsetup_get_token_as_json and handle that in any call site, not just
the TPM fallback path but also others.
This commit is contained in:
Kai Lüke
2026-07-10 08:07:47 +02:00
committed by Kai Lüke
parent 14c0b8414f
commit 7fb6b9c2a2
8 changed files with 12 additions and 6 deletions
+2 -1
View File
@@ -164,6 +164,7 @@ int cryptsetup_get_token_as_json(
* -EINVAL → token index out of range or "type" field missing
* -ENOENT → token doesn't exist
* -EMEDIUMTYPE → "verify_type" specified and doesn't match token's type
* -EUCLEAN → token JSON data cannot be parsed
*/
r = sym_crypt_token_json_get(cd, idx, &text);
@@ -172,7 +173,7 @@ int cryptsetup_get_token_as_json(
r = sd_json_parse(text, 0, &v, NULL, NULL);
if (r < 0)
return r;
return r == -ENOMEM ? r : -EUCLEAN; /* Report unparseable token data in a single way for callers to skip */
if (verify_type) {
sd_json_variant *w;