pass NULL to library_init() to load settings from default file
authorMartin Willi <martin@strongswan.org>
Tue, 8 Sep 2009 18:01:13 +0000 (20:01 +0200)
committerMartin Willi <martin@strongswan.org>
Thu, 10 Sep 2009 16:52:42 +0000 (18:52 +0200)
22 files changed:
scripts/Makefile.am
scripts/dh_speed.c
scripts/pubkey_speed.c
src/charon/Makefile.am
src/charon/daemon.c
src/charon/plugins/sql/Makefile.am
src/charon/plugins/sql/pool.c
src/libstrongswan/Makefile.am
src/libstrongswan/settings.c
src/libstrongswan/settings.h
src/manager/Makefile.am
src/manager/main.c
src/medsrv/Makefile.am
src/medsrv/main.c
src/openac/Makefile.am
src/openac/openac.c
src/pki/Makefile.am
src/pki/pki.c
src/pluto/Makefile.am
src/pluto/plutomain.c
src/scepclient/Makefile.am
src/scepclient/scepclient.c

index 8a70d79..24e3cd1 100644 (file)
@@ -1,7 +1,6 @@
 INCLUDES = -I$(top_srcdir)/src/libstrongswan
 AM_CFLAGS = \
--DPLUGINS="\"${libstrongswan_plugins}\"" \
--DSTRONGSWAN_CONF=\"${strongswan_conf}\"
+-DPLUGINS="\"${libstrongswan_plugins}\""
 
 noinst_PROGRAMS = bin2array bin2sql id2sql key2keyid keyid2sql \
        thread_analysis dh_speed pubkey_speed
index 80a1d2d..b85bf1a 100644 (file)
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
                usage();
        }
 
-       library_init(STRONGSWAN_CONF);
+       library_init(NULL);
        lib->plugins->load(lib->plugins, NULL, argv[1]);
        atexit(library_deinit);
 
index b51de09..e6c6688 100644 (file)
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
                usage();
        }
 
-       library_init(STRONGSWAN_CONF);
+       library_init(NULL);
        lib->plugins->load(lib->plugins, NULL, argv[1]);
        atexit(library_deinit);
 
index 54fc764..525b201 100644 (file)
@@ -105,8 +105,7 @@ credentials/credential_set.h
 INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
 AM_CFLAGS = -rdynamic \
   -DIPSEC_DIR=\"${ipsecdir}\" \
-  -DIPSEC_PIDDIR=\"${piddir}\" \
-  -DSTRONGSWAN_CONF=\"${strongswan_conf}\"
+  -DIPSEC_PIDDIR=\"${piddir}\"
 charon_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lpthread -lm $(DLLIB) $(SOCKLIB)
 
 # compile options
index 2580430..a1ec3ad 100644 (file)
@@ -684,7 +684,7 @@ int main(int argc, char *argv[])
        dbg = dbg_stderr;
 
        /* initialize library */
