summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-10-08 22:18:12 +0200
committerLennart Poettering <lennart@poettering.net>2021-10-11 11:12:29 +0200
commita2236110c335ff78df87f6b2e4316e75e6133592 (patch)
tree2f813ca286b1f2929d8c34204cc375f1e4e7894d /src
parent5cbe70af0252a5e4eb685303fdba692186811f00 (diff)
downloadsystemd-a2236110c335ff78df87f6b2e4316e75e6133592.tar.gz
cryptsetup: minor modernizations
Diffstat (limited to 'src')
-rw-r--r--src/cryptsetup/cryptsetup.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index fc63f8834e..250a8314f6 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -848,11 +848,11 @@ static int attach_luks2_by_fido2(
void *usrptr,
uint32_t activation_flags) {
- int r = -EOPNOTSUPP;
#if HAVE_LIBCRYPTSETUP_PLUGINS
- char **p;
- _cleanup_strv_free_erase_ char **pins = NULL;
AskPasswordFlags flags = ASK_PASSWORD_PUSH_CACHE | ASK_PASSWORD_ACCEPT_CACHED;
+ _cleanup_strv_free_erase_ char **pins = NULL;
+ char **p;
+ int r;
r = crypt_activate_by_token_pin(cd, name, "systemd-fido2", CRYPT_ANY_TOKEN, NULL, 0, usrptr, activation_flags);
if (r > 0) /* returns unlocked keyslot id on success */
@@ -891,8 +891,10 @@ static int attach_luks2_by_fido2(
flags &= ~ASK_PASSWORD_ACCEPT_CACHED;
}
-#endif
return r;
+#else
+ return -EOPNOTSUPP;
+#endif
}
static int attach_luks_or_plain_or_bitlk_by_fido2(
@@ -1050,9 +1052,10 @@ static int attach_luks2_by_pkcs11(
bool headless,
uint32_t flags) {
- int r = -EOPNOTSUPP;
#if HAVE_LIBCRYPTSETUP_PLUGINS
- if (!crypt_get_type(cd) || strcmp(crypt_get_type(cd), CRYPT_LUKS2))
+ int r;
+
+ if (!streq_ptr(crypt_get_type(cd), CRYPT_LUKS2))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Automatic PKCS#11 metadata requires LUKS2 device.");
systemd_pkcs11_plugin_params params = {
@@ -1064,8 +1067,11 @@ static int attach_luks2_by_pkcs11(
r = crypt_activate_by_token_pin(cd, name, "systemd-pkcs11", CRYPT_ANY_TOKEN, NULL, 0, &params, flags);
if (r > 0) /* returns unlocked keyslot id on success */
r = 0;
-#endif
+
return r;
+#else
+ return -EOPNOTSUPP;
+#endif
}
static int attach_luks_or_plain_or_bitlk_by_pkcs11(