mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Add API and CLI option to disable token plugins.
This could be useful for debugging external plugins or ot intentionally disable loading of a token library.
This commit is contained in:
@@ -25,6 +25,12 @@
|
||||
|
||||
#include "luks2_internal.h"
|
||||
|
||||
#if USE_EXTERNAL_TOKENS
|
||||
static bool external_tokens_enabled = true;
|
||||
#else
|
||||
static bool external_tokens_enabled = false;
|
||||
#endif
|
||||
|
||||
static struct crypt_token_handler_internal token_handlers[LUKS2_TOKENS_MAX] = {
|
||||
/* keyring builtin token */
|
||||
{
|
||||
@@ -38,13 +44,14 @@ static struct crypt_token_handler_internal token_handlers[LUKS2_TOKENS_MAX] = {
|
||||
}
|
||||
};
|
||||
|
||||
void crypt_token_external_disable(void)
|
||||
{
|
||||
external_tokens_enabled = false;
|
||||
}
|
||||
|
||||
int crypt_token_external_support(void)
|
||||
{
|
||||
#if USE_EXTERNAL_TOKENS
|
||||
return 0;
|
||||
#else
|
||||
return -ENOTSUP;
|
||||
#endif
|
||||
return external_tokens_enabled ? 0 : -ENOTSUP;
|
||||
}
|
||||
|
||||
#if USE_EXTERNAL_TOKENS
|
||||
@@ -127,6 +134,9 @@ crypt_token_load_external(struct crypt_device *cd, const char *name, struct cryp
|
||||
char buf[512];
|
||||
int r;
|
||||
|
||||
if (!external_tokens_enabled)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (!ret || !name)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user