From d494d6688d69ae3adf2397450eb5ffc20c7fe235 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 4 Jun 2024 23:06:27 +0100 Subject: [PATCH] cryptsetup: check keyring cache passphrase at least once The first try will be on the TPM2, so in practice this was always skipped as it happens only on the first try. Use a different bool to track this. --- src/cryptsetup/cryptsetup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 638e9d0c792..85897aecace 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -2416,6 +2416,7 @@ static int run(int argc, char *argv[]) { } #endif + bool use_cached_passphrase = true; _cleanup_strv_free_erase_ char **passwords = NULL; for (tries = 0; arg_tries == 0 || tries < arg_tries; tries++) { log_debug("Beginning attempt %u to unlock.", tries); @@ -2451,7 +2452,8 @@ static int run(int argc, char *argv[]) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No passphrase or recovery key registered."); } - r = get_password(volume, source, until, tries == 0 && !arg_verify, passphrase_type, &passwords); + r = get_password(volume, source, until, use_cached_passphrase && !arg_verify, passphrase_type, &passwords); + use_cached_passphrase = false; if (r == -EAGAIN) continue; if (r < 0) -- 2.47.3