]> granicus.if.org Git - p11-kit/commitdiff
modules: Make config file and module configs overridable by tests
authorStef Walter <stef@thewalter.net>
Wed, 9 Oct 2013 19:40:24 +0000 (21:40 +0200)
committerStef Walter <stef@thewalter.net>
Tue, 8 Jul 2014 06:57:31 +0000 (08:57 +0200)
p11-kit/modules.c
p11-kit/private.h

index bddc823e3de98882983dd82d365313f9c7086a43..cc382b29f8366444a5c36dee28dc3ca28fab8926 100644 (file)
@@ -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);
index 0fa221b573a14bfe7ed38bdb8d59ab642b0af42a..1de61eb85d4640c40e9b908b181e0bc2642c0248 100644 (file)
 #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);