From: Lennart Poettering Date: Mon, 10 Jun 2024 15:47:43 +0000 (+0200) Subject: cryptsetup: merge two mostly equivalent functions X-Git-Tag: v257-rc1~1163^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86854ee6e6ec14b95504330e1c6f53855f99f2ea;p=thirdparty%2Fsystemd.git cryptsetup: merge two mostly equivalent functions --- diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index ac46793e057..7df47111f0d 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -1251,7 +1251,7 @@ static int run_security_device_monitor( } } -static bool libcryptsetup_plugins_support(void) { +static bool use_token_plugins(void) { #if HAVE_TPM2 /* Currently, there's no way for us to query the volume key when plugins are used. Hence don't use @@ -1401,7 +1401,7 @@ static int attach_luks_or_plain_or_bitlk_by_fido2( size_t decrypted_key_size; _cleanup_free_ char *friendly = NULL; int keyslot = arg_key_slot, r; - bool use_libcryptsetup_plugin = libcryptsetup_plugins_support(); + bool use_libcryptsetup_plugin = use_token_plugins(); assert(cd); assert(name); @@ -1553,7 +1553,7 @@ static int attach_luks_or_plain_or_bitlk_by_pkcs11( _cleanup_free_ void *discovered_key = NULL; int keyslot = arg_key_slot, r; const char *uri = NULL; - bool use_libcryptsetup_plugin = libcryptsetup_plugins_support(); + bool use_libcryptsetup_plugin = use_token_plugins(); assert(cd); assert(name); @@ -1707,20 +1707,6 @@ static int make_tpm2_device_monitor( return 0; } -static bool use_token_plugins(void) { - int r; - - /* Disable tokens if we shall measure, since we won't get access to the volume key then. */ - if (arg_tpm2_measure_pcr != UINT_MAX) - return false; - - r = getenv_bool("SYSTEMD_CRYPTSETUP_USE_TOKEN_MODULE"); - if (r < 0 && r != -ENXIO) - log_debug_errno(r, "Failed to parse $SYSTEMD_CRYPTSETUP_USE_TOKEN_MODULE value, ignoring: %m"); - - return r != 0; -} - static int attach_luks2_by_tpm2_via_plugin( struct crypt_device *cd, const char *name, @@ -1735,9 +1721,9 @@ static int attach_luks2_by_tpm2_via_plugin( .pcrlock_path = arg_tpm2_pcrlock, }; - if (!libcryptsetup_plugins_support()) + if (!use_token_plugins()) return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), - "Libcryptsetup has external plugins support disabled."); + "libcryptsetup has external plugins support disabled."); return crypt_activate_by_token_pin_ask_password( cd,