library: Store the used root strongswan.conf configuration
authorMartin Willi <martin@revosec.ch>
Thu, 17 Jul 2014 15:47:42 +0000 (17:47 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 22 Sep 2014 11:40:39 +0000 (13:40 +0200)
src/libstrongswan/library.c
src/libstrongswan/library.h

index 4d2b3eb..715f5bc 100644 (file)
 
 #define CHECKSUM_LIBRARY IPSEC_LIB_DIR"/libchecksum.so"
 
+#ifndef STRONGSWAN_CONF
+#define STRONGSWAN_CONF NULL
+#endif
+
 typedef struct private_library_t private_library_t;
 
 /**
@@ -149,6 +153,7 @@ void library_deinit()
        utils_deinit();
        threads_deinit();
 
+       free(this->public.conf);
        free((void*)this->public.ns);
        free(this);
        lib = NULL;
@@ -258,6 +263,7 @@ bool library_init(char *settings, const char *namespace)
                        .get = _get,
                        .set = _set,
                        .ns = strdup(namespace ?: "libstrongswan"),
+                       .conf = strdupnull(settings ?: STRONGSWAN_CONF),
                },
                .ref = 1,
        );
@@ -304,13 +310,7 @@ bool library_init(char *settings, const char *namespace)
        this->objects = hashtable_create((hashtable_hash_t)hash,
                                                                         (hashtable_equals_t)equals, 4);
 
-#ifdef STRONGSWAN_CONF
-       if (!settings)
-       {
-               settings = STRONGSWAN_CONF;
-       }
-#endif
-       this->public.settings = settings_create(settings);
+       this->public.settings = settings_create(this->public.conf);
        /* all namespace settings may fall back to libstrongswan */
        lib->settings->add_fallback(lib->settings, lib->ns, "libstrongswan");
 
index 37a83fa..2bd5e35 100644 (file)
@@ -147,6 +147,11 @@ struct library_t {
        const char *ns;
 
        /**
+        * Main configuration file passed to library_init(), the default, or NULL
+        */
+       char *conf;
+
+       /**
         * Printf hook registering facility
         */
        printf_hook_t *printf_hook;