aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcharon')
-rw-r--r--src/libcharon/.gitignore1
-rw-r--r--src/libcharon/Makefile.am26
-rw-r--r--src/libcharon/bus/bus.h2
-rw-r--r--src/libcharon/daemon.c457
-rw-r--r--src/libcharon/daemon.h73
-rw-r--r--src/libcharon/plugins/android/Makefile.am2
-rw-r--r--src/libcharon/plugins/attr/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_aka/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_aka_3gpp2/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_gtc/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_identity/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_md5/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_mschapv2/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_radius/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_sim/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_sim_file/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_simaka_pseudonym/Makefile.am2
-rw-r--r--src/libcharon/plugins/eap_simaka_reauth/Makefile.am2
-rw-r--r--src/libcharon/plugins/kernel_klips/Makefile.am2
-rw-r--r--src/libcharon/plugins/kernel_netlink/Makefile.am2
-rw-r--r--src/libcharon/plugins/kernel_pfkey/Makefile.am2
-rw-r--r--src/libcharon/plugins/kernel_pfroute/Makefile.am2
-rw-r--r--src/libcharon/plugins/load_tester/Makefile.am2
-rw-r--r--src/libcharon/plugins/medcli/Makefile.am2
-rw-r--r--src/libcharon/plugins/medsrv/Makefile.am2
-rw-r--r--src/libcharon/plugins/nm/Makefile.am2
-rw-r--r--src/libcharon/plugins/resolve/Makefile.am2
-rw-r--r--src/libcharon/plugins/smp/Makefile.am2
-rw-r--r--src/libcharon/plugins/socket_default/Makefile.am2
-rw-r--r--src/libcharon/plugins/socket_dynamic/Makefile.am2
-rw-r--r--src/libcharon/plugins/socket_raw/Makefile.am2
-rw-r--r--src/libcharon/plugins/sql/Makefile.am2
-rw-r--r--src/libcharon/plugins/stroke/Makefile.am2
-rw-r--r--src/libcharon/plugins/uci/Makefile.am2
-rw-r--r--src/libcharon/plugins/unit_tester/Makefile.am2
-rw-r--r--src/libcharon/plugins/updown/Makefile.am2
36 files changed, 147 insertions, 474 deletions
diff --git a/src/libcharon/.gitignore b/src/libcharon/.gitignore
deleted file mode 100644
index 8357dae71..000000000
--- a/src/libcharon/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-charon
diff --git a/src/libcharon/Makefile.am b/src/libcharon/Makefile.am
index 8dd8a0e0c..e608d2206 100644
--- a/src/libcharon/Makefile.am
+++ b/src/libcharon/Makefile.am
@@ -1,6 +1,6 @@
-ipsec_PROGRAMS = charon
+lib_LTLIBRARIES = libcharon.la
-charon_SOURCES = \
+libcharon_la_SOURCES = \
bus/bus.c bus/bus.h \
bus/listeners/listener.h \
bus/listeners/file_logger.c bus/listeners/file_logger.h \
@@ -100,11 +100,11 @@ credentials/sets/ocsp_response_wrapper.c credentials/sets/ocsp_response_wrapper.
credentials/sets/cert_cache.c credentials/sets/cert_cache.h \
credentials/credential_set.h
-INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
-AM_CFLAGS = -rdynamic \
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
+AM_CFLAGS = \
-DIPSEC_DIR=\"${ipsecdir}\" \
-DIPSEC_PIDDIR=\"${piddir}\"
-charon_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lm $(PTHREADLIB) $(DLLIB) $(SOCKLIB)
+libcharon_la_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lm $(PTHREADLIB) $(DLLIB) $(SOCKLIB)
EXTRA_DIST = Android.mk
@@ -112,7 +112,7 @@ EXTRA_DIST = Android.mk
#################
if USE_ME
- charon_SOURCES += encoding/payloads/endpoint_notify.c encoding/payloads/endpoint_notify.h \
+ libcharon_la_SOURCES += encoding/payloads/endpoint_notify.c encoding/payloads/endpoint_notify.h \
processing/jobs/initiate_mediation_job.c processing/jobs/initiate_mediation_job.h \
processing/jobs/mediation_job.c processing/jobs/mediation_job.h \
sa/connect_manager.c sa/connect_manager.h \
@@ -121,20 +121,18 @@ if USE_ME
endif
if USE_CAPABILITIES
- charon_LDADD += -lcap
-endif
-
-if MONOLITHIC
- lib_LTLIBRARIES = libcharon.la
- charon_LDADD += $(top_builddir)/src/charon/libcharon.la
- libcharon_la_SOURCES =
- libcharon_la_LIBADD =
+ libcharon_la_LIBADD += -lcap
endif
# build optional plugins
########################
+if MONOLITHIC
SUBDIRS =
+else
+SUBDIRS = .
+endif
+
PLUGINS = ${libstrongswan_plugins}
if USE_LOAD_TESTER
diff --git a/src/libcharon/bus/bus.h b/src/libcharon/bus/bus.h
index af59a14a1..ca974d81b 100644
--- a/src/libcharon/bus/bus.h
+++ b/src/libcharon/bus/bus.h
@@ -15,7 +15,7 @@
/**
* @defgroup bus bus
- * @{ @ingroup charon
+ * @{ @ingroup libcharon
*/
#ifndef BUS_H_
diff --git a/src/libcharon/daemon.c b/src/libcharon/daemon.c
index dfb2ee38d..be9672f7d 100644
--- a/src/libcharon/daemon.c
+++ b/src/libcharon/daemon.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2009 Tobias Brunner
+ * Copyright (C) 2006-2010 Tobias Brunner
* Copyright (C) 2005-2009 Martin Willi
* Copyright (C) 2006 Daniel Roethlisberger
* Copyright (C) 2005 Jan Hutter
@@ -17,22 +17,10 @@
*/
#include <stdio.h>
-#ifdef HAVE_PRCTL
-#include <sys/prctl.h>
-#endif
-#define _POSIX_PTHREAD_SEMANTICS /* for two param sigwait on OpenSolaris */
-#include <signal.h>
-#undef _POSIX_PTHREAD_SEMANTICS
-#include <pthread.h>
-#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
-#include <string.h>
-#include <getopt.h>
#include <errno.h>
-#include <pwd.h>
-#include <grp.h>
#ifdef CAPABILITIES
#include <sys/capability.h>
#endif /* CAPABILITIES */
@@ -40,8 +28,6 @@
#include "daemon.h"
#include <library.h>
-#include <utils/backtrace.h>
-#include <threading/thread.h>
#include <selectors/traffic_selector.h>
#include <config/proposal.h>
@@ -60,11 +46,6 @@ struct private_daemon_t {
*/
daemon_t public;
- /**
- * Signal set used for signal handling.
- */
- sigset_t signal_set;
-
#ifdef CAPABILITIES
/**
* capabilities to keep
@@ -84,6 +65,11 @@ daemon_t *charon;
extern void (*dbg) (int level, char *fmt, ...);
/**
+ * we store the previous debug function so we can reset it
+ */
+static void (*dbg_old) (int level, char *fmt, ...);
+
+/**
* Logging hook for library logs, spreads debug message over bus
*/
static void dbg_bus(int level, char *fmt, ...)
@@ -96,76 +82,6 @@ static void dbg_bus(int level, char *fmt, ...)
}
/**
- * Logging hook for library logs, using stderr output
- */
-static void dbg_stderr(int level, char *fmt, ...)
-{
- va_list args;
-
- if (level <= 1)
- {
- va_start(args, fmt);
- fprintf(stderr, "00[LIB] ");
- vfprintf(stderr, fmt, args);
- fprintf(stderr, "\n");
- va_end(args);
- }
-}
-
-/**
- * Run the daemon and handle unix signals
- */
-static void run(private_daemon_t *this)
-{
- sigset_t set;
-
- /* handle SIGINT, SIGHUP ans SIGTERM in this handler */
- sigemptyset(&set);
- sigaddset(&set, SIGINT);
- sigaddset(&set, SIGHUP);
- sigaddset(&set, SIGTERM);
- sigprocmask(SIG_BLOCK, &set, NULL);
-
- while (TRUE)
- {
- int sig;
- int error;
-
- error = sigwait(&set, &sig);
- if (error)
- {
- DBG1(DBG_DMN, "error %d while waiting for a signal", error);
- return;
- }
- switch (sig)
- {
- case SIGHUP:
- {
- DBG1(DBG_DMN, "signal of type SIGHUP received. Ignored");
- break;
- }
- case SIGINT:
- {
- DBG1(DBG_DMN, "signal of type SIGINT received. Shutting down");
- charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
- return;
- }
- case SIGTERM:
- {
- DBG1(DBG_DMN, "signal of type SIGTERM received. Shutting down");
- charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
- return;
- }
- default:
- {
- DBG1(DBG_DMN, "unknown signal %d received. Ignored", sig);
- break;
- }
- }
- }
-}
-
-/**
* Clean up all daemon resources
*/
static void destroy(private_daemon_t *this)
@@ -205,7 +121,7 @@ static void destroy(private_daemon_t *this)
DESTROY_IF(this->public.processor);
/* rehook library logging, shutdown logging */
- dbg = dbg_stderr;
+ dbg = dbg_old;
DESTROY_IF(this->public.bus);
this->public.file_loggers->destroy_offset(this->public.file_loggers,
offsetof(file_logger_t, destroy));
@@ -214,40 +130,8 @@ static void destroy(private_daemon_t *this)
free(this);
}
-/**
- * drop daemon capabilities
- */
-static bool drop_capabilities(private_daemon_t *this)
-{
-#ifdef HAVE_PRCTL
- prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
-#endif
-
- if (setgid(charon->gid) != 0)
- {
- DBG1(DBG_DMN, "change to unprivileged group failed");
- return FALSE;
- }
- if (setuid(charon->uid) != 0)
- {
- DBG1(DBG_DMN, "change to unprivileged user failed");
- return FALSE;
- }
-
-#ifdef CAPABILITIES
- if (cap_set_proc(this->caps) != 0)
- {
- DBG1(DBG_DMN, "unable to drop daemon capabilities");
- return FALSE;
- }
-#endif /* CAPABILITIES */
- return TRUE;
-}
-
-/**
- * Implementation of daemon_t.keep_cap
- */
-static void keep_cap(private_daemon_t *this, u_int cap)
+METHOD(daemon_t, keep_cap, void,
+ private_daemon_t *this, u_int cap)
{
#ifdef CAPABILITIES
cap_set_flag(this->caps, CAP_EFFECTIVE, 1, &cap, CAP_SET);
@@ -256,42 +140,27 @@ static void keep_cap(private_daemon_t *this, u_int cap)
#endif /* CAPABILITIES */
}
-/**
- * lookup UID and GID
- */
-static bool lookup_uid_gid(private_daemon_t *this)
+METHOD(daemon_t, drop_capabilities, bool,
+ private_daemon_t *this)
{
-#ifdef IPSEC_USER
- {
- char buf[1024];
- struct passwd passwd, *pwp;
-
- if (getpwnam_r(IPSEC_USER, &passwd, buf, sizeof(buf), &pwp) != 0 ||
- pwp == NULL)
- {
- DBG1(DBG_DMN, "resolving user '"IPSEC_USER"' failed");
- return FALSE;
- }
- charon->uid = pwp->pw_uid;
- }
-#endif
-#ifdef IPSEC_GROUP
+#ifdef CAPABILITIES
+ if (cap_set_proc(this->caps) != 0)
{
- char buf[1024];
- struct group group, *grp;
-
- if (getgrnam_r(IPSEC_GROUP, &group, buf, sizeof(buf), &grp) != 0 ||
- grp == NULL)
- {
- DBG1(DBG_DMN, "resolving group '"IPSEC_GROUP"' failed");
- return FALSE;
- }
- charon->gid = grp->gr_gid;
+ return FALSE;
}
-#endif
+#endif /* CAPABILITIES */
return TRUE;
}
+METHOD(daemon_t, start, void,
+ private_daemon_t *this)
+{
+ /* start the engine, go multithreaded */
+ charon->processor->set_threads(charon->processor,
+ lib->settings->get_int(lib->settings, "charon.threads",
+ DEFAULT_THREADS));
+}
+
/**
* Log loaded plugins
*/
@@ -434,10 +303,8 @@ static void initialize_loggers(private_daemon_t *this, bool use_stderr,
}
}
-/**
- * Initialize the daemon
- */
-static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
+METHOD(daemon_t, initialize, bool,
+ private_daemon_t *this, bool syslog, level_t levels[])
{
/* for uncritical pseudo random numbers */
srandom(time(NULL) + getpid());
@@ -445,6 +312,7 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
/* setup bus and it's listeners first to enable log output */
this->public.bus = bus_create();
/* set up hook to log dbg message in library via charons message bus */
+ dbg_old = dbg;
dbg = dbg_bus;
initialize_loggers(this, !syslog, levels);
@@ -455,6 +323,7 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
{
DBG1(DBG_DMN, "integrity tests enabled:");
DBG1(DBG_DMN, "lib 'libstrongswan': passed file and segment integrity tests");
+ DBG1(DBG_DMN, "lib 'libcharon': passed file and segment integrity tests");
DBG1(DBG_DMN, "daemon 'charon': passed file integrity test");
}
@@ -504,55 +373,22 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
}
/**
- * Handle SIGSEGV/SIGILL signals raised by threads
- */
-static void segv_handler(int signal)
-{
- backtrace_t *backtrace;
-
- DBG1(DBG_DMN, "thread %u received %d", thread_current_id(), signal);
- backtrace = backtrace_create(2);
- backtrace->log(backtrace, stderr);
- backtrace->destroy(backtrace);
-
- DBG1(DBG_DMN, "killing ourself, received critical signal");
- abort();
-}
-
-/**
* Create the daemon.
*/
-private_daemon_t *daemon_create(void)
+private_daemon_t *daemon_create()
{
- struct sigaction action;
- private_daemon_t *this = malloc_thing(private_daemon_t);
-
- /* assign methods */
- this->public.keep_cap = (void(*)(daemon_t*, u_int cap))keep_cap;
-
- /* NULL members for clean destruction */
- this->public.socket = NULL;
- this->public.ike_sa_manager = NULL;
- this->public.traps = NULL;
- this->public.credentials = NULL;
- this->public.backends = NULL;
- this->public.sender= NULL;
- this->public.receiver = NULL;
- this->public.scheduler = NULL;
- this->public.kernel_interface = NULL;
- this->public.processor = NULL;
- this->public.controller = NULL;
- this->public.eap = NULL;
- this->public.sim = NULL;
- this->public.bus = NULL;
- this->public.file_loggers = linked_list_create();
- this->public.sys_loggers = linked_list_create();
-#ifdef ME
- this->public.connect_manager = NULL;
- this->public.mediation_manager = NULL;
-#endif /* ME */
- this->public.uid = 0;
- this->public.gid = 0;
+ private_daemon_t *this;
+
+ INIT(this,
+ .public = {
+ .keep_cap = _keep_cap,
+ .drop_capabilities = _drop_capabilities,
+ .initialize = _initialize,
+ .start = _start,
+ .file_loggers = linked_list_create(),
+ .sys_loggers = linked_list_create(),
+ },
+ );
#ifdef CAPABILITIES
this->caps = cap_init();
@@ -563,116 +399,28 @@ private_daemon_t *daemon_create(void)
}
#endif /* CAPABILITIES */
- /* add handler for SEGV and ILL,
- * INT, TERM and HUP are handled by sigwait() in run() */
- action.sa_handler = segv_handler;
- action.sa_flags = 0;
- sigemptyset(&action.sa_mask);
- sigaddset(&action.sa_mask, SIGINT);
- sigaddset(&action.sa_mask, SIGTERM);
- sigaddset(&action.sa_mask, SIGHUP);
- sigaction(SIGSEGV, &action, NULL);
- sigaction(SIGILL, &action, NULL);
- sigaction(SIGBUS, &action, NULL);
- action.sa_handler = SIG_IGN;
- sigaction(SIGPIPE, &action, NULL);
-
- pthread_sigmask(SIG_SETMASK, &action.sa_mask, NULL);
-
return this;
}
/**
- * Check/create PID file, return TRUE if already running
+ * Described in header.
*/
-static bool check_pidfile()
+void libcharon_deinit()
{
- struct stat stb;
- FILE *file;
-
- if (stat(PID_FILE, &stb) == 0)
- {
- file = fopen(PID_FILE, "r");
- if (file)
- {
- char buf[64];
- pid_t pid = 0;
-
- memset(buf, 0, sizeof(buf));
- if (fread(buf, 1, sizeof(buf), file))
- {
- pid = atoi(buf);
- }
- fclose(file);
- if (pid && kill(pid, 0) == 0)
- { /* such a process is running */
- return TRUE;
- }
- }
- DBG1(DBG_DMN, "removing pidfile '"PID_FILE"', process not running");
- unlink(PID_FILE);
- }
- /* create new pidfile */
- file = fopen(PID_FILE, "w");
- if (file)
- {
- fprintf(file, "%d\n", getpid());
- ignore_result(fchown(fileno(file), charon->uid, charon->gid));
- fclose(file);
- }
- return FALSE;
-}
-
-/**
- * print command line usage and exit
- */
-static void usage(const char *msg)
-{
- if (msg != NULL && *msg != '\0')
- {
- fprintf(stderr, "%s\n", msg);
- }
- fprintf(stderr, "Usage: charon\n"
- " [--help]\n"
- " [--version]\n"
- " [--use-syslog]\n"
- " [--debug-<type> <level>]\n"
- " <type>: log context type (dmn|mgr|ike|chd|job|cfg|knl|net|enc|lib)\n"
- " <level>: log verbosity (-1 = silent, 0 = audit, 1 = control,\n"
- " 2 = controlmore, 3 = raw, 4 = private)\n"
- "\n"
- );
- exit(msg == NULL? 0 : 1);
+ destroy((private_daemon_t*)charon);
+ charon = NULL;
}
/**
- * Main function, manages the daemon.
+ * Described in header.
*/
-int main(int argc, char *argv[])
+bool libcharon_init()
{
- bool use_syslog = FALSE;
- private_daemon_t *private_charon;
- level_t levels[DBG_MAX];
- int group;
+ private_daemon_t *this;
- /* logging for library during initialization, as we have no bus yet */
- dbg = dbg_stderr;
-
- /* initialize library */
- if (!library_init(NULL))
- {
- library_deinit();
- exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
- }
-
- if (lib->integrity &&
- !lib->integrity->check_file(lib->integrity, "charon", argv[0]))
- {
- dbg_stderr(1, "integrity check of charon failed");
- library_deinit();
- exit(SS_RC_DAEMON_INTEGRITY);
- }
+ this = daemon_create();
+ charon = &this->public;
lib->printf_hook->add_handler(lib->printf_hook, 'R',
traffic_selector_printf_hook,
@@ -682,108 +430,13 @@ int main(int argc, char *argv[])
proposal_printf_hook,
PRINTF_HOOK_ARGTYPE_POINTER,
PRINTF_HOOK_ARGTYPE_END);
- private_charon = daemon_create();
- charon = (daemon_t*)private_charon;
-
- /* use CTRL loglevel for default */
- for (group = 0; group < DBG_MAX; group++)
- {
- levels[group] = LEVEL_CTRL;
- }
-
- /* handle arguments */
- for (;;)
- {
- struct option long_opts[] = {
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'v' },
- { "use-syslog", no_argument, NULL, 'l' },
- /* TODO: handle "debug-all" */
- { "debug-dmn", required_argument, &group, DBG_DMN },
- { "debug-mgr", required_argument, &group, DBG_MGR },
- { "debug-ike", required_argument, &group, DBG_IKE },
- { "debug-chd", required_argument, &group, DBG_CHD },
- { "debug-job", required_argument, &group, DBG_JOB },
- { "debug-cfg", required_argument, &group, DBG_CFG },
- { "debug-knl", required_argument, &group, DBG_KNL },
- { "debug-net", required_argument, &group, DBG_NET },
- { "debug-enc", required_argument, &group, DBG_ENC },
- { "debug-lib", required_argument, &group, DBG_LIB },
- { 0,0,0,0 }
- };
-
- int c = getopt_long(argc, argv, "", long_opts, NULL);
- switch (c)
- {
- case EOF:
- break;
- case 'h':
- usage(NULL);
- break;
- case 'v':
- printf("Linux strongSwan %s\n", VERSION);
- exit(0);
- case 'l':
- use_syslog = TRUE;
- continue;
- case 0:
- /* option is in group */
- levels[group] = atoi(optarg);
- continue;
- default:
- usage("");
- break;
- }
- break;
- }
-
- if (!lookup_uid_gid(private_charon))
- {
- DBG1(DBG_DMN, "invalid uid/gid - aborting charon");
- destroy(private_charon);
- library_deinit();
- exit(SS_RC_INITIALIZATION_FAILED);
- }
-
- /* initialize daemon */
- if (!initialize(private_charon, use_syslog, levels))
- {
- DBG1(DBG_DMN, "initialization failed - aborting charon");
- destroy(private_charon);
- library_deinit();
- exit(SS_RC_INITIALIZATION_FAILED);
- }
-
- if (check_pidfile())
- {
- DBG1(DBG_DMN, "charon already running (\""PID_FILE"\" exists)");
- destroy(private_charon);
- library_deinit();
- exit(-1);
- }
- if (!drop_capabilities(private_charon))
+ if (lib->integrity &&
+ !lib->integrity->check(lib->integrity, "libcharon", libcharon_init))
{
- DBG1(DBG_DMN, "capability dropping failed - aborting charon");
- destroy(private_charon);
- library_deinit();
- exit(SS_RC_INITIALIZATION_FAILED);
+ dbg(1, "integrity check of libcharon failed");
+ return FALSE;
}
- /* start the engine, go multithreaded */
- charon->processor->set_threads(charon->processor,
- lib->settings->get_int(lib->settings, "charon.threads",
- DEFAULT_THREADS));
-
- /* run daemon */
- run(private_charon);
-
- /* normal termination, cleanup and exit */
- destroy(private_charon);
- unlink(PID_FILE);
-
- library_deinit();
-
- return 0;
+ return TRUE;
}
-
diff --git a/src/libcharon/daemon.h b/src/libcharon/daemon.h
index 7b2362bb8..eb97a1688 100644
--- a/src/libcharon/daemon.h
+++ b/src/libcharon/daemon.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2007 Tobias Brunner
+ * Copyright (C) 2006-2010 Tobias Brunner
* Copyright (C) 2005-2009 Martin Willi
* Copyright (C) 2006 Daniel Roethlisberger
* Copyright (C) 2005 Jan Hutter
@@ -17,52 +17,52 @@
*/
/**
- * @defgroup charon charon
+ * @defgroup libcharon libcharon
*
* @defgroup bus bus
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup listeners listeners
* @ingroup bus
*
* @defgroup config config
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup attributes attributes
* @ingroup config
*
* @defgroup control control
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup ccredentials credentials
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup sets sets
* @ingroup ccredentials
*
* @defgroup encoding encoding
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup payloads payloads
* @ingroup encoding
*
* @defgroup kernel kernel
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup network network
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup cplugins plugins
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup processing processing
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup jobs jobs
* @ingroup processing
*
* @defgroup sa sa
- * @ingroup charon
+ * @ingroup libcharon
*
* @defgroup authenticators authenticators
* @ingroup sa
@@ -73,7 +73,7 @@
* @defgroup tasks tasks
* @ingroup sa
*
- * @addtogroup charon
+ * @addtogroup libcharon
* @{
*
* IKEv2 keying daemon.
@@ -169,11 +169,6 @@ typedef struct daemon_t daemon_t;
#endif /* ME */
/**
- * Name of the daemon.
- */
-#define DAEMON_NAME "charon"
-
-/**
* Number of threads in the thread pool, if not specified in config.
*/
#define DEFAULT_THREADS 16
@@ -189,12 +184,6 @@ typedef struct daemon_t daemon_t;
#define IKEV2_NATT_PORT 4500
/**
- * PID file, in which charon stores its process id
- */
-#define PID_FILE IPSEC_PIDDIR "/charon.pid"
-
-
-/**
* Main class of daemon, contains some globals.
*/
struct daemon_t {
@@ -309,11 +298,45 @@ struct daemon_t {
* drop these.
*/
void (*keep_cap)(daemon_t *this, u_int cap);
+
+ /**
+ * Drop all capabilities of the current process, but keep those that have
+ * been set with a call to keep_cap.
+ *
+ * This should be called after the initialization of the daemon because
+ * some plugins require the process to keep additional capabilities.
+ *
+ * @return TRUE if successful, FALSE otherwise
+ */
+ bool (*drop_capabilities)(daemon_t *this);
+
+ /**
+ * Initialize the daemon.
+ */
+ bool (*initialize)(daemon_t *this, bool syslog, level_t levels[]);
+
+ /**
+ * Starts the daemon, i.e. spawns the threads of the thread pool.
+ */
+ void (*start)(daemon_t *this);
+
};
/**
- * The one and only instance of the daemon.
+ * The one and only instance of the daemon. Set between libcharon_init() and
+ * libcharon_deinit() calls.
*/
extern daemon_t *charon;
+/**
+ * Initialize libcharon and create the "charon" instance of daemon_t.
+ * @return FALSE if integrity check failed
+ */
+bool libcharon_init();
+
+/**
+ * Deinitialize libcharon and destroy the "charon" instance of daemon_t.
+ */
+void libcharon_deinit();
+
#endif /** DAEMON_H_ @}*/
diff --git a/src/libcharon/plugins/android/Makefile.am b/src/libcharon/plugins/android/Makefile.am
index a7024eaa9..5c6c3f731 100644
--- a/src/libcharon/plugins/android/Makefile.am
+++ b/src/libcharon/plugins/android/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/attr/Makefile.am b/src/libcharon/plugins/attr/Makefile.am
index 6ba220abb..917c1263d 100644
--- a/src/libcharon/plugins/attr/Makefile.am
+++ b/src/libcharon/plugins/attr/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_aka/Makefile.am b/src/libcharon/plugins/eap_aka/Makefile.am
index c7ce8d96b..b57da4c2e 100644
--- a/src/libcharon/plugins/eap_aka/Makefile.am
+++ b/src/libcharon/plugins/eap_aka/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon \
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon \
-I$(top_srcdir)/src/libsimaka
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_aka_3gpp2/Makefile.am b/src/libcharon/plugins/eap_aka_3gpp2/Makefile.am
index 6bab07c17..606a52ce6 100644
--- a/src/libcharon/plugins/eap_aka_3gpp2/Makefile.am
+++ b/src/libcharon/plugins/eap_aka_3gpp2/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_gtc/Makefile.am b/src/libcharon/plugins/eap_gtc/Makefile.am
index e87f5e899..2df288d32 100644
--- a/src/libcharon/plugins/eap_gtc/Makefile.am
+++ b/src/libcharon/plugins/eap_gtc/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_identity/Makefile.am b/src/libcharon/plugins/eap_identity/Makefile.am
index f743f3566..66efa7b2a 100644
--- a/src/libcharon/plugins/eap_identity/Makefile.am
+++ b/src/libcharon/plugins/eap_identity/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_md5/Makefile.am b/src/libcharon/plugins/eap_md5/Makefile.am
index 76b039b28..85769f06e 100644
--- a/src/libcharon/plugins/eap_md5/Makefile.am
+++ b/src/libcharon/plugins/eap_md5/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_mschapv2/Makefile.am b/src/libcharon/plugins/eap_mschapv2/Makefile.am
index 3a2b6e211..018e7134b 100644
--- a/src/libcharon/plugins/eap_mschapv2/Makefile.am
+++ b/src/libcharon/plugins/eap_mschapv2/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_radius/Makefile.am b/src/libcharon/plugins/eap_radius/Makefile.am
index 9f1405469..1ea2c4838 100644
--- a/src/libcharon/plugins/eap_radius/Makefile.am
+++ b/src/libcharon/plugins/eap_radius/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_sim/Makefile.am b/src/libcharon/plugins/eap_sim/Makefile.am
index ddadebcfe..318643334 100644
--- a/src/libcharon/plugins/eap_sim/Makefile.am
+++ b/src/libcharon/plugins/eap_sim/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon \
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon \
-I$(top_srcdir)/src/libsimaka
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_sim_file/Makefile.am b/src/libcharon/plugins/eap_sim_file/Makefile.am
index 544883003..5c5699cc6 100644
--- a/src/libcharon/plugins/eap_sim_file/Makefile.am
+++ b/src/libcharon/plugins/eap_sim_file/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic -DIPSEC_CONFDIR=\"${sysconfdir}\"
diff --git a/src/libcharon/plugins/eap_simaka_pseudonym/Makefile.am b/src/libcharon/plugins/eap_simaka_pseudonym/Makefile.am
index 1e8882826..f845f2373 100644
--- a/src/libcharon/plugins/eap_simaka_pseudonym/Makefile.am
+++ b/src/libcharon/plugins/eap_simaka_pseudonym/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/eap_simaka_reauth/Makefile.am b/src/libcharon/plugins/eap_simaka_reauth/Makefile.am
index 919678432..92d2df45f 100644
--- a/src/libcharon/plugins/eap_simaka_reauth/Makefile.am
+++ b/src/libcharon/plugins/eap_simaka_reauth/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/kernel_klips/Makefile.am b/src/libcharon/plugins/kernel_klips/Makefile.am
index 74c3caa09..b5fb6d447 100644
--- a/src/libcharon/plugins/kernel_klips/Makefile.am
+++ b/src/libcharon/plugins/kernel_klips/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/kernel_netlink/Makefile.am b/src/libcharon/plugins/kernel_netlink/Makefile.am
index eda872882..59a368a30 100644
--- a/src/libcharon/plugins/kernel_netlink/Makefile.am
+++ b/src/libcharon/plugins/kernel_netlink/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic \
-DROUTING_TABLE=${routing_table} \
diff --git a/src/libcharon/plugins/kernel_pfkey/Makefile.am b/src/libcharon/plugins/kernel_pfkey/Makefile.am
index 2c7641e5f..251f860a9 100644
--- a/src/libcharon/plugins/kernel_pfkey/Makefile.am
+++ b/src/libcharon/plugins/kernel_pfkey/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/kernel_pfroute/Makefile.am b/src/libcharon/plugins/kernel_pfroute/Makefile.am
index 05499f070..98d2a497a 100644
--- a/src/libcharon/plugins/kernel_pfroute/Makefile.am
+++ b/src/libcharon/plugins/kernel_pfroute/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/load_tester/Makefile.am b/src/libcharon/plugins/load_tester/Makefile.am
index 090b0baf6..4bcaa36db 100644
--- a/src/libcharon/plugins/load_tester/Makefile.am
+++ b/src/libcharon/plugins/load_tester/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/medcli/Makefile.am b/src/libcharon/plugins/medcli/Makefile.am
index e1e3dc53a..513f0ec5c 100644
--- a/src/libcharon/plugins/medcli/Makefile.am
+++ b/src/libcharon/plugins/medcli/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/medsrv/Makefile.am b/src/libcharon/plugins/medsrv/Makefile.am
index 9775c098c..8b65d2c96 100644
--- a/src/libcharon/plugins/medsrv/Makefile.am
+++ b/src/libcharon/plugins/medsrv/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/nm/Makefile.am b/src/libcharon/plugins/nm/Makefile.am
index a6d29dea6..5720171d0 100644
--- a/src/libcharon/plugins/nm/Makefile.am
+++ b/src/libcharon/plugins/nm/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon ${nm_CFLAGS}
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon ${nm_CFLAGS}
AM_CFLAGS = -rdynamic \
-DNM_CA_DIR=\"${nm_ca_dir}\"
diff --git a/src/libcharon/plugins/resolve/Makefile.am b/src/libcharon/plugins/resolve/Makefile.am
index 04e61c342..879370857 100644
--- a/src/libcharon/plugins/resolve/Makefile.am
+++ b/src/libcharon/plugins/resolve/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic \
-DRESOLV_CONF=\"${resolv_conf}\"
diff --git a/src/libcharon/plugins/smp/Makefile.am b/src/libcharon/plugins/smp/Makefile.am
index 4e7141900..392d49603 100644
--- a/src/libcharon/plugins/smp/Makefile.am
+++ b/src/libcharon/plugins/smp/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon ${xml_CFLAGS}
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon ${xml_CFLAGS}
AM_CFLAGS = -rdynamic -DIPSEC_PIDDIR=\"${piddir}\"
diff --git a/src/libcharon/plugins/socket_default/Makefile.am b/src/libcharon/plugins/socket_default/Makefile.am
index 6b1ee2fee..02f9289e8 100644
--- a/src/libcharon/plugins/socket_default/Makefile.am
+++ b/src/libcharon/plugins/socket_default/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/socket_dynamic/Makefile.am b/src/libcharon/plugins/socket_dynamic/Makefile.am
index 546db5c16..c898cee61 100644
--- a/src/libcharon/plugins/socket_dynamic/Makefile.am
+++ b/src/libcharon/plugins/socket_dynamic/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/socket_raw/Makefile.am b/src/libcharon/plugins/socket_raw/Makefile.am
index 896cd0c11..0d621c026 100644
--- a/src/libcharon/plugins/socket_raw/Makefile.am
+++ b/src/libcharon/plugins/socket_raw/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/sql/Makefile.am b/src/libcharon/plugins/sql/Makefile.am
index ece07f538..940235e9f 100644
--- a/src/libcharon/plugins/sql/Makefile.am
+++ b/src/libcharon/plugins/sql/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic \
-DPLUGINS=\""${libstrongswan_plugins}\""
diff --git a/src/libcharon/plugins/stroke/Makefile.am b/src/libcharon/plugins/stroke/Makefile.am
index 36e0d8280..004ca1b73 100644
--- a/src/libcharon/plugins/stroke/Makefile.am
+++ b/src/libcharon/plugins/stroke/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon -I$(top_srcdir)/src/stroke
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/stroke
AM_CFLAGS = \
-rdynamic \
diff --git a/src/libcharon/plugins/uci/Makefile.am b/src/libcharon/plugins/uci/Makefile.am
index ccaecc6bc..d6899f78c 100644
--- a/src/libcharon/plugins/uci/Makefile.am
+++ b/src/libcharon/plugins/uci/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/unit_tester/Makefile.am b/src/libcharon/plugins/unit_tester/Makefile.am
index c0307e06f..5bf97ca7e 100644
--- a/src/libcharon/plugins/unit_tester/Makefile.am
+++ b/src/libcharon/plugins/unit_tester/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic
diff --git a/src/libcharon/plugins/updown/Makefile.am b/src/libcharon/plugins/updown/Makefile.am
index 1de2946bf..e52556953 100644
--- a/src/libcharon/plugins/updown/Makefile.am
+++ b/src/libcharon/plugins/updown/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
AM_CFLAGS = -rdynamic