From 47dfe3d944bb58682ce1eec90fc58ba93eab5711 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 9 Oct 2013 21:40:24 +0200 Subject: modules: Make config file and module configs overridable by tests --- p11-kit/modules.c | 15 +++++++++++---- p11-kit/private.h | 7 +++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/p11-kit/modules.c b/p11-kit/modules.c index b373544..7ea4296 100644 --- a/p11-kit/modules.c +++ b/p11-kit/modules.c @@ -172,6 +172,13 @@ static struct _Shared { p11_dict *config; } gl = { NULL, NULL }; +/* These are global variables to be overridden in tests */ +const char *p11_config_system_file = P11_SYSTEM_CONFIG_FILE; +const char *p11_config_user_file = P11_USER_CONFIG_FILE; +const char *p11_config_package_modules = P11_PACKAGE_CONFIG_MODULES; +const char *p11_config_system_modules = P11_SYSTEM_CONFIG_MODULES; +const char *p11_config_user_modules = P11_USER_CONFIG_MODULES; + /* ----------------------------------------------------------------------------- * P11-KIT FUNCTIONALITY */ @@ -501,16 +508,16 @@ load_registered_modules_unlocked (void) return CKR_OK; /* Load the global configuration files */ - config = _p11_conf_load_globals (P11_SYSTEM_CONFIG_FILE, P11_USER_CONFIG_FILE, &mode); + config = _p11_conf_load_globals (p11_config_system_file, p11_config_user_file, &mode); if (config == NULL) return CKR_GENERAL_ERROR; assert (mode != CONF_USER_INVALID); configs = _p11_conf_load_modules (mode, - P11_PACKAGE_CONFIG_MODULES, - P11_SYSTEM_CONFIG_MODULES, - P11_USER_CONFIG_MODULES); + p11_config_package_modules, + p11_config_system_modules, + p11_config_user_modules); if (configs == NULL) { rv = CKR_GENERAL_ERROR; p11_dict_free (config); diff --git a/p11-kit/private.h b/p11-kit/private.h index 0fa221b..1de61eb 100644 --- a/p11-kit/private.h +++ b/p11-kit/private.h @@ -38,6 +38,13 @@ #include "compat.h" #include "pkcs11.h" +/* These are global variables to be overridden in tests */ +extern const char *p11_config_system_file; +extern const char *p11_config_user_file; +extern const char *p11_config_package_modules; +extern const char *p11_config_system_modules; +extern const char *p11_config_user_modules; + CK_RV _p11_load_config_files_unlocked (const char *system_conf, const char *user_conf, int *user_mode); -- cgit v1.2.1