Init/deinit libhydra in charon and pluto.
This commit is contained in:
@@ -3,10 +3,15 @@ ipsec_PROGRAMS = charon
|
|||||||
charon_SOURCES = \
|
charon_SOURCES = \
|
||||||
charon.c
|
charon.c
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libcharon
|
INCLUDES = \
|
||||||
|
-I$(top_srcdir)/src/libstrongswan \
|
||||||
|
-I$(top_srcdir)/src/libhydra \
|
||||||
|
-I$(top_srcdir)/src/libcharon
|
||||||
|
|
||||||
AM_CFLAGS = \
|
AM_CFLAGS = \
|
||||||
-DIPSEC_DIR=\"${ipsecdir}\" \
|
-DIPSEC_DIR=\"${ipsecdir}\" \
|
||||||
-DIPSEC_PIDDIR=\"${piddir}\"
|
-DIPSEC_PIDDIR=\"${piddir}\"
|
||||||
|
|
||||||
charon_LDADD = \
|
charon_LDADD = \
|
||||||
$(top_builddir)/src/libstrongswan/libstrongswan.la \
|
$(top_builddir)/src/libstrongswan/libstrongswan.la \
|
||||||
$(top_builddir)/src/libhydra/libhydra.la \
|
$(top_builddir)/src/libhydra/libhydra.la \
|
||||||
|
|||||||
+22
-20
@@ -31,6 +31,7 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
|
||||||
|
#include <hydra.h>
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
@@ -268,7 +269,7 @@ int main(int argc, char *argv[])
|
|||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
bool use_syslog = FALSE;
|
bool use_syslog = FALSE;
|
||||||
level_t levels[DBG_MAX];
|
level_t levels[DBG_MAX];
|
||||||
int group;
|
int group, status = SS_RC_INITIALIZATION_FAILED;
|
||||||
|
|
||||||
/* logging for library during initialization, as we have no bus yet */
|
/* logging for library during initialization, as we have no bus yet */
|
||||||
dbg = dbg_stderr;
|
dbg = dbg_stderr;
|
||||||
@@ -288,12 +289,18 @@ int main(int argc, char *argv[])
|
|||||||
exit(SS_RC_DAEMON_INTEGRITY);
|
exit(SS_RC_DAEMON_INTEGRITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!libhydra_init())
|
||||||
|
{
|
||||||
|
dbg_stderr(1, "initialization failed - aborting charon");
|
||||||
|
libhydra_deinit();
|
||||||
|
library_deinit();
|
||||||
|
exit(SS_RC_INITIALIZATION_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
if (!libcharon_init())
|
if (!libcharon_init())
|
||||||
{
|
{
|
||||||
dbg_stderr(1, "initialization failed - aborting charon");
|
dbg_stderr(1, "initialization failed - aborting charon");
|
||||||
libcharon_deinit();
|
goto deinit;
|
||||||
library_deinit();
|
|
||||||
exit(SS_RC_INITIALIZATION_FAILED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use CTRL loglevel for default */
|
/* use CTRL loglevel for default */
|
||||||
@@ -351,34 +358,27 @@ int main(int argc, char *argv[])
|
|||||||
if (!lookup_uid_gid())
|
if (!lookup_uid_gid())
|
||||||
{
|
{
|
||||||
dbg_stderr(1, "invalid uid/gid - aborting charon");
|
dbg_stderr(1, "invalid uid/gid - aborting charon");
|
||||||
libcharon_deinit();
|
goto deinit;
|
||||||
library_deinit();
|
|
||||||
exit(SS_RC_INITIALIZATION_FAILED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize daemon */
|
/* initialize daemon */
|
||||||
if (!charon->initialize(charon, use_syslog, levels))
|
if (!charon->initialize(charon, use_syslog, levels))
|
||||||
{
|
{
|
||||||
DBG1(DBG_DMN, "initialization failed - aborting charon");
|
DBG1(DBG_DMN, "initialization failed - aborting charon");
|
||||||
libcharon_deinit();
|
goto deinit;
|
||||||
library_deinit();
|
|
||||||
exit(SS_RC_INITIALIZATION_FAILED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_pidfile())
|
if (check_pidfile())
|
||||||
{
|
{
|
||||||
DBG1(DBG_DMN, "charon already running (\""PID_FILE"\" exists)");
|
DBG1(DBG_DMN, "charon already running (\""PID_FILE"\" exists)");
|
||||||
libcharon_deinit();
|
status = -1;
|
||||||
library_deinit();
|
goto deinit;
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!drop_capabilities())
|
if (!drop_capabilities())
|
||||||
{
|
{
|
||||||
DBG1(DBG_DMN, "capability dropping failed - aborting charon");
|
DBG1(DBG_DMN, "capability dropping failed - aborting charon");
|
||||||
libcharon_deinit();
|
goto deinit;
|
||||||
library_deinit();
|
|
||||||
exit(SS_RC_INITIALIZATION_FAILED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add handler for SEGV and ILL,
|
/* add handler for SEGV and ILL,
|
||||||
@@ -404,11 +404,13 @@ int main(int argc, char *argv[])
|
|||||||
run();
|
run();
|
||||||
|
|
||||||
/* normal termination, cleanup and exit */
|
/* normal termination, cleanup and exit */
|
||||||
libcharon_deinit();
|
|
||||||
library_deinit();
|
|
||||||
|
|
||||||
unlink(PID_FILE);
|
unlink(PID_FILE);
|
||||||
|
status = 0;
|
||||||
|
|
||||||
return 0;
|
deinit:
|
||||||
|
libcharon_deinit();
|
||||||
|
libhydra_deinit();
|
||||||
|
library_deinit();
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ METHOD(daemon_t, initialize, bool,
|
|||||||
{
|
{
|
||||||
DBG1(DBG_DMN, "integrity tests enabled:");
|
DBG1(DBG_DMN, "integrity tests enabled:");
|
||||||
DBG1(DBG_DMN, "lib 'libstrongswan': passed file and segment integrity tests");
|
DBG1(DBG_DMN, "lib 'libstrongswan': passed file and segment integrity tests");
|
||||||
|
DBG1(DBG_DMN, "lib 'libhydra': passed file and segment integrity tests");
|
||||||
DBG1(DBG_DMN, "lib 'libcharon': 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");
|
DBG1(DBG_DMN, "daemon 'charon': passed file integrity test");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,13 +54,14 @@ rsaref/pkcs11t.h rsaref/pkcs11.h rsaref/unix.h rsaref/pkcs11f.h
|
|||||||
_pluto_adns_SOURCES = adns.c adns.h
|
_pluto_adns_SOURCES = adns.c adns.h
|
||||||
|
|
||||||
LIBSTRONGSWANDIR=$(top_builddir)/src/libstrongswan
|
LIBSTRONGSWANDIR=$(top_builddir)/src/libstrongswan
|
||||||
LIBHYDRADIR=$(top_builddir)/src/libhydra
|
|
||||||
LIBFREESWANDIR=$(top_builddir)/src/libfreeswan
|
LIBFREESWANDIR=$(top_builddir)/src/libfreeswan
|
||||||
|
LIBHYDRADIR=$(top_builddir)/src/libhydra
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I${linux_headers} \
|
-I${linux_headers} \
|
||||||
-I$(top_srcdir)/src/libstrongswan \
|
-I$(top_srcdir)/src/libstrongswan \
|
||||||
-I$(top_srcdir)/src/libfreeswan \
|
-I$(top_srcdir)/src/libfreeswan \
|
||||||
|
-I$(top_srcdir)/src/libhydra \
|
||||||
-I$(top_srcdir)/src/whack
|
-I$(top_srcdir)/src/whack
|
||||||
|
|
||||||
AM_CFLAGS = \
|
AM_CFLAGS = \
|
||||||
@@ -75,8 +76,8 @@ AM_CFLAGS = \
|
|||||||
|
|
||||||
pluto_LDADD = \
|
pluto_LDADD = \
|
||||||
$(LIBSTRONGSWANDIR)/libstrongswan.la \
|
$(LIBSTRONGSWANDIR)/libstrongswan.la \
|
||||||
$(LIBHYDRADIR)/libhydra.la \
|
|
||||||
$(LIBFREESWANDIR)/libfreeswan.a \
|
$(LIBFREESWANDIR)/libfreeswan.a \
|
||||||
|
$(LIBHYDRADIR)/libhydra.la \
|
||||||
-lresolv $(PTHREADLIB) $(DLLIB)
|
-lresolv $(PTHREADLIB) $(DLLIB)
|
||||||
|
|
||||||
_pluto_adns_LDADD = \
|
_pluto_adns_LDADD = \
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <freeswan.h>
|
#include <freeswan.h>
|
||||||
|
|
||||||
|
#include <hydra.h>
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <utils/enumerator.h>
|
#include <utils/enumerator.h>
|
||||||
@@ -273,6 +274,12 @@ int main(int argc, char **argv)
|
|||||||
library_deinit();
|
library_deinit();
|
||||||
exit(SS_RC_DAEMON_INTEGRITY);
|
exit(SS_RC_DAEMON_INTEGRITY);
|
||||||
}
|
}
|
||||||
|
if (!libhydra_init())
|
||||||
|
{
|
||||||
|
libhydra_deinit();
|
||||||
|
library_deinit();
|
||||||
|
exit(SS_RC_INITIALIZATION_FAILED);
|
||||||
|
}
|
||||||
options = options_create();
|
options = options_create();
|
||||||
|
|
||||||
/* handle arguments */
|
/* handle arguments */
|
||||||
@@ -648,6 +655,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
plog("integrity tests enabled:");
|
plog("integrity tests enabled:");
|
||||||
plog("lib 'libstrongswan': passed file and segment integrity tests");
|
plog("lib 'libstrongswan': passed file and segment integrity tests");
|
||||||
|
plog("lib 'libhydra': passed file and segment integrity tests");
|
||||||
plog("daemon 'pluto': passed file integrity test");
|
plog("daemon 'pluto': passed file integrity test");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,6 +778,7 @@ void exit_pluto(int status)
|
|||||||
free_builder();
|
free_builder();
|
||||||
delete_lock();
|
delete_lock();
|
||||||
options->destroy(options);
|
options->destroy(options);
|
||||||
|
libhydra_deinit();
|
||||||
library_deinit();
|
library_deinit();
|
||||||
close_log();
|
close_log();
|
||||||
exit(status);
|
exit(status);
|
||||||
|
|||||||
Reference in New Issue
Block a user