fixed manager plugin loading
authorMartin Willi <martin@strongswan.org>
Fri, 28 Mar 2008 12:41:05 +0000 (12:41 -0000)
committerMartin Willi <martin@strongswan.org>
Fri, 28 Mar 2008 12:41:05 +0000 (12:41 -0000)
manager uses strongswan.conf to read its configuration

src/manager/Makefile.am
src/manager/main.c

index 366022f..4b24175 100644 (file)
@@ -11,7 +11,8 @@ controller/gateway_controller.c controller/gateway_controller.h
 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 -DIPSECDIR=\"${ipsecdir}\" -DIPSEC_PIDDIR=\"${piddir}\"
+AM_CFLAGS = -rdynamic -DIPSECDIR=\"${ipsecdir}\" -DIPSEC_PIDDIR=\"${piddir}\" \
+  -DIPSEC_PLUGINDIR=\"${plugindir}\"
 
 ipsec_DATA = manager.db
 
index fc1f5fc..981f92f 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <dispatcher.h>
+#include <debug.h>
 #include <stdio.h>
 
 #include "manager.h"
 #include "controller/control_controller.h"
 #include "controller/config_controller.h"
 
-#define DBFILE IPSECDIR "/manager.db"
-#define SESSION_TIMEOUT 900
-#define THREADS 10
-
 int main (int arc, char *argv[])
 {
        dispatcher_t *dispatcher;
        storage_t *storage;
-       char *socket = NULL;
-       bool debug = FALSE;
-       
-#ifdef FCGI_SOCKET
-       socket = FCGI_SOCKET;
-       debug = TRUE;
-#endif /* FCGI_SOCKET */
+       char *socket;
+       char *database;
+       bool debug;
+       int threads, timeout;
 
-       library_init(IPSECDIR "/manager.conf");
+       library_init(IPSECDIR "/strongswan.conf");
+       lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, "libstrongswan-");
+       
+       socket = lib->settings->get_str(lib->settings, "manager.socket", NULL);
+       debug = lib->settings->get_bool(lib->settings, "manager.debug", FALSE);
+       timeout = lib->settings->get_int(lib->settings, "manager.timeout", 900);
+       threads = lib->settings->get_int(lib->settings, "manager.threads", 10);
+       database = lib->settings->get_str(lib->settings, "manager.database", NULL);
+       if (!database)
+       {
+               DBG1("database URI undefined, set manager.database in strongswan.conf");
+               return 1;
+       }
        
-       storage = storage_create("sqlite://"DBFILE);
+       storage = storage_create(database);
        if (storage == NULL)
        {
-               fprintf(stderr, "opening database '%s' failed.\n", DBFILE);
                return 1;
        }
        
-       dispatcher = dispatcher_create(socket, debug, SESSION_TIMEOUT,
+       dispatcher = dispatcher_create(socket, debug, timeout,
                                                (context_constructor_t)manager_create, storage);
        dispatcher->add_controller(dispatcher, ikesa_controller_create, NULL);
        dispatcher->add_controller(dispatcher, gateway_controller_create, NULL);
@@ -59,7 +64,7 @@ int main (int arc, char *argv[])
        dispatcher->add_controller(dispatcher, control_controller_create, NULL);
        dispatcher->add_controller(dispatcher, config_controller_create, NULL);
        
-       dispatcher->run(dispatcher, THREADS);
+       dispatcher->run(dispatcher, threads);
        
        dispatcher->waitsignal(dispatcher);