-       if (!library_init(STRONGSWAN_CONF))
+       if (!library_init(NULL))
        {
                library_deinit();
                exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
index bbbc5a2..c6a382c 100644 (file)
@@ -2,7 +2,6 @@
 INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
 
 AM_CFLAGS = -rdynamic \
-  -DSTRONGSWAN_CONF=\"${strongswan_conf}\" \
   -DPLUGINS=\""${libstrongswan_plugins}\""
 
 plugin_LTLIBRARIES = libstrongswan-sql.la
index d59c4c8..55d82da 100644 (file)
@@ -624,7 +624,7 @@ int main(int argc, char *argv[])
        atexit(library_deinit);
 
        /* initialize library */
-       if (!library_init(STRONGSWAN_CONF))
+       if (!library_init(NULL))
        {
                exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
        }
index ebf7e4e..7cba9fe 100644 (file)
@@ -54,7 +54,8 @@ libstrongswan_la_LIBADD = -lpthread $(DLLIB) $(BTLIB) $(SOCKLIB) $(RTLIB)
 INCLUDES = -I$(top_srcdir)/src/libstrongswan
 AM_CFLAGS = \
 -DIPSEC_DIR=\"${ipsecdir}\" \
--DPLUGINDIR=\"${plugindir}\"
+-DPLUGINDIR=\"${plugindir}\" \
+-DSTRONGSWAN_CONF=\"${strongswan_conf}\"
 
 if USE_LEAK_DETECTIVE
   AM_CFLAGS += -DLEAK_DETECTIVE
index b502c02..d0937dd 100644 (file)
@@ -484,8 +484,12 @@ static void destroy(private_settings_t *this)
  */
 settings_t *settings_create(char *file)
 {
-       private_settings_t *this = malloc_thing(private_settings_t);
+       private_settings_t *this;
+       char *pos;
+       FILE *fd;
+       int len;
 
+       this = malloc_thing(private_settings_t);
        this->public.get_str = (char*(*)(settings_t*, char *key, char* def, ...))get_str;
        this->public.get_int = (int(*)(settings_t*, char *key, int def, ...))get_int;
        this->public.get_time = (u_int32_t(*)(settings_t*, char *key, u_int32_t def, ...))get_time;
@@ -496,39 +500,35 @@ settings_t *settings_create(char *file)
        this->top = NULL;
        this->text = NULL;
 
-       if (file)
+       if (file == NULL)
        {
-               FILE *fd;
-               int len;
-               char *pos;
-
-               fd = fopen(file, "r");
-               if (fd == NULL)
-               {
-                       DBG1("'%s' does not exist or is not readable", file);
-                       return &this->public;
-               }
-               fseek(fd, 0, SEEK_END);
-               len = ftell(fd);
-               rewind(fd);
-               this->text = malloc(len + 1);
-               this->text[len] = '\0';
-               if (fread(this->text, 1, len, fd) != len)
-               {
-                       free(this->text);
-                       this->text = NULL;
-                       return &this->public;
-               }
-               fclose(fd);
+               file = STRONGSWAN_CONF;
+       }
+       fd = fopen(file, "r");
+       if (fd == NULL)
+       {
+               DBG1("'%s' does not exist or is not readable", file);
+               return &this->public;
+       }
+       fseek(fd, 0, SEEK_END);
+       len = ftell(fd);
+       rewind(fd);
+       this->text = malloc(len + 1);
+       this->text[len] = '\0';
+       if (fread(this->text, 1, len, fd) != len)
+       {
+               free(this->text);
+               this->text = NULL;
+               return &this->public;
+       }
+       fclose(fd);
 
-               pos = this->text;
-               this->top = parse_section(&pos, NULL);
-               if (this->top == NULL)
-               {
-                       free(this->text);
-                       this->text = NULL;
-                       return &this->public;
-               }
+       pos = this->text;
+       this->top = parse_section(&pos, NULL);
+       if (this->top == NULL)
+       {
+               free(this->text);
+               this->text = NULL;
        }
        return &this->public;
 }
index e10158f..7a28225 100644 (file)
@@ -110,7 +110,10 @@ struct settings_t {
 };
 
 /**
- * Load setings from a file.
+ * Load settings from a file.
+ *
+ * @param file                 file to read settings from, NULL for default
+ * @return                             settings object
  */
 settings_t *settings_create(char *file);
 
index b5948c0..e6c31e9 100644 (file)
@@ -14,7 +14,6 @@ manager_fcgi_LDADD = $(top_builddir)/src/libfast/libfast.la ${xml_LIBS}
 
 INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libfast ${xml_CFLAGS}
 AM_CFLAGS = -rdynamic \
-  -DSTRONGSWAN_CONF=\"${strongswan_conf}\" \
   -DIPSECDIR=\"${ipsecdir}\" \
   -DIPSEC_PIDDIR=\"${piddir}\" \
   -DPLUGINS=\""${libstrongswan_plugins}\""
index 990beda..1f5c451 100644 (file)
@@ -34,7 +34,7 @@ int main (int arc, char *argv[])
        bool debug;
        int threads, timeout;
 
-       library_init(STRONGSWAN_CONF);
+       library_init(NULL);
        if (!lib->plugins->load(lib->plugins, NULL,
                        lib->settings->get_str(lib->settings, "manager.load", PLUGINS)))
        {
index be9360b..9f5c9e2 100644 (file)
@@ -11,7 +11,6 @@ medsrv_fcgi_LDADD = $(top_builddir)/src/libfast/libfast.la
 
 INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libfast
 AM_CFLAGS = -rdynamic \
-  -DSTRONGSWAN_CONF=\"${strongswan_conf}\" \
   -DIPSECDIR=\"${ipsecdir}\" \
   -DIPSEC_PIDDIR=\"${piddir}\" \
   -DPLUGINS=\""${libstrongswan_plugins}\""
index 15d1f7f..1f43a7e 100644 (file)
@@ -33,7 +33,7 @@ int main(int arc, char *argv[])
        char *uri;
        int timeout, threads;
 
-       library_init(STRONGSWAN_CONF);
+       library_init(NULL);
        if (!lib->plugins->load(lib->plugins, NULL,
                        lib->settings->get_str(lib->settings, "medsrv.load", PLUGINS)))
        {
index e36b623..ca62382 100644 (file)
@@ -5,7 +5,6 @@ dist_man_MANS = openac.8
 INCLUDES = -I$(top_srcdir)/src/libstrongswan
 AM_CFLAGS = \
   -DIPSEC_CONFDIR=\"${sysconfdir}\" \
-  -DSTRONGSWAN_CONF=\"${strongswan_conf}\" \
   -DPLUGINS=\""${libstrongswan_plugins}\""
 openac_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
 
index de95643..f63676b 100755 (executable)
@@ -221,7 +221,7 @@ int main(int argc, char **argv)
 
        /* initialize library */
        atexit(library_deinit);
-       if (!library_init(STRONGSWAN_CONF))
+       if (!library_init(NULL))
        {
                exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
        }
index 7eb5795..8bd32e6 100644 (file)
@@ -7,5 +7,4 @@ pki_SOURCES = pki.c pki.h command.c command.h \
 pki_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
 INCLUDES = -I$(top_srcdir)/src/libstrongswan
 AM_CFLAGS = \
-       -DPLUGINS=\""${libstrongswan_plugins}\"" \
-       -DSTRONGSWAN_CONF=\"${strongswan_conf}\"
+       -DPLUGINS=\""${libstrongswan_plugins}\""
index aa873a4..c1a0702 100644 (file)
@@ -79,7 +79,7 @@ hash_algorithm_t get_digest(char *name)
 int main(int argc, char *argv[])
 {
        atexit(library_deinit);
-       if (!library_init(STRONGSWAN_CONF))
+       if (!library_init(NULL))
        {
                exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
        }
index 77d366b..a51f305 100644 (file)
@@ -69,7 +69,6 @@ AM_CFLAGS = \
 -DIPSEC_PIDDIR=\"${piddir}\" \
 -DSHARED_SECRETS_FILE=\"${confdir}/ipsec.secrets\" \
 -DPLUGINS=\""${pluto_plugins}\"" \
--DSTRONGSWAN_CONF=\"${strongswan_conf}\" \
 -DPKCS11_DEFAULT_LIB=\"${default_pkcs11}\" \
 -DKERNEL26_SUPPORT -DKERNEL26_HAS_KAME_DUPLICATES \
 -DPLUTO -DKLIPS -DDEBUG
index 18e8228..78afeac 100644 (file)
@@ -261,7 +261,7 @@ int main(int argc, char **argv)
 #endif /* CAPABILITIES */
 
        /* initialize library and optionsfrom */
-       if (!library_init(STRONGSWAN_CONF))
+       if (!library_init(NULL))
        {
                library_deinit();
                exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
index 8a2837d..88481fa 100644 (file)
@@ -18,7 +18,6 @@ INCLUDES = \
 AM_CFLAGS = \
 -DIPSEC_CONFDIR=\"${sysconfdir}\" \
 -DPLUGINS=\""${pluto_plugins}\"" \
--DSTRONGSWAN_CONF=\"${strongswan_conf}\" \
 -DDEBUG -DNO_PLUTO
 
 LIBSTRONGSWANBUILDDIR=$(top_builddir)/src/libstrongswan
index 4b9c02e..34b9854 100644 (file)
@@ -387,7 +387,7 @@ int main(int argc, char **argv)
        log_to_stderr     = TRUE;
 
        /* initialize library */
-       if (!library_init(STRONGSWAN_CONF))
+       if (!library_init(NULL))
        {
                library_deinit();
                exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);