]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: pass selected mode to crypt_load() when doing LUKS 16111/head
authorLennart Poettering <lennart@poettering.net>
Tue, 9 Jun 2020 12:21:32 +0000 (14:21 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 9 Jun 2020 12:24:21 +0000 (14:24 +0200)
This doesn't fix anything IRL, but is a bit cleaner, since it makes sure
that arg_type is properly passed to crypt_load() in all cases.

We actually never set arg_type to CRYPT_LUKS2, which is why this wasn't
noticed before, but theoretically this might change one day, and
existing comments suggest it as possible value for arg_type, hence let's
process it properly.

src/cryptsetup/cryptsetup.c

index a8d72fcf5a85fc1009cf48de26bb735e9745eb49..6d3f842dbe1ec5fb5f6bf7d70ec3ff0b574f67ac 100644 (file)
@@ -932,8 +932,8 @@ static int run(int argc, char *argv[]) {
                                 log_warning("Key file %s is world-readable. This is not a good idea!", key_file);
                 }
 
-                if (!arg_type || STR_IN_SET(arg_type, ANY_LUKS, CRYPT_LUKS1)) {
-                        r = crypt_load(cd, CRYPT_LUKS, NULL);
+                if (!arg_type || STR_IN_SET(arg_type, ANY_LUKS, CRYPT_LUKS1, CRYPT_LUKS2)) {
+                        r = crypt_load(cd, !arg_type || streq(arg_type, ANY_LUKS) ? CRYPT_LUKS : arg_type, NULL);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to load LUKS superblock on device %s: %m", crypt_get_device_name(cd));