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:
Milan Broz
2021-06-13 20:32:40 +02:00
parent f79ef935a7
commit df5e54545e
8 changed files with 40 additions and 10 deletions

View File

@@ -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;