]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: ask for PIN when trying to activate using a LUKS2 token plugin
authorJonas Witschel <diabonas@archlinux.org>
Wed, 25 May 2022 12:06:12 +0000 (14:06 +0200)
committerJonas Witschel <diabonas@archlinux.org>
Fri, 5 Aug 2022 10:22:27 +0000 (12:22 +0200)
crypt_activate_by_token() fails with ENOANO if the token is protected with a
PIN, in this case we need to call crypt_activate_by_token_pin() with a PIN.
This logic is already implemented in
crypt_activate_by_token_pin_ask_password().

This code path is relevant when using systemd-gpt-auto-generator because there
is no a priory information about the type of the used security device, so
systemd-cryptsetup tries to unlock the volume using the corresponding
cryptsetup plugin.

src/cryptsetup/cryptsetup.c

index 7a9878e6897be56bbbc716744d2835c21f7715cc..c8e71c43de5c9cca0c851e45e2021d593341f8d5 100644 (file)
@@ -1886,7 +1886,17 @@ static int run(int argc, char *argv[]) {
 
                         /* Tokens are available in LUKS2 only, but it is ok to call (and fail) with LUKS1. */
                         if (!key_file && !key_data) {
-                                r = crypt_activate_by_token(cd, volume, CRYPT_ANY_TOKEN, NULL, flags);
+                                r = crypt_activate_by_token_pin_ask_password(
+                                                cd,
+                                                volume,
+                                                NULL,
+                                                until,
+                                                arg_headless,
+                                                NULL,
+                                                flags,
+                                                "Please enter LUKS2 token PIN:",
+                                                "luks2-pin",
+                                                "cryptsetup.luks2-pin");
                                 if (r >= 0) {
                                         log_debug("Volume %s activated with LUKS token id %i.", volume, r);
                                         return 0;