]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: check keyring cache passphrase at least once 33197/head
authorLuca Boccassi <bluca@debian.org>
Tue, 4 Jun 2024 22:06:27 +0000 (23:06 +0100)
committerLuca Boccassi <bluca@debian.org>
Tue, 4 Jun 2024 22:18:13 +0000 (23:18 +0100)
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

index 638e9d0c7920bbcaddb8f0948b5618e568f12288..85897aecace7b63d08c7a3a5d59f05bbca822eeb 100644 (file)
@@ -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)