merging kernel_klips plugin back into trunk

This commit is contained in:
Tobias Brunner
2008-11-11 09:22:00 +00:00
parent c117f24e61
commit ea625fabf9
30 changed files with 3774 additions and 262 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
ipsec_PROGRAMS = starter
starter_SOURCES = y.tab.c netkey.c y.tab.h parser.h args.h netkey.h \
starterwhack.c starterwhack.h starterstroke.c invokepluto.c confread.c \
starterstroke.h interfaces.c invokepluto.h confread.h interfaces.h args.c \
starterstroke.h interfaces.c invokepluto.h confread.h interfaces.h args.c \
keywords.c files.h keywords.h cmp.c starter.c cmp.h exec.c invokecharon.c \
exec.h invokecharon.h lex.yy.c loglite.c
exec.h invokecharon.h lex.yy.c loglite.c klips.c klips.h
INCLUDES = -I$(top_srcdir)/src/libfreeswan -I$(top_srcdir)/src/pluto -I$(top_srcdir)/src/whack -I$(top_srcdir)/src/stroke
AM_CFLAGS = -DIPSEC_DIR=\"${ipsecdir}\" -DIPSEC_CONFDIR=\"${confdir}\" -DIPSEC_PIDDIR=\"${piddir}\" -DIPSEC_EAPDIR=\"${eapdir}\" -DDEBUG
+2 -1
View File
@@ -19,7 +19,8 @@
#define STARTER_PID_FILE IPSEC_PIDDIR "/starter.pid"
#define PROC_NETKEY "/proc/net/pfkey"
#define PROC_NETKEY "/proc/net/pfkey"
#define PROC_KLIPS "/proc/net/pf_key"
#define PROC_MODULES "/proc/modules"
#define CONFIG_FILE IPSEC_CONFDIR "/ipsec.conf"
+82
View File
@@ -0,0 +1,82 @@
/* strongSwan KLIPS starter
* Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* RCSID $Id$
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <freeswan.h>
#include "../pluto/constants.h"
#include "../pluto/defs.h"
#include "../pluto/log.h"
#include "files.h"
bool
starter_klips_init(void)
{
struct stat stb;
if (stat(PROC_KLIPS, &stb) != 0)
{
/* ipsec module makes the pf_key proc interface visible */
if (stat(PROC_MODULES, &stb) == 0)
{
system("modprobe -qv ipsec");
}
/* now test again */
if (stat(PROC_KLIPS, &stb) != 0)
{
DBG(DBG_CONTROL,
DBG_log("kernel appears to lack the KLIPS IPsec stack")
)
return FALSE;
}
}
/* load crypto algorithm modules */
system("modprobe -qv ipsec_aes");
system("modprobe -qv ipsec_blowfish");
system("modprobe -qv ipsec_sha2");
DBG(DBG_CONTROL,
DBG_log("Found KLIPS IPsec stack")
)
return TRUE;
}
void
starter_klips_cleanup(void)
{
if (system("type eroute > /dev/null 2>&1") == 0)
{
system("spi --clear");
system("eroute --clear");
}
else if (system("type setkey > /dev/null 2>&1") == 0)
{
system("setkey -F");
system("setkey -FP");
}
else
{
plog("WARNING: cannot flush IPsec state/policy database");
}
}
+24
View File
@@ -0,0 +1,24 @@
/* strongSwan KLIPS initialization and cleanup
* Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* RCSID $Id$
*/
#ifndef _STARTER_KLIPS_H_
#define _STARTER_KLIPS_H_
extern bool starter_klips_init (void);
extern void starter_klips_cleanup (void);
#endif /* _STARTER_KLIPS_H_ */
+6 -1
View File
@@ -42,6 +42,7 @@
#include "invokepluto.h"
#include "invokecharon.h"
#include "netkey.h"
#include "klips.h"
#include "cmp.h"
#include "interfaces.h"
@@ -324,7 +325,11 @@ int main (int argc, char **argv)
if (!starter_netkey_init())
{
plog("no netkey IPSec stack detected");
exit(LSB_RC_FAILURE);
if (!starter_klips_init())
{
plog("no KLIPS IPSec stack detected");
exit(LSB_RC_FAILURE);
}
}
last_reload = time(NULL);