summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2013-10-09 21:40:24 +0200
committerStef Walter <stef@thewalter.net>2014-06-23 11:33:48 +0200
commit47dfe3d944bb58682ce1eec90fc58ba93eab5711 (patch)
treeb8f27e69da906632f5b08a77b9ffaf0b473bf056
parent4a33183a910809f7a6f28dc53250789d14da3281 (diff)
downloadp11-kit-47dfe3d944bb58682ce1eec90fc58ba93eab5711.tar.gz
modules: Make config file and module configs overridable by tests
-rw-r--r--p11-kit/modules.c15
-rw-r--r--p11-kit/private.h7
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);