manager: Remove legacy PoC manager web application
This has not been developed for years and as far as web applications go it has some serious (security) issues. So just remove it.
@@ -20,7 +20,6 @@ options = \
|
|||||||
options/imcv.opt \
|
options/imcv.opt \
|
||||||
options/imv_policy_manager.opt \
|
options/imv_policy_manager.opt \
|
||||||
options/iptfs.opt \
|
options/iptfs.opt \
|
||||||
options/manager.opt \
|
|
||||||
options/medsrv.opt \
|
options/medsrv.opt \
|
||||||
options/pki.opt \
|
options/pki.opt \
|
||||||
options/pool.opt \
|
options/pool.opt \
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
manager.database =
|
|
||||||
Credential database URI for manager. If it contains a password, make
|
|
||||||
sure to adjust the permissions of the config file accordingly.
|
|
||||||
|
|
||||||
manager.debug = no
|
|
||||||
Enable debugging in manager.
|
|
||||||
|
|
||||||
manager.load =
|
|
||||||
Plugins to load in manager.
|
|
||||||
|
|
||||||
manager.socket =
|
|
||||||
FastCGI socket of manager, to run it statically.
|
|
||||||
|
|
||||||
manager.threads = 10
|
|
||||||
Threads to use for request handling.
|
|
||||||
|
|
||||||
manager.timeout = 15m
|
|
||||||
Session timeout for manager.
|
|
||||||
@@ -291,7 +291,6 @@ ARG_ENABL_SET([conftest], [enforce Suite B conformance test framework.])
|
|||||||
ARG_ENABL_SET([fast], [enable libfast (FastCGI Application Server w/ templates.])
|
ARG_ENABL_SET([fast], [enable libfast (FastCGI Application Server w/ templates.])
|
||||||
ARG_ENABL_SET([fuzzing], [enable fuzzing scripts (found in directory fuzz).])
|
ARG_ENABL_SET([fuzzing], [enable fuzzing scripts (found in directory fuzz).])
|
||||||
ARG_ENABL_SET([libipsec], [enable user space IPsec implementation.])
|
ARG_ENABL_SET([libipsec], [enable user space IPsec implementation.])
|
||||||
ARG_ENABL_SET([manager], [enable web management console (proof of concept).])
|
|
||||||
ARG_ENABL_SET([medcli], [enable mediation client configuration database plugin.])
|
ARG_ENABL_SET([medcli], [enable mediation client configuration database plugin.])
|
||||||
ARG_ENABL_SET([medsrv], [enable mediation server web frontend and daemon plugin.])
|
ARG_ENABL_SET([medsrv], [enable mediation server web frontend and daemon plugin.])
|
||||||
ARG_ENABL_SET([nm], [enable NetworkManager backend.])
|
ARG_ENABL_SET([nm], [enable NetworkManager backend.])
|
||||||
@@ -475,10 +474,6 @@ if test x$smp = xtrue -o x$tnccs_11 = xtrue -o x$tnc_ifmap = xtrue; then
|
|||||||
xml=true
|
xml=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$manager = xtrue; then
|
|
||||||
fast=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test x$medsrv = xtrue; then
|
if test x$medsrv = xtrue; then
|
||||||
mediation=true
|
mediation=true
|
||||||
fast=true
|
fast=true
|
||||||
@@ -1534,7 +1529,6 @@ pool_plugins=
|
|||||||
attest_plugins=
|
attest_plugins=
|
||||||
pki_plugins=
|
pki_plugins=
|
||||||
scripts_plugins=
|
scripts_plugins=
|
||||||
manager_plugins=
|
|
||||||
medsrv_plugins=
|
medsrv_plugins=
|
||||||
nm_plugins=
|
nm_plugins=
|
||||||
cmd_plugins=
|
cmd_plugins=
|
||||||
@@ -1562,19 +1556,19 @@ ADD_PLUGIN([blowfish], [s charon swanctl pki scripts nm cmd])
|
|||||||
ADD_PLUGIN([rc2], [s charon swanctl pki scripts nm cmd])
|
ADD_PLUGIN([rc2], [s charon swanctl pki scripts nm cmd])
|
||||||
ADD_PLUGIN([sha2], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fc])
|
ADD_PLUGIN([sha2], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fc])
|
||||||
ADD_PLUGIN([sha3], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fc])
|
ADD_PLUGIN([sha3], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fc])
|
||||||
ADD_PLUGIN([sha1], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen fc])
|
ADD_PLUGIN([sha1], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fc])
|
||||||
ADD_PLUGIN([md4], [s charon swanctl pki nm cmd])
|
ADD_PLUGIN([md4], [s charon swanctl pki nm cmd])
|
||||||
ADD_PLUGIN([md5], [s charon swanctl pki scripts attest nm cmd aikgen])
|
ADD_PLUGIN([md5], [s charon swanctl pki scripts attest nm cmd aikgen])
|
||||||
ADD_PLUGIN([mgf1], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fc])
|
ADD_PLUGIN([mgf1], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fc])
|
||||||
ADD_PLUGIN([rdrand], [s charon swanctl pki scripts medsrv attest nm cmd aikgen])
|
ADD_PLUGIN([rdrand], [s charon swanctl pki scripts medsrv attest nm cmd aikgen])
|
||||||
ADD_PLUGIN([random], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen])
|
ADD_PLUGIN([random], [s charon swanctl pki scripts medsrv attest nm cmd aikgen])
|
||||||
ADD_PLUGIN([nonce], [s charon nm cmd aikgen])
|
ADD_PLUGIN([nonce], [s charon nm cmd aikgen])
|
||||||
ADD_PLUGIN([x509], [s charon swanctl pki scripts attest nm cmd aikgen fd fc])
|
ADD_PLUGIN([x509], [s charon swanctl pki scripts attest nm cmd aikgen fd fc])
|
||||||
ADD_PLUGIN([revocation], [s charon pki nm cmd])
|
ADD_PLUGIN([revocation], [s charon pki nm cmd])
|
||||||
ADD_PLUGIN([constraints], [s charon pki nm cmd])
|
ADD_PLUGIN([constraints], [s charon pki nm cmd])
|
||||||
ADD_PLUGIN([acert], [s charon])
|
ADD_PLUGIN([acert], [s charon])
|
||||||
ADD_PLUGIN([pubkey], [s charon swanctl pki cmd aikgen])
|
ADD_PLUGIN([pubkey], [s charon swanctl pki cmd aikgen])
|
||||||
ADD_PLUGIN([pkcs1], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen fd fc])
|
ADD_PLUGIN([pkcs1], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fd fc])
|
||||||
ADD_PLUGIN([pkcs7], [s charon swanctl pki scripts nm cmd])
|
ADD_PLUGIN([pkcs7], [s charon swanctl pki scripts nm cmd])
|
||||||
ADD_PLUGIN([pkcs12], [s charon swanctl pki scripts cmd])
|
ADD_PLUGIN([pkcs12], [s charon swanctl pki scripts cmd])
|
||||||
ADD_PLUGIN([pgp], [s charon])
|
ADD_PLUGIN([pgp], [s charon])
|
||||||
@@ -1582,16 +1576,16 @@ ADD_PLUGIN([dnskey], [s charon swanctl pki])
|
|||||||
ADD_PLUGIN([sshkey], [s charon swanctl pki nm cmd])
|
ADD_PLUGIN([sshkey], [s charon swanctl pki nm cmd])
|
||||||
ADD_PLUGIN([dnscert], [c charon])
|
ADD_PLUGIN([dnscert], [c charon])
|
||||||
ADD_PLUGIN([ipseckey], [c charon])
|
ADD_PLUGIN([ipseckey], [c charon])
|
||||||
ADD_PLUGIN([pem], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen fd fc])
|
ADD_PLUGIN([pem], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fd fc])
|
||||||
ADD_PLUGIN([padlock], [s charon])
|
ADD_PLUGIN([padlock], [s charon])
|
||||||
ADD_PLUGIN([openssl], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen fd])
|
ADD_PLUGIN([openssl], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fd])
|
||||||
ADD_PLUGIN([wolfssl], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen])
|
ADD_PLUGIN([wolfssl], [s charon swanctl pki scripts medsrv attest nm cmd aikgen])
|
||||||
ADD_PLUGIN([gcrypt], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen])
|
ADD_PLUGIN([gcrypt], [s charon swanctl pki scripts medsrv attest nm cmd aikgen])
|
||||||
ADD_PLUGIN([botan], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen])
|
ADD_PLUGIN([botan], [s charon swanctl pki scripts medsrv attest nm cmd aikgen])
|
||||||
ADD_PLUGIN([pkcs8], [s charon swanctl pki scripts manager medsrv attest nm cmd])
|
ADD_PLUGIN([pkcs8], [s charon swanctl pki scripts medsrv attest nm cmd])
|
||||||
ADD_PLUGIN([af-alg], [s charon swanctl pki scripts medsrv attest nm cmd aikgen])
|
ADD_PLUGIN([af-alg], [s charon swanctl pki scripts medsrv attest nm cmd aikgen])
|
||||||
ADD_PLUGIN([fips-prf], [s charon nm cmd])
|
ADD_PLUGIN([fips-prf], [s charon nm cmd])
|
||||||
ADD_PLUGIN([gmp], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen fc])
|
ADD_PLUGIN([gmp], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fc])
|
||||||
ADD_PLUGIN([curve25519], [s charon swanctl pki scripts nm cmd])
|
ADD_PLUGIN([curve25519], [s charon swanctl pki scripts nm cmd])
|
||||||
ADD_PLUGIN([agent], [s charon nm cmd])
|
ADD_PLUGIN([agent], [s charon nm cmd])
|
||||||
ADD_PLUGIN([keychain], [s charon cmd])
|
ADD_PLUGIN([keychain], [s charon cmd])
|
||||||
@@ -1609,8 +1603,8 @@ ADD_PLUGIN([curl], [s charon pki scripts nm cmd])
|
|||||||
ADD_PLUGIN([files], [s charon pki scripts nm cmd])
|
ADD_PLUGIN([files], [s charon pki scripts nm cmd])
|
||||||
ADD_PLUGIN([winhttp], [s charon pki scripts])
|
ADD_PLUGIN([winhttp], [s charon pki scripts])
|
||||||
ADD_PLUGIN([soup], [s charon pki scripts nm cmd])
|
ADD_PLUGIN([soup], [s charon pki scripts nm cmd])
|
||||||
ADD_PLUGIN([mysql], [s charon pki pool manager medsrv attest])
|
ADD_PLUGIN([mysql], [s charon pki pool medsrv attest])
|
||||||
ADD_PLUGIN([sqlite], [s charon pki pool manager medsrv attest])
|
ADD_PLUGIN([sqlite], [s charon pki pool medsrv attest])
|
||||||
ADD_PLUGIN([openxpki], [s pki])
|
ADD_PLUGIN([openxpki], [s pki])
|
||||||
ADD_PLUGIN([attr], [c charon])
|
ADD_PLUGIN([attr], [c charon])
|
||||||
ADD_PLUGIN([attr-sql], [c charon])
|
ADD_PLUGIN([attr-sql], [c charon])
|
||||||
@@ -1695,7 +1689,6 @@ AC_SUBST(pool_plugins)
|
|||||||
AC_SUBST(attest_plugins)
|
AC_SUBST(attest_plugins)
|
||||||
AC_SUBST(pki_plugins)
|
AC_SUBST(pki_plugins)
|
||||||
AC_SUBST(scripts_plugins)
|
AC_SUBST(scripts_plugins)
|
||||||
AC_SUBST(manager_plugins)
|
|
||||||
AC_SUBST(medsrv_plugins)
|
AC_SUBST(medsrv_plugins)
|
||||||
AC_SUBST(nm_plugins)
|
AC_SUBST(nm_plugins)
|
||||||
AC_SUBST(cmd_plugins)
|
AC_SUBST(cmd_plugins)
|
||||||
@@ -1874,7 +1867,6 @@ AM_CONDITIONAL(USE_PF_HANDLER, test x$dhcp = xtrue -o x$farp = xtrue)
|
|||||||
AM_CONDITIONAL(USE_LEAK_DETECTIVE, test x$leak_detective = xtrue)
|
AM_CONDITIONAL(USE_LEAK_DETECTIVE, test x$leak_detective = xtrue)
|
||||||
AM_CONDITIONAL(USE_LOCK_PROFILER, test x$lock_profiler = xtrue)
|
AM_CONDITIONAL(USE_LOCK_PROFILER, test x$lock_profiler = xtrue)
|
||||||
AM_CONDITIONAL(USE_FAST, test x$fast = xtrue)
|
AM_CONDITIONAL(USE_FAST, test x$fast = xtrue)
|
||||||
AM_CONDITIONAL(USE_MANAGER, test x$manager = xtrue)
|
|
||||||
AM_CONDITIONAL(USE_ME, test x$mediation = xtrue)
|
AM_CONDITIONAL(USE_ME, test x$mediation = xtrue)
|
||||||
AM_CONDITIONAL(USE_INTEGRITY_TEST, test x$integrity_test = xtrue)
|
AM_CONDITIONAL(USE_INTEGRITY_TEST, test x$integrity_test = xtrue)
|
||||||
AM_CONDITIONAL(USE_LOAD_WARNING, test x$load_warning = xtrue)
|
AM_CONDITIONAL(USE_LOAD_WARNING, test x$load_warning = xtrue)
|
||||||
@@ -1986,7 +1978,6 @@ AM_COND_IF([USE_IMCV], [strongswan_options=${strongswan_options}" imcv imv_polic
|
|||||||
AM_COND_IF([USE_IMC_SWIMA], [strongswan_options=${strongswan_options}" sw-collector"])
|
AM_COND_IF([USE_IMC_SWIMA], [strongswan_options=${strongswan_options}" sw-collector"])
|
||||||
AM_COND_IF([USE_IMV_SWIMA], [strongswan_options=${strongswan_options}" sec-updater"])
|
AM_COND_IF([USE_IMV_SWIMA], [strongswan_options=${strongswan_options}" sec-updater"])
|
||||||
AM_COND_IF([USE_LIBTNCCS], [strongswan_options=${strongswan_options}" tnc"])
|
AM_COND_IF([USE_LIBTNCCS], [strongswan_options=${strongswan_options}" tnc"])
|
||||||
AM_COND_IF([USE_MANAGER], [strongswan_options=${strongswan_options}" manager"])
|
|
||||||
AM_COND_IF([USE_MEDSRV], [strongswan_options=${strongswan_options}" medsrv"])
|
AM_COND_IF([USE_MEDSRV], [strongswan_options=${strongswan_options}" medsrv"])
|
||||||
AM_COND_IF([USE_CMD], [strongswan_options=${strongswan_options}" charon-cmd"])
|
AM_COND_IF([USE_CMD], [strongswan_options=${strongswan_options}" charon-cmd"])
|
||||||
AM_COND_IF([USE_NM], [strongswan_options=${strongswan_options}" charon-nm"])
|
AM_COND_IF([USE_NM], [strongswan_options=${strongswan_options}" charon-nm"])
|
||||||
@@ -2196,7 +2187,6 @@ AC_CONFIG_FILES([
|
|||||||
src/pki/man/Makefile
|
src/pki/man/Makefile
|
||||||
src/pool/Makefile
|
src/pool/Makefile
|
||||||
src/libfast/Makefile
|
src/libfast/Makefile
|
||||||
src/manager/Makefile
|
|
||||||
src/medsrv/Makefile
|
src/medsrv/Makefile
|
||||||
src/checksum/Makefile
|
src/checksum/Makefile
|
||||||
src/conftest/Makefile
|
src/conftest/Makefile
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ all|alpine|codeql|coverage|sonarcloud|no-dbg|no-testable-ke)
|
|||||||
# no TrouSerS either
|
# no TrouSerS either
|
||||||
CONFIG="$CONFIG --disable-tss-trousers --disable-aikgen"
|
CONFIG="$CONFIG --disable-tss-trousers --disable-aikgen"
|
||||||
# and no Clearsilver
|
# and no Clearsilver
|
||||||
CONFIG="$CONFIG --disable-fast --disable-manager --disable-medsrv"
|
CONFIG="$CONFIG --disable-fast --disable-medsrv"
|
||||||
fi
|
fi
|
||||||
if test "$1" = "build-deps"; then
|
if test "$1" = "build-deps"; then
|
||||||
build_botan
|
build_botan
|
||||||
|
|||||||
@@ -91,10 +91,6 @@ if USE_FAST
|
|||||||
SUBDIRS += libfast
|
SUBDIRS += libfast
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if USE_MANAGER
|
|
||||||
SUBDIRS += manager
|
|
||||||
endif
|
|
||||||
|
|
||||||
if USE_MEDSRV
|
if USE_MEDSRV
|
||||||
SUBDIRS += medsrv
|
SUBDIRS += medsrv
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
manager.fcgi
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
managerdir = ${ipsecdir}/manager
|
|
||||||
|
|
||||||
manager_PROGRAMS = manager.fcgi
|
|
||||||
|
|
||||||
manager_fcgi_SOURCES = \
|
|
||||||
main.c manager.c manager.h gateway.h gateway.c storage.h storage.c xml.h xml.c \
|
|
||||||
controller/auth_controller.c controller/auth_controller.h \
|
|
||||||
controller/ikesa_controller.c controller/ikesa_controller.h \
|
|
||||||
controller/control_controller.c controller/control_controller.h \
|
|
||||||
controller/config_controller.c controller/config_controller.h \
|
|
||||||
controller/gateway_controller.c controller/gateway_controller.h
|
|
||||||
|
|
||||||
manager_fcgi_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(top_builddir)/src/libfast/libfast.la ${xml_LIBS}
|
|
||||||
main.o : $(top_builddir)/config.status
|
|
||||||
|
|
||||||
AM_CPPFLAGS = \
|
|
||||||
-I$(top_srcdir)/src/libstrongswan \
|
|
||||||
-I$(top_srcdir)/src/libfast \
|
|
||||||
-DIPSECDIR=\"${ipsecdir}\" \
|
|
||||||
-DIPSEC_PIDDIR=\"${piddir}\" \
|
|
||||||
-DPLUGINS=\""${manager_plugins}\""
|
|
||||||
|
|
||||||
AM_CFLAGS = \
|
|
||||||
${xml_CFLAGS} \
|
|
||||||
$(PLUGIN_CFLAGS)
|
|
||||||
|
|
||||||
# Don't forget to add templates to EXTRA_DIST !!! How to automate?
|
|
||||||
manager_templatesdir = ${managerdir}/templates
|
|
||||||
manager_templates_DATA = templates/header.cs templates/footer.cs templates/error.cs
|
|
||||||
|
|
||||||
manager_templates_authdir = ${manager_templatesdir}/auth
|
|
||||||
manager_templates_auth_DATA = templates/auth/login.cs
|
|
||||||
|
|
||||||
manager_templates_gatewaydir = ${manager_templatesdir}/gateway
|
|
||||||
manager_templates_gateway_DATA = templates/gateway/list.cs
|
|
||||||
|
|
||||||
manager_templates_ikesadir = ${manager_templatesdir}/ikesa
|
|
||||||
manager_templates_ikesa_DATA = templates/ikesa/list.cs
|
|
||||||
|
|
||||||
manager_templates_controldir = ${manager_templatesdir}/control
|
|
||||||
manager_templates_control_DATA = templates/control/result.cs
|
|
||||||
|
|
||||||
manager_templates_configdir = ${manager_templatesdir}/config
|
|
||||||
manager_templates_config_DATA = templates/config/list.cs
|
|
||||||
|
|
||||||
manager_templates_staticdir = ${manager_templatesdir}/static
|
|
||||||
manager_templates_static_DATA = templates/static/style.css templates/static/script.js templates/static/jquery.js \
|
|
||||||
templates/static/pipe.png templates/static/pipe-good.png templates/static/pipe-bad.png \
|
|
||||||
templates/static/pipe-thin.png templates/static/pipe-thin-left.png templates/static/pipe-thin-right.png \
|
|
||||||
templates/static/pipe-thin-green.png templates/static/pipe-thin-left-green.png templates/static/pipe-thin-right-green.png \
|
|
||||||
templates/static/gateway-left.png templates/static/client-left.png templates/static/strongswan.png \
|
|
||||||
templates/static/router.png templates/static/gateway-right.png templates/static/client-right.png \
|
|
||||||
templates/static/close.png templates/static/initiate.png
|
|
||||||
|
|
||||||
EXTRA_DIST = templates/header.cs templates/footer.cs templates/error.cs \
|
|
||||||
templates/auth/login.cs templates/gateway/list.cs templates/ikesa/list.cs \
|
|
||||||
templates/config/list.cs templates/control/result.cs \
|
|
||||||
templates/static/style.css templates/static/script.js templates/static/jquery.js \
|
|
||||||
templates/static/pipe.png templates/static/pipe-good.png templates/static/pipe-bad.png \
|
|
||||||
templates/static/pipe-thin.png templates/static/pipe-thin-left.png templates/static/pipe-thin-right.png \
|
|
||||||
templates/static/pipe-thin-green.png templates/static/pipe-thin-left-green.png templates/static/pipe-thin-right-green.png \
|
|
||||||
templates/static/gateway-left.png templates/static/client-left.png templates/static/strongswan.png \
|
|
||||||
templates/static/router.png templates/static/gateway-right.png templates/static/client-right.png \
|
|
||||||
templates/static/close.png templates/static/initiate.png
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "auth_controller.h"
|
|
||||||
#include "../manager.h"
|
|
||||||
|
|
||||||
#include <library.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct private_auth_controller_t private_auth_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of the task manager
|
|
||||||
*/
|
|
||||||
struct private_auth_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
auth_controller_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* manager instance
|
|
||||||
*/
|
|
||||||
manager_t *manager;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void login(private_auth_controller_t *this, fast_request_t *request)
|
|
||||||
{
|
|
||||||
request->set(request, "action", "check");
|
|
||||||
request->set(request, "title", "Login");
|
|
||||||
request->render(request, "templates/auth/login.cs");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void check(private_auth_controller_t *this, fast_request_t *request)
|
|
||||||
{
|
|
||||||
char *username, *password;
|
|
||||||
|
|
||||||
username = request->get_query_data(request, "username");
|
|
||||||
password = request->get_query_data(request, "password");
|
|
||||||
if (username && password &&
|
|
||||||
this->manager->login(this->manager, username, password))
|
|
||||||
{
|
|
||||||
request->redirect(request, "ikesa/list");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
request->redirect(request, "auth/login");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void logout(private_auth_controller_t *this, fast_request_t *request)
|
|
||||||
{
|
|
||||||
this->manager->logout(this->manager);
|
|
||||||
request->redirect(request, "auth/login");
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, get_name, char*,
|
|
||||||
private_auth_controller_t *this)
|
|
||||||
{
|
|
||||||
return "auth";
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, handle, void,
|
|
||||||
private_auth_controller_t *this, fast_request_t *request, char *action,
|
|
||||||
char *p2, char *p3, char *p4, char *p5)
|
|
||||||
{
|
|
||||||
if (action)
|
|
||||||
{
|
|
||||||
if (streq(action, "login"))
|
|
||||||
{
|
|
||||||
return login(this, request);
|
|
||||||
}
|
|
||||||
else if (streq(action, "check"))
|
|
||||||
{
|
|
||||||
return check(this, request);
|
|
||||||
}
|
|
||||||
else if (streq(action, "logout"))
|
|
||||||
{
|
|
||||||
return logout(this, request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request->redirect(request, "auth/login");
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, destroy, void,
|
|
||||||
private_auth_controller_t *this)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see header file
|
|
||||||
*/
|
|
||||||
fast_controller_t *auth_controller_create(fast_context_t *context, void *param)
|
|
||||||
{
|
|
||||||
private_auth_controller_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.controller = {
|
|
||||||
.get_name = _get_name,
|
|
||||||
.handle = _handle,
|
|
||||||
.destroy = _destroy,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
.manager = (manager_t*)context,
|
|
||||||
);
|
|
||||||
|
|
||||||
return &this->public.controller;
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup auth_controller auth_controller
|
|
||||||
* @{ @ingroup manager_controller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AUTH_CONTROLLER_H_
|
|
||||||
#define AUTH_CONTROLLER_H_
|
|
||||||
|
|
||||||
#include <fast_controller.h>
|
|
||||||
|
|
||||||
typedef struct auth_controller_t auth_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Authentication controller.
|
|
||||||
*/
|
|
||||||
struct auth_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements controller_t interface.
|
|
||||||
*/
|
|
||||||
fast_controller_t controller;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a auth_controller controller instance.
|
|
||||||
*/
|
|
||||||
fast_controller_t *auth_controller_create(fast_context_t *context, void *param);
|
|
||||||
|
|
||||||
#endif /** AUTH_CONTROLLER_H_ @}*/
|
|
||||||
@@ -1,207 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config_controller.h"
|
|
||||||
#include "../manager.h"
|
|
||||||
#include "../gateway.h"
|
|
||||||
|
|
||||||
#include <xml.h>
|
|
||||||
|
|
||||||
#include <library.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct private_config_controller_t private_config_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of the task manager
|
|
||||||
*/
|
|
||||||
struct private_config_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
config_controller_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* manager instance
|
|
||||||
*/
|
|
||||||
manager_t *manager;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* read XML of a peerconfig element and fill template
|
|
||||||
*/
|
|
||||||
static void process_peerconfig(private_config_controller_t *this,
|
|
||||||
enumerator_t *e, fast_request_t *r)
|
|
||||||
{
|
|
||||||
xml_t *xml;
|
|
||||||
enumerator_t *e1, *e2, *e3;
|
|
||||||
char *name, *value, *config = "", *child = "", *section = "";
|
|
||||||
|
|
||||||
while (e->enumerate(e, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "name"))
|
|
||||||
{
|
|
||||||
config = value;
|
|
||||||
}
|
|
||||||
else if (streq(name, "ikeconfig"))
|
|
||||||
{
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "local") || streq(name, "remote"))
|
|
||||||
{
|
|
||||||
if (streq(value, "0.0.0.0") || streq(value, "::"))
|
|
||||||
{
|
|
||||||
value = "%any";
|
|
||||||
}
|
|
||||||
r->setf(r, "peercfgs.%s.ikecfg.%s=%s", config, name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
}
|
|
||||||
else if (streq(name, "childconfiglist"))
|
|
||||||
{
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "childconfig"))
|
|
||||||
{
|
|
||||||
int num = 0;
|
|
||||||
|
|
||||||
e2 = xml->children(xml);
|
|
||||||
while (e2->enumerate(e2, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "name"))
|
|
||||||
{
|
|
||||||
child = value;
|
|
||||||
}
|
|
||||||
else if (streq(name, "local") || streq(name, "remote"))
|
|
||||||
{
|
|
||||||
section = name;
|
|
||||||
e3 = xml->children(xml);
|
|
||||||
while (e3->enumerate(e3, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "network"))
|
|
||||||
{
|
|
||||||
r->setf(r, "peercfgs.%s.childcfgs.%s.%s.networks.%d=%s",
|
|
||||||
config, child, section, ++num, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e3->destroy(e3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e2->destroy(e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r->setf(r, "peercfgs.%s.%s=%s", config, name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void list(private_config_controller_t *this, fast_request_t *r)
|
|
||||||
{
|
|
||||||
gateway_t *gateway;
|
|
||||||
xml_t *xml;
|
|
||||||
enumerator_t *e1, *e2;
|
|
||||||
char *name, *value;
|
|
||||||
|
|
||||||
gateway = this->manager->select_gateway(this->manager, 0);
|
|
||||||
e1 = gateway->query_configlist(gateway);
|
|
||||||
if (e1 == NULL)
|
|
||||||
{
|
|
||||||
r->set(r, "title", "Error");
|
|
||||||
r->set(r, "error", "querying the gateway failed");
|
|
||||||
r->render(r, "templates/error.cs");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r->set(r, "title", "Configuration overview");
|
|
||||||
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "peerconfig"))
|
|
||||||
{
|
|
||||||
e2 = xml->children(xml);
|
|
||||||
process_peerconfig(this, e2, r);
|
|
||||||
e2->destroy(e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
|
|
||||||
r->render(r, "templates/config/list.cs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, get_name, char*,
|
|
||||||
private_config_controller_t *this)
|
|
||||||
{
|
|
||||||
return "config";
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, handle, void,
|
|
||||||
private_config_controller_t *this, fast_request_t *request, char *action,
|
|
||||||
char *p2, char *p3, char *p4, char *p5)
|
|
||||||
{
|
|
||||||
if (!this->manager->logged_in(this->manager))
|
|
||||||
{
|
|
||||||
return request->redirect(request, "auth/login");
|
|
||||||
}
|
|
||||||
if (this->manager->select_gateway(this->manager, 0) == NULL)
|
|
||||||
{
|
|
||||||
return request->redirect(request, "gateway/list");
|
|
||||||
}
|
|
||||||
if (action)
|
|
||||||
{
|
|
||||||
if (streq(action, "list"))
|
|
||||||
{
|
|
||||||
return list(this, request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return request->redirect(request, "config/list");
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, destroy, void,
|
|
||||||
private_config_controller_t *this)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see header file
|
|
||||||
*/
|
|
||||||
fast_controller_t *config_controller_create(fast_context_t *context,
|
|
||||||
void *param)
|
|
||||||
{
|
|
||||||
private_config_controller_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.controller = {
|
|
||||||
.get_name = _get_name,
|
|
||||||
.handle = _handle,
|
|
||||||
.destroy = _destroy,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
.manager = (manager_t*)context,
|
|
||||||
);
|
|
||||||
|
|
||||||
return &this->public.controller;
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup config_controller config_controller
|
|
||||||
* @{ @ingroup manager_controller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CONFIG_CONTROLLER_H_
|
|
||||||
#define CONFIG_CONTROLLER_H_
|
|
||||||
|
|
||||||
#include <fast_controller.h>
|
|
||||||
|
|
||||||
typedef struct config_controller_t config_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Status controller.
|
|
||||||
*/
|
|
||||||
struct config_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements controller_t interface.
|
|
||||||
*/
|
|
||||||
fast_controller_t controller;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a config_controller controller instance.
|
|
||||||
*/
|
|
||||||
fast_controller_t *config_controller_create(fast_context_t *context,
|
|
||||||
void *param);
|
|
||||||
|
|
||||||
#endif /** CONFIG_CONTROLLER_H_ @}*/
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "control_controller.h"
|
|
||||||
#include "../manager.h"
|
|
||||||
#include "../gateway.h"
|
|
||||||
|
|
||||||
#include <xml.h>
|
|
||||||
|
|
||||||
#include <library.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct private_control_controller_t private_control_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of the task manager
|
|
||||||
*/
|
|
||||||
struct private_control_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
control_controller_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* manager instance
|
|
||||||
*/
|
|
||||||
manager_t *manager;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* handle the result of a control operation
|
|
||||||
*/
|
|
||||||
static void handle_result(private_control_controller_t *this, fast_request_t *r,
|
|
||||||
enumerator_t *e)
|
|
||||||
{
|
|
||||||
enumerator_t *e1;
|
|
||||||
xml_t *xml;
|
|
||||||
char *name, *value;
|
|
||||||
int num = 0;
|
|
||||||
|
|
||||||
if (e)
|
|
||||||
{
|
|
||||||
while (e->enumerate(e, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "status"))
|
|
||||||
{
|
|
||||||
if (value && atoi(value) == 0)
|
|
||||||
{
|
|
||||||
r->set(r, "result", "Operation executed successfully:");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r->set(r, "result", "Operation failed:");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (streq(name, "log"))
|
|
||||||
{
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "item"))
|
|
||||||
{
|
|
||||||
r->setf(r, "log.%d=%s", ++num, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e->destroy(e);
|
|
||||||
r->render(r, "templates/control/result.cs");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r->set(r, "title", "Error");
|
|
||||||
r->set(r, "error", "controlling the gateway failed");
|
|
||||||
r->render(r, "templates/error.cs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initiate an IKE or CHILD SA
|
|
||||||
*/
|
|
||||||
static void initiate(private_control_controller_t *this, fast_request_t *r,
|
|
||||||
bool ike, char *config)
|
|
||||||
{
|
|
||||||
gateway_t *gateway;
|
|
||||||
enumerator_t *e;
|
|
||||||
|
|
||||||
r->setf(r, "title=Establishing %s SA %s", ike ? "IKE" : "CHILD", config);
|
|
||||||
gateway = this->manager->select_gateway(this->manager, 0);
|
|
||||||
e = gateway->initiate(gateway, ike, config);
|
|
||||||
handle_result(this, r, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* terminate an IKE or CHILD SA
|
|
||||||
*/
|
|
||||||
static void terminate(private_control_controller_t *this, fast_request_t *r,
|
|
||||||
bool ike, uint32_t id)
|
|
||||||
{
|
|
||||||
gateway_t *gateway;
|
|
||||||
enumerator_t *e;
|
|
||||||
|
|
||||||
r->setf(r, "title=Terminate %s SA %d", ike ? "IKE" : "CHILD", id);
|
|
||||||
gateway = this->manager->select_gateway(this->manager, 0);
|
|
||||||
e = gateway->terminate(gateway, ike, id);
|
|
||||||
handle_result(this, r, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, get_name, char*,
|
|
||||||
private_control_controller_t *this)
|
|
||||||
{
|
|
||||||
return "control";
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, handle, void,
|
|
||||||
private_control_controller_t *this, fast_request_t *request, char *action,
|
|
||||||
char *str, char *p3, char *p4, char *p5)
|
|
||||||
{
|
|
||||||
if (!this->manager->logged_in(this->manager))
|
|
||||||
{
|
|
||||||
return request->redirect(request, "auth/login");
|
|
||||||
}
|
|
||||||
if (this->manager->select_gateway(this->manager, 0) == NULL)
|
|
||||||
{
|
|
||||||
return request->redirect(request, "gateway/list");
|
|
||||||
}
|
|
||||||
if (action)
|
|
||||||
{
|
|
||||||
uint32_t id;
|
|
||||||
|
|
||||||
if (streq(action, "terminateike"))
|
|
||||||
{
|
|
||||||
if (str && (id = atoi(str)))
|
|
||||||
{
|
|
||||||
return terminate(this, request, TRUE, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (streq(action, "terminatechild"))
|
|
||||||
{
|
|
||||||
if (str && (id = atoi(str)))
|
|
||||||
{
|
|
||||||
return terminate(this, request, FALSE, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (streq(action, "initiateike"))
|
|
||||||
{
|
|
||||||
if (str)
|
|
||||||
{
|
|
||||||
return initiate(this, request, TRUE, str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (streq(action, "initiatechild"))
|
|
||||||
{
|
|
||||||
if (str)
|
|
||||||
{
|
|
||||||
return initiate(this, request, FALSE, str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return request->redirect(request, "ikesa/list");
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, destroy, void,
|
|
||||||
private_control_controller_t *this)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see header file
|
|
||||||
*/
|
|
||||||
fast_controller_t *control_controller_create(fast_context_t *context,
|
|
||||||
void *param)
|
|
||||||
{
|
|
||||||
private_control_controller_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.controller = {
|
|
||||||
.get_name = _get_name,
|
|
||||||
.handle = _handle,
|
|
||||||
.destroy = _destroy,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
.manager = (manager_t*)context,
|
|
||||||
);
|
|
||||||
|
|
||||||
return &this->public.controller;
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup control_controller control_controller
|
|
||||||
* @{ @ingroup manager_controller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CONTROL_CONTROLLER_H_
|
|
||||||
#define CONTROL_CONTROLLER_H_
|
|
||||||
|
|
||||||
#include <fast_controller.h>
|
|
||||||
|
|
||||||
typedef struct control_controller_t control_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Control controller.
|
|
||||||
*/
|
|
||||||
struct control_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements controller_t interface.
|
|
||||||
*/
|
|
||||||
fast_controller_t controller;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a control_controller controller instance.
|
|
||||||
*/
|
|
||||||
fast_controller_t *control_controller_create(fast_context_t *context,
|
|
||||||
void *param);
|
|
||||||
|
|
||||||
#endif /** CONTROL_CONTROLLER_H_ @}*/
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gateway_controller.h"
|
|
||||||
#include "../manager.h"
|
|
||||||
#include "../gateway.h"
|
|
||||||
|
|
||||||
#include <library.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct private_gateway_controller_t private_gateway_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of the gateway_controller
|
|
||||||
*/
|
|
||||||
struct private_gateway_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
gateway_controller_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* manager instance
|
|
||||||
*/
|
|
||||||
manager_t *manager;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
static void list(private_gateway_controller_t *this, fast_request_t *request)
|
|
||||||
{
|
|
||||||
enumerator_t *enumerator;
|
|
||||||
char *name, *address;
|
|
||||||
int id, port;
|
|
||||||
|
|
||||||
enumerator = this->manager->create_gateway_enumerator(this->manager);
|
|
||||||
while (enumerator->enumerate(enumerator, &id, &name, &port, &address))
|
|
||||||
{
|
|
||||||
request->setf(request, "gateways.%d.name=%s", id, name);
|
|
||||||
if (port)
|
|
||||||
{
|
|
||||||
request->setf(request, "gateways.%d.address=tcp://%s:%d",
|
|
||||||
id, address, port);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
request->setf(request, "gateways.%d.address=unix://%s",
|
|
||||||
id, IPSEC_PIDDIR"/charon.xml");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enumerator->destroy(enumerator);
|
|
||||||
request->set(request, "action", "select");
|
|
||||||
request->set(request, "title", "Choose gateway");
|
|
||||||
request->render(request, "templates/gateway/list.cs");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _select(private_gateway_controller_t *this, fast_request_t *request)
|
|
||||||
{
|
|
||||||
char *id;
|
|
||||||
|
|
||||||
id = request->get_query_data(request, "gateway");
|
|
||||||
if (id)
|
|
||||||
{
|
|
||||||
if (this->manager->select_gateway(this->manager, atoi(id)))
|
|
||||||
{
|
|
||||||
request->redirect(request, "ikesa/list");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request->redirect(request, "gateway/list");
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, get_name, char*,
|
|
||||||
private_gateway_controller_t *this)
|
|
||||||
{
|
|
||||||
return "gateway";
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, handle, void,
|
|
||||||
private_gateway_controller_t *this, fast_request_t *request, char *action,
|
|
||||||
char *p2, char *p3, char *p4, char *p5)
|
|
||||||
{
|
|
||||||
if (!this->manager->logged_in(this->manager))
|
|
||||||
{
|
|
||||||
return request->redirect(request, "auth/login");
|
|
||||||
}
|
|
||||||
if (action)
|
|
||||||
{
|
|
||||||
if (streq(action, "list"))
|
|
||||||
{
|
|
||||||
return list(this, request);
|
|
||||||
}
|
|
||||||
else if (streq(action, "select"))
|
|
||||||
{
|
|
||||||
return _select(this, request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request->redirect(request, "gateway/list");
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, destroy, void,
|
|
||||||
private_gateway_controller_t *this)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see header file
|
|
||||||
*/
|
|
||||||
fast_controller_t *gateway_controller_create(fast_context_t *context,
|
|
||||||
void *param)
|
|
||||||
{
|
|
||||||
private_gateway_controller_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.controller = {
|
|
||||||
.get_name = _get_name,
|
|
||||||
.handle = _handle,
|
|
||||||
.destroy = _destroy,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
.manager = (manager_t*)context,
|
|
||||||
);
|
|
||||||
|
|
||||||
return &this->public.controller;
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup gateway_controller gateway_controller
|
|
||||||
* @{ @ingroup manager_controller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GATEWAY_CONTROLLER_H_
|
|
||||||
#define GATEWAY_CONTROLLER_H_
|
|
||||||
|
|
||||||
#include <fast_controller.h>
|
|
||||||
|
|
||||||
typedef struct gateway_controller_t gateway_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Status controller.
|
|
||||||
*/
|
|
||||||
struct gateway_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements controller_t interface.
|
|
||||||
*/
|
|
||||||
fast_controller_t controller;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a gateway_controller controller instance.
|
|
||||||
*/
|
|
||||||
fast_controller_t *gateway_controller_create(fast_context_t *context,
|
|
||||||
void *param);
|
|
||||||
|
|
||||||
#endif /** GATEWAY_CONTROLLER_H_ @}*/
|
|
||||||
@@ -1,230 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ikesa_controller.h"
|
|
||||||
#include "../manager.h"
|
|
||||||
#include "../gateway.h"
|
|
||||||
|
|
||||||
#include <xml.h>
|
|
||||||
|
|
||||||
#include <library.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct private_ikesa_controller_t private_ikesa_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of the task manager
|
|
||||||
*/
|
|
||||||
struct private_ikesa_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
ikesa_controller_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* manager instance
|
|
||||||
*/
|
|
||||||
manager_t *manager;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* read XML of a childsa element and fill template
|
|
||||||
*/
|
|
||||||
static void process_childsa(private_ikesa_controller_t *this, char *id,
|
|
||||||
enumerator_t *e, fast_request_t *r)
|
|
||||||
{
|
|
||||||
xml_t *xml;
|
|
||||||
enumerator_t *e1, *e2;
|
|
||||||
char *name, *value, *reqid = "", *section = "";
|
|
||||||
int num = 0;
|
|
||||||
|
|
||||||
while (e->enumerate(e, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "reqid"))
|
|
||||||
{
|
|
||||||
reqid = value;
|
|
||||||
}
|
|
||||||
else if (streq(name, "local") || streq(name, "remote"))
|
|
||||||
{
|
|
||||||
section = name;
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "networks"))
|
|
||||||
{
|
|
||||||
e2 = xml->children(xml);
|
|
||||||
while (e2->enumerate(e2, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "network"))
|
|
||||||
{
|
|
||||||
r->setf(r, "ikesas.%s.childsas.%s.%s.networks.%d=%s",
|
|
||||||
id, reqid, section, ++num, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e2->destroy(e2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r->setf(r, "ikesas.%s.childsas.%s.%s.%s=%s",
|
|
||||||
id, reqid, section, name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r->setf(r, "ikesas.%s.childsas.%s.%s=%s",
|
|
||||||
id, reqid, name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* read XML of a ikesa element and fill template
|
|
||||||
*/
|
|
||||||
static void process_ikesa(private_ikesa_controller_t *this,
|
|
||||||
enumerator_t *e, fast_request_t *r)
|
|
||||||
{
|
|
||||||
xml_t *xml;
|
|
||||||
enumerator_t *e1, *e2;
|
|
||||||
char *name, *value, *id = "", *section = "";
|
|
||||||
|
|
||||||
while (e->enumerate(e, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "id"))
|
|
||||||
{
|
|
||||||
id = value;
|
|
||||||
}
|
|
||||||
else if (streq(name, "local") || streq(name, "remote"))
|
|
||||||
{
|
|
||||||
section = name;
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
r->setf(r, "ikesas.%s.%s.%s=%s", id, section, name, value);
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
}
|
|
||||||
else if (streq(name, "childsalist"))
|
|
||||||
{
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "childsa"))
|
|
||||||
{
|
|
||||||
e2 = xml->children(xml);
|
|
||||||
process_childsa(this, id, e2, r);
|
|
||||||
e2->destroy(e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r->setf(r, "ikesas.%s.%s=%s", id, name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void list(private_ikesa_controller_t *this, fast_request_t *r)
|
|
||||||
{
|
|
||||||
gateway_t *gateway;
|
|
||||||
xml_t *xml;
|
|
||||||
enumerator_t *e1, *e2;
|
|
||||||
char *name, *value;
|
|
||||||
|
|
||||||
gateway = this->manager->select_gateway(this->manager, 0);
|
|
||||||
e1 = gateway->query_ikesalist(gateway);
|
|
||||||
if (e1 == NULL)
|
|
||||||
{
|
|
||||||
r->set(r, "title", "Error");
|
|
||||||
r->set(r, "error", "querying the gateway failed");
|
|
||||||
r->render(r, "templates/error.cs");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r->set(r, "title", "IKE SA overview");
|
|
||||||
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "ikesa"))
|
|
||||||
{
|
|
||||||
e2 = xml->children(xml);
|
|
||||||
process_ikesa(this, e2, r);
|
|
||||||
e2->destroy(e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
|
|
||||||
r->render(r, "templates/ikesa/list.cs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, get_name, char*,
|
|
||||||
private_ikesa_controller_t *this)
|
|
||||||
{
|
|
||||||
return "ikesa";
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, handle, void,
|
|
||||||
private_ikesa_controller_t *this, fast_request_t *request, char *action,
|
|
||||||
char *p2, char *p3, char *p4, char *p5)
|
|
||||||
{
|
|
||||||
if (!this->manager->logged_in(this->manager))
|
|
||||||
{
|
|
||||||
return request->redirect(request, "auth/login");
|
|
||||||
}
|
|
||||||
if (this->manager->select_gateway(this->manager, 0) == NULL)
|
|
||||||
{
|
|
||||||
return request->redirect(request, "gateway/list");
|
|
||||||
}
|
|
||||||
if (action)
|
|
||||||
{
|
|
||||||
if (streq(action, "list"))
|
|
||||||
{
|
|
||||||
return list(this, request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return request->redirect(request, "ikesa/list");
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_controller_t, destroy, void,
|
|
||||||
private_ikesa_controller_t *this)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see header file
|
|
||||||
*/
|
|
||||||
fast_controller_t *ikesa_controller_create(fast_context_t *context, void *param)
|
|
||||||
{
|
|
||||||
private_ikesa_controller_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.controller = {
|
|
||||||
.get_name = _get_name,
|
|
||||||
.handle = _handle,
|
|
||||||
.destroy = _destroy,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
.manager = (manager_t*)context,
|
|
||||||
);
|
|
||||||
|
|
||||||
return &this->public.controller;
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup ikesa_controller ikesa_controller
|
|
||||||
* @{ @ingroup manager_controller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef IKESA_CONTROLLER_H_
|
|
||||||
#define IKESA_CONTROLLER_H_
|
|
||||||
|
|
||||||
#include <fast_controller.h>
|
|
||||||
|
|
||||||
typedef struct ikesa_controller_t ikesa_controller_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Status controller.
|
|
||||||
*/
|
|
||||||
struct ikesa_controller_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements controller_t interface.
|
|
||||||
*/
|
|
||||||
fast_controller_t controller;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a ikesa_controller controller instance.
|
|
||||||
*/
|
|
||||||
fast_controller_t *ikesa_controller_create(fast_context_t *context, void *param);
|
|
||||||
|
|
||||||
#endif /** IKESA_CONTROLLER_H_ @}*/
|
|
||||||
@@ -1,398 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gateway.h"
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
|
|
||||||
#include <xml.h>
|
|
||||||
|
|
||||||
typedef struct private_gateway_t private_gateway_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of gateway
|
|
||||||
*/
|
|
||||||
struct private_gateway_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
gateway_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* name of the gateway
|
|
||||||
*/
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* host to connect using tcp
|
|
||||||
*/
|
|
||||||
host_t *host;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* socket file descriptor, > 0 if connected
|
|
||||||
*/
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* unique id assigned to each xml message
|
|
||||||
*/
|
|
||||||
int xmlid;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sockaddr_un unix_addr = { AF_UNIX, IPSEC_PIDDIR "/charon.xml"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* establish connection to gateway
|
|
||||||
*/
|
|
||||||
static bool connect_(private_gateway_t *this)
|
|
||||||
{
|
|
||||||
int family, len;
|
|
||||||
struct sockaddr *addr;
|
|
||||||
|
|
||||||
if (this->fd >= 0)
|
|
||||||
{
|
|
||||||
close(this->fd);
|
|
||||||
}
|
|
||||||
if (this->host)
|
|
||||||
{
|
|
||||||
family = AF_INET;
|
|
||||||
addr = this->host->get_sockaddr(this->host);
|
|
||||||
len = *this->host->get_sockaddr_len(this->host);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
family = AF_UNIX;
|
|
||||||
addr = (struct sockaddr*)&unix_addr;
|
|
||||||
len = sizeof(unix_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->fd = socket(family, SOCK_STREAM, 0);
|
|
||||||
if (this->fd < 0)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (connect(this->fd, addr, len) != 0)
|
|
||||||
{
|
|
||||||
close(this->fd);
|
|
||||||
this->fd = -1;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(gateway_t, request, char*,
|
|
||||||
private_gateway_t *this, char *xml, ...)
|
|
||||||
{
|
|
||||||
if (this->fd < 0)
|
|
||||||
{
|
|
||||||
if (!connect_(this))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
char buf[8096];
|
|
||||||
ssize_t len;
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, xml);
|
|
||||||
len = vsnprintf(buf, sizeof(buf), xml, args);
|
|
||||||
va_end(args);
|
|
||||||
if (len < 0 || len >= sizeof(buf))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (send(this->fd, buf, len, 0) != len)
|
|
||||||
{
|
|
||||||
if (!connect_(this))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
len = recv(this->fd, buf, sizeof(buf) - 1, 0);
|
|
||||||
if (len <= 0)
|
|
||||||
{
|
|
||||||
if (!connect_(this))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
buf[len] = 0;
|
|
||||||
return strdup(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(gateway_t, query_ikesalist, enumerator_t*,
|
|
||||||
private_gateway_t *this)
|
|
||||||
{
|
|
||||||
char *str, *name, *value;
|
|
||||||
xml_t *xml;
|
|
||||||
enumerator_t *e1, *e2, *e3, *e4 = NULL;
|
|
||||||
|
|
||||||
str = request(this, "<message type=\"request\" id=\"%d\">"
|
|
||||||
"<query>"
|
|
||||||
"<ikesalist/>"
|
|
||||||
"</query>"
|
|
||||||
"</message>", this->xmlid++);
|
|
||||||
if (str == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
xml = xml_create(str);
|
|
||||||
if (xml == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
free(str);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "message"))
|
|
||||||
{
|
|
||||||
e2 = xml->children(xml);
|
|
||||||
while (e2->enumerate(e2, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "query"))
|
|
||||||
{
|
|
||||||
e3 = xml->children(xml);
|
|
||||||
while (e3->enumerate(e3, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "ikesalist"))
|
|
||||||
{
|
|
||||||
e4 = xml->children(xml);
|
|
||||||
e1->destroy(e1);
|
|
||||||
e2->destroy(e2);
|
|
||||||
e3->destroy(e3);
|
|
||||||
return e4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e3->destroy(e3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e2->destroy(e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(gateway_t, query_configlist, enumerator_t*,
|
|
||||||
private_gateway_t *this)
|
|
||||||
{
|
|
||||||
char *str, *name, *value;
|
|
||||||
xml_t *xml;
|
|
||||||
enumerator_t *e1, *e2, *e3, *e4 = NULL;
|
|
||||||
|
|
||||||
str = request(this, "<message type=\"request\" id=\"%d\">"
|
|
||||||
"<query>"
|
|
||||||
"<configlist/>"
|
|
||||||
"</query>"
|
|
||||||
"</message>", this->xmlid++);
|
|
||||||
if (str == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
xml = xml_create(str);
|
|
||||||
if (xml == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
free(str);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "message"))
|
|
||||||
{
|
|
||||||
e2 = xml->children(xml);
|
|
||||||
while (e2->enumerate(e2, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "query"))
|
|
||||||
{
|
|
||||||
e3 = xml->children(xml);
|
|
||||||
while (e3->enumerate(e3, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "configlist"))
|
|
||||||
{
|
|
||||||
e4 = xml->children(xml);
|
|
||||||
e1->destroy(e1);
|
|
||||||
e2->destroy(e2);
|
|
||||||
e3->destroy(e3);
|
|
||||||
return e4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e3->destroy(e3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e2->destroy(e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create enumerator over control elements children of a control response
|
|
||||||
*/
|
|
||||||
static enumerator_t* read_result(private_gateway_t *this, char *res)
|
|
||||||
{
|
|
||||||
char *name, *value;
|
|
||||||
xml_t *xml;
|
|
||||||
enumerator_t *e1, *e2, *e3;
|
|
||||||
|
|
||||||
if (res == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
xml = xml_create(res);
|
|
||||||
if (xml == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
e1 = xml->children(xml);
|
|
||||||
free(res);
|
|
||||||
while (e1->enumerate(e1, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "message"))
|
|
||||||
{
|
|
||||||
e2 = xml->children(xml);
|
|
||||||
while (e2->enumerate(e2, &xml, &name, &value))
|
|
||||||
{
|
|
||||||
if (streq(name, "control"))
|
|
||||||
{
|
|
||||||
e3 = xml->children(xml);
|
|
||||||
e1->destroy(e1);
|
|
||||||
e2->destroy(e2);
|
|
||||||
return e3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e2->destroy(e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1->destroy(e1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(gateway_t, initiate, enumerator_t*,
|
|
||||||
private_gateway_t *this, bool ike, char *name)
|
|
||||||
{
|
|
||||||
char *str, *kind;
|
|
||||||
|
|
||||||
if (ike)
|
|
||||||
{
|
|
||||||
kind = "ike";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
kind = "child";
|
|
||||||
}
|
|
||||||
str = request(this, "<message type=\"request\" id=\"%d\">"
|
|
||||||
"<control>"
|
|
||||||
"<%ssainitiate>%s</%ssainitiate>"
|
|
||||||
"</control>"
|
|
||||||
"</message>", this->xmlid++, kind, name, kind);
|
|
||||||
return read_result(this, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(gateway_t, terminate, enumerator_t*,
|
|
||||||
private_gateway_t *this, bool ike, uint32_t id)
|
|
||||||
{
|
|
||||||
char *str, *kind;
|
|
||||||
|
|
||||||
if (ike)
|
|
||||||
{
|
|
||||||
kind = "ike";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
kind = "child";
|
|
||||||
}
|
|
||||||
str = request(this, "<message type=\"request\" id=\"%d\">"
|
|
||||||
"<control>"
|
|
||||||
"<%ssaterminate>%d</%ssaterminate>"
|
|
||||||
"</control>"
|
|
||||||
"</message>", this->xmlid++, kind, id, kind);
|
|
||||||
return read_result(this, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(gateway_t, destroy, void,
|
|
||||||
private_gateway_t *this)
|
|
||||||
{
|
|
||||||
if (this->fd >= 0)
|
|
||||||
{
|
|
||||||
close(this->fd);
|
|
||||||
}
|
|
||||||
if (this->host) this->host->destroy(this->host);
|
|
||||||
free(this->name);
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* generic constructor
|
|
||||||
*/
|
|
||||||
static private_gateway_t *gateway_create(char *name)
|
|
||||||
{
|
|
||||||
private_gateway_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.request = _request,
|
|
||||||
.query_ikesalist = _query_ikesalist,
|
|
||||||
.query_configlist = _query_configlist,
|
|
||||||
.initiate = _initiate,
|
|
||||||
.terminate = _terminate,
|
|
||||||
.destroy = _destroy,
|
|
||||||
},
|
|
||||||
.name = strdup(name),
|
|
||||||
.fd = -1,
|
|
||||||
.xmlid = 1,
|
|
||||||
);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* see header
|
|
||||||
*/
|
|
||||||
gateway_t *gateway_create_tcp(char *name, host_t *host)
|
|
||||||
{
|
|
||||||
private_gateway_t *this = gateway_create(name);
|
|
||||||
|
|
||||||
this->host = host;
|
|
||||||
|
|
||||||
return &this->public;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* see header
|
|
||||||
*/
|
|
||||||
gateway_t *gateway_create_unix(char *name)
|
|
||||||
{
|
|
||||||
private_gateway_t *this = gateway_create(name);
|
|
||||||
|
|
||||||
return &this->public;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup gateway gateway
|
|
||||||
* @{ @ingroup manager
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GATEWAY_H_
|
|
||||||
#define GATEWAY_H_
|
|
||||||
|
|
||||||
#include <networking/host.h>
|
|
||||||
#include <collections/enumerator.h>
|
|
||||||
|
|
||||||
typedef struct gateway_t gateway_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A connection to a gateway.
|
|
||||||
*/
|
|
||||||
struct gateway_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send an XML request to the gateway.
|
|
||||||
*
|
|
||||||
* @param xml xml request string
|
|
||||||
* @param ... printf style argument list for xml request string
|
|
||||||
* @return allocated xml response string
|
|
||||||
*/
|
|
||||||
char* (*request)(gateway_t *this, char *xml, ...);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the list of IKE_SAs and all its children.
|
|
||||||
*
|
|
||||||
* @return enumerator over ikesa XML elements
|
|
||||||
*/
|
|
||||||
enumerator_t* (*query_ikesalist)(gateway_t *this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the list of peer configs and its subconfigs.
|
|
||||||
*
|
|
||||||
* @return enumerator over peerconfig XML elements
|
|
||||||
*/
|
|
||||||
enumerator_t* (*query_configlist)(gateway_t *this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate an IKE or a CHILD SA.
|
|
||||||
*
|
|
||||||
* @param ike TRUE for IKE-, FALSE for a CHILD-SA
|
|
||||||
* @param id ID of the SA to terminate
|
|
||||||
* @return enumerator over control response XML children
|
|
||||||
*/
|
|
||||||
enumerator_t* (*terminate)(gateway_t *this, bool ike, uint32_t id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initiate an IKE or a CHILD SA.
|
|
||||||
*
|
|
||||||
* @param ike TRUE for IKE-, FALSE for CHILD-SA
|
|
||||||
* @param name name of the peer/child config
|
|
||||||
* @return enumerator over control response XML children
|
|
||||||
*/
|
|
||||||
enumerator_t* (*initiate)(gateway_t *this, bool ike, char *name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a gateway instance.
|
|
||||||
*/
|
|
||||||
void (*destroy)(gateway_t *this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a gateway instance using a TCP connection.
|
|
||||||
*
|
|
||||||
* @param name name of the gateway
|
|
||||||
* @param host gateway connection endpoint
|
|
||||||
* @return gateway connection
|
|
||||||
*/
|
|
||||||
gateway_t *gateway_create_tcp(char *name, host_t *host);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a gateway instance using a UNIX socket.
|
|
||||||
*
|
|
||||||
* @param name name of the gateway
|
|
||||||
* @return gateway connection
|
|
||||||
*/
|
|
||||||
gateway_t *gateway_create_unix(char *name);
|
|
||||||
|
|
||||||
#endif /** GATEWAY_H_ @}*/
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fast_dispatcher.h>
|
|
||||||
#include <utils/debug.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "manager.h"
|
|
||||||
#include "storage.h"
|
|
||||||
#include "controller/auth_controller.h"
|
|
||||||
#include "controller/ikesa_controller.h"
|
|
||||||
#include "controller/gateway_controller.h"
|
|
||||||
#include "controller/control_controller.h"
|
|
||||||
#include "controller/config_controller.h"
|
|
||||||
|
|
||||||
int main (int arc, char *argv[])
|
|
||||||
{
|
|
||||||
fast_dispatcher_t *dispatcher;
|
|
||||||
storage_t *storage;
|
|
||||||
char *socket;
|
|
||||||
char *database;
|
|
||||||
bool debug;
|
|
||||||
int threads, timeout;
|
|
||||||
|
|
||||||
library_init(NULL, "manager");
|
|
||||||
if (!lib->plugins->load(lib->plugins,
|
|
||||||
lib->settings->get_str(lib->settings, "manager.load", PLUGINS)))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
socket = lib->settings->get_str(lib->settings, "manager.socket", NULL);
|
|
||||||
debug = lib->settings->get_bool(lib->settings, "manager.debug", FALSE);
|
|
||||||
timeout = lib->settings->get_time(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(DBG_LIB, "database URI undefined, set manager.database "
|
|
||||||
"in strongswan.conf");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
storage = storage_create(database);
|
|
||||||
if (storage == NULL)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatcher = fast_dispatcher_create(socket, debug, timeout,
|
|
||||||
(fast_context_constructor_t)manager_create, storage);
|
|
||||||
dispatcher->add_controller(dispatcher, ikesa_controller_create, NULL);
|
|
||||||
dispatcher->add_controller(dispatcher, gateway_controller_create, NULL);
|
|
||||||
dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
|
|
||||||
dispatcher->add_controller(dispatcher, control_controller_create, NULL);
|
|
||||||
dispatcher->add_controller(dispatcher, config_controller_create, NULL);
|
|
||||||
|
|
||||||
dispatcher->run(dispatcher, threads);
|
|
||||||
|
|
||||||
dispatcher->waitsignal(dispatcher);
|
|
||||||
|
|
||||||
dispatcher->destroy(dispatcher);
|
|
||||||
storage->destroy(storage);
|
|
||||||
|
|
||||||
library_deinit();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Debug helper script, launches manager statically. Use Apache config:
|
|
||||||
# FastCgiIpcDir /var/lib/apache2/fastcgi
|
|
||||||
# FastCgiExternalServer /var/www/manager-dbg -socket manager
|
|
||||||
|
|
||||||
make CFLAGS="-g -O2 -DFCGI_SOCKET=\\\"/var/lib/apache2/fastcgi/manager\\\"" || exit
|
|
||||||
sudo make install || exit
|
|
||||||
|
|
||||||
if [ "$1" == "dbg" ]
|
|
||||||
then
|
|
||||||
sudo -u www-data gdb -q /usr/local/libexec/ipsec/manager.fcgi
|
|
||||||
else
|
|
||||||
sudo -u www-data /usr/local/libexec/ipsec/manager.fcgi
|
|
||||||
fi
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "manager.h"
|
|
||||||
|
|
||||||
#include "gateway.h"
|
|
||||||
|
|
||||||
#include <collections/linked_list.h>
|
|
||||||
|
|
||||||
typedef struct private_manager_t private_manager_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of manager
|
|
||||||
*/
|
|
||||||
struct private_manager_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
manager_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* underlying storage database
|
|
||||||
*/
|
|
||||||
storage_t *store;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* user id, if we are logged in
|
|
||||||
*/
|
|
||||||
int user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* selected gateway
|
|
||||||
*/
|
|
||||||
gateway_t *gateway;
|
|
||||||
};
|
|
||||||
|
|
||||||
METHOD(manager_t, create_gateway_enumerator, enumerator_t*,
|
|
||||||
private_manager_t *this)
|
|
||||||
{
|
|
||||||
return this->store->create_gateway_enumerator(this->store, this->user);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(manager_t, select_gateway, gateway_t*,
|
|
||||||
private_manager_t *this, int select_id)
|
|
||||||
{
|
|
||||||
if (select_id != 0)
|
|
||||||
{
|
|
||||||
enumerator_t *enumerator;
|
|
||||||
int id, port;
|
|
||||||
char *name, *address;
|
|
||||||
host_t *host;
|
|
||||||
|
|
||||||
if (this->gateway) this->gateway->destroy(this->gateway);
|
|
||||||
this->gateway = NULL;
|
|
||||||
|
|
||||||
enumerator = this->store->create_gateway_enumerator(this->store, this->user);
|
|
||||||
while (enumerator->enumerate(enumerator, &id, &name, &port, &address))
|
|
||||||
{
|
|
||||||
if (select_id == id)
|
|
||||||
{
|
|
||||||
if (port == 0)
|
|
||||||
{
|
|
||||||
this->gateway = gateway_create_unix(name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
host = host_create_from_string(address, port);
|
|
||||||
if (host)
|
|
||||||
{
|
|
||||||
this->gateway = gateway_create_tcp(name, host);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enumerator->destroy(enumerator);
|
|
||||||
}
|
|
||||||
return this->gateway;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(manager_t, logged_in, bool,
|
|
||||||
private_manager_t *this)
|
|
||||||
{
|
|
||||||
return this->user != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(manager_t, login, bool,
|
|
||||||
private_manager_t *this, char *username, char *password)
|
|
||||||
{
|
|
||||||
if (!this->user)
|
|
||||||
{
|
|
||||||
this->user = this->store->login(this->store, username, password);
|
|
||||||
}
|
|
||||||
return this->user != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(manager_t, logout, void,
|
|
||||||
private_manager_t *this)
|
|
||||||
{
|
|
||||||
if (this->gateway)
|
|
||||||
{
|
|
||||||
this->gateway->destroy(this->gateway);
|
|
||||||
this->gateway = NULL;
|
|
||||||
}
|
|
||||||
this->user = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(fast_context_t, destroy, void,
|
|
||||||
private_manager_t *this)
|
|
||||||
{
|
|
||||||
if (this->gateway) this->gateway->destroy(this->gateway);
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see header file
|
|
||||||
*/
|
|
||||||
manager_t *manager_create(storage_t *storage)
|
|
||||||
{
|
|
||||||
private_manager_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.login = _login,
|
|
||||||
.logged_in = _logged_in,
|
|
||||||
.logout = _logout,
|
|
||||||
.create_gateway_enumerator = _create_gateway_enumerator,
|
|
||||||
.select_gateway = _select_gateway,
|
|
||||||
.context = {
|
|
||||||
.destroy = _destroy,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
.store = storage,
|
|
||||||
);
|
|
||||||
|
|
||||||
return &this->public;
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup manager manager
|
|
||||||
*
|
|
||||||
* @defgroup manager_controller controller
|
|
||||||
* @ingroup manager
|
|
||||||
*
|
|
||||||
* @defgroup manager_i manager
|
|
||||||
* @{ @ingroup manager
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MANAGER_H_
|
|
||||||
#define MANAGER_H_
|
|
||||||
|
|
||||||
#include "storage.h"
|
|
||||||
#include "gateway.h"
|
|
||||||
|
|
||||||
#include <fast_context.h>
|
|
||||||
|
|
||||||
typedef struct manager_t manager_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The manager, manages multiple gateways.
|
|
||||||
*/
|
|
||||||
struct manager_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* implements context_t interface
|
|
||||||
*/
|
|
||||||
fast_context_t context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an enumerator over all configured gateways.
|
|
||||||
*
|
|
||||||
* enumerate() arguments: int id, char *name, int port, char *address
|
|
||||||
* If port is 0, address is a Unix socket address.
|
|
||||||
*
|
|
||||||
* @return enumerator
|
|
||||||
*/
|
|
||||||
enumerator_t* (*create_gateway_enumerator)(manager_t *this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select a gateway.
|
|
||||||
*
|
|
||||||
* If id is 0, the previously selected gateway is returned. If none has
|
|
||||||
* been selected yet, NULL is returned.
|
|
||||||
*
|
|
||||||
* @param id id of the gateway (from enumerate), or 0
|
|
||||||
* @return selected gateway, or NULL
|
|
||||||
*/
|
|
||||||
gateway_t* (*select_gateway)(manager_t *this, int id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to log in.
|
|
||||||
*
|
|
||||||
* @param username username
|
|
||||||
* @param password cleartext password
|
|
||||||
* @return TRUE if login successful
|
|
||||||
*/
|
|
||||||
bool (*login)(manager_t *this, char *username, char *password);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if user logged in.
|
|
||||||
*
|
|
||||||
* @return TRUE if logged in
|
|
||||||
*/
|
|
||||||
bool (*logged_in)(manager_t *this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log out.
|
|
||||||
*/
|
|
||||||
void (*logout)(manager_t *this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a manager instance.
|
|
||||||
*/
|
|
||||||
manager_t *manager_create(storage_t *storage);
|
|
||||||
|
|
||||||
#endif /** MANAGER_H_ @}*/
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
|
|
||||||
CREATE TABLE users (
|
|
||||||
username TEXT, password TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE gateways (
|
|
||||||
name TEXT,
|
|
||||||
port INTEGER,
|
|
||||||
address text
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE user_gateway (
|
|
||||||
user INTEGER,
|
|
||||||
gateway INTEGER
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO users VALUES(
|
|
||||||
'strongSwan',
|
|
||||||
'44092c0394d3661bd3c3587f43e48729836bdf6e' -- strongSwan
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO gateways VALUES(
|
|
||||||
'Local Unix',
|
|
||||||
0,
|
|
||||||
'/var/run/charon.xml'
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO user_gateway VALUES(
|
|
||||||
1,1
|
|
||||||
);
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "storage.h"
|
|
||||||
|
|
||||||
#include <library.h>
|
|
||||||
#include <crypto/hashers/hasher.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct private_storage_t private_storage_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of storage
|
|
||||||
*/
|
|
||||||
struct private_storage_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
storage_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* database connection
|
|
||||||
*/
|
|
||||||
database_t *db;
|
|
||||||
};
|
|
||||||
|
|
||||||
METHOD(storage_t, login, int,
|
|
||||||
private_storage_t *this, char *username, char *password)
|
|
||||||
{
|
|
||||||
hasher_t *hasher;
|
|
||||||
chunk_t hash, data, hex_str;
|
|
||||||
size_t username_len, password_len;
|
|
||||||
int uid = 0;
|
|
||||||
enumerator_t *enumerator;
|
|
||||||
|
|
||||||
/* hash = SHA1( username | password ) */
|
|
||||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
|
||||||
if (hasher == NULL)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
hash = chunk_alloca(hasher->get_hash_size(hasher));
|
|
||||||
username_len = strlen(username);
|
|
||||||
password_len = strlen(password);
|
|
||||||
data = chunk_alloca(username_len + password_len);
|
|
||||||
memcpy(data.ptr, username, username_len);
|
|
||||||
memcpy(data.ptr + username_len, password, password_len);
|
|
||||||
if (!hasher->get_hash(hasher, data, hash.ptr))
|
|
||||||
{
|
|
||||||
hasher->destroy(hasher);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
hasher->destroy(hasher);
|
|
||||||
hex_str = chunk_to_hex(hash, NULL, FALSE);
|
|
||||||
|
|
||||||
enumerator = this->db->query(this->db,
|
|
||||||
"SELECT oid FROM users WHERE username = ? AND password = ?;",
|
|
||||||
DB_TEXT, username, DB_TEXT, hex_str.ptr,
|
|
||||||
DB_INT);
|
|
||||||
if (enumerator)
|
|
||||||
{
|
|
||||||
enumerator->enumerate(enumerator, &uid);
|
|
||||||
enumerator->destroy(enumerator);
|
|
||||||
}
|
|
||||||
free(hex_str.ptr);
|
|
||||||
return uid;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(storage_t, create_gateway_enumerator, enumerator_t*,
|
|
||||||
private_storage_t *this, int user)
|
|
||||||
{
|
|
||||||
enumerator_t *enumerator;
|
|
||||||
|
|
||||||
enumerator = this->db->query(this->db,
|
|
||||||
"SELECT gateways.oid AS gid, name, port, address FROM "
|
|
||||||
"gateways, user_gateway AS ug ON gid = ug.gateway WHERE ug.user = ?;",
|
|
||||||
DB_INT, user,
|
|
||||||
DB_INT, DB_TEXT, DB_INT, DB_TEXT);
|
|
||||||
if (!enumerator)
|
|
||||||
{
|
|
||||||
enumerator = enumerator_create_empty();
|
|
||||||
}
|
|
||||||
return enumerator;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(storage_t, destroy, void,
|
|
||||||
private_storage_t *this)
|
|
||||||
{
|
|
||||||
this->db->destroy(this->db);
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see header file
|
|
||||||
*/
|
|
||||||
storage_t *storage_create(char *uri)
|
|
||||||
{
|
|
||||||
private_storage_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.login = _login,
|
|
||||||
.create_gateway_enumerator = _create_gateway_enumerator,
|
|
||||||
.destroy = _destroy,
|
|
||||||
},
|
|
||||||
.db = lib->db->create(lib->db, uri),
|
|
||||||
);
|
|
||||||
if (this->db == NULL)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return &this->public;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup storage storage
|
|
||||||
* @{ @ingroup manager
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef STORAGE_H_
|
|
||||||
#define STORAGE_H_
|
|
||||||
|
|
||||||
#include <collections/enumerator.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct storage_t storage_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Persistent database storage.
|
|
||||||
*/
|
|
||||||
struct storage_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to log in using specified credentials.
|
|
||||||
*
|
|
||||||
* @param username username
|
|
||||||
* @param password plaintext password
|
|
||||||
* @return user ID if login good, 0 otherwise
|
|
||||||
*/
|
|
||||||
int (*login)(storage_t *this, char *username, char *password);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an enumerator over the gateways.
|
|
||||||
*
|
|
||||||
* enumerate() arguments: int id, char *name, int port, char *address
|
|
||||||
* If port is 0, address is a Unix socket address.
|
|
||||||
*
|
|
||||||
* @param user user Id
|
|
||||||
* @return enumerator
|
|
||||||
*/
|
|
||||||
enumerator_t* (*create_gateway_enumerator)(storage_t *this, int user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a storage instance.
|
|
||||||
*/
|
|
||||||
void (*destroy)(storage_t *this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a storage instance.
|
|
||||||
*
|
|
||||||
* @param uri database connection URI
|
|
||||||
*/
|
|
||||||
storage_t *storage_create(char *uri);
|
|
||||||
|
|
||||||
#endif /** STORAGE_H_ @}*/
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?cs include:"templates/header.cs" ?>
|
|
||||||
<div align="center">
|
|
||||||
<form method="post" action="<?cs var:action ?>">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Username</td><td><input type="text" name="username" size="25" /></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Password</td><td><input type="password" name="password" size="25" /></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td/><td><input type="submit" value="Login"/></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?cs include:"templates/footer.cs" ?>
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
<?cs include:"templates/header.cs" ?>
|
|
||||||
<?cs each:peercfg = peercfgs ?>
|
|
||||||
<div class="expand" id="peercfg-<?cs name:peercfg ?>">
|
|
||||||
<h1><?cs name:peercfg ?>:
|
|
||||||
<span><?cs var:peercfg.local ?></span> <->
|
|
||||||
<span><?cs var:peercfg.remote ?></span>
|
|
||||||
</h1>
|
|
||||||
<div class="controls">
|
|
||||||
<?cs if:peercfg.remote != "%any" ?>
|
|
||||||
<a title="initiate SA" href="<?cs var:base ?>/control/initiateike/<?cs name:peercfg ?>">
|
|
||||||
<img src="<?cs var:base ?>/static/initiate.png"/>
|
|
||||||
</a>
|
|
||||||
<?cs else ?>
|
|
||||||
|
|
||||||
<?cs /if ?>
|
|
||||||
</div>
|
|
||||||
<div class="expander">
|
|
||||||
<hr/>
|
|
||||||
<table class="drawing">
|
|
||||||
<tr>
|
|
||||||
<td class="left" colspan="3">
|
|
||||||
<?cs var:peercfg.local ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td class="right" colspan="3">
|
|
||||||
<?cs var:peercfg.remote ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="images">
|
|
||||||
<td>
|
|
||||||
<?cs if:peercfg.remote != "%any" ?>
|
|
||||||
<img title="Local host can be the initiator" src="<?cs var:base ?>/static/client-left.png"></img>
|
|
||||||
<?cs else ?>
|
|
||||||
<img title="Local host must be the responder" src="<?cs var:base ?>/static/gateway-left.png"></img>
|
|
||||||
<?cs /if ?>
|
|
||||||
</td>
|
|
||||||
<td style="background-image:url(<?cs var:base ?>/static/pipe.png)">
|
|
||||||
<font color="#e5bf5e">0123456789abdcef</font><br/><br/><br/>
|
|
||||||
<?cs var:peercfg.ikecfg.local ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img src="<?cs var:base ?>/static/pipe.png"></img>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img title="IKE connection is down" src="<?cs var:base ?>/static/pipe.png"></img>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img src="<?cs var:base ?>/static/pipe.png"></img>
|
|
||||||
</td>
|
|
||||||
<td class="right" style="background-image:url(<?cs var:base ?>/static/pipe.png)">
|
|
||||||
<font color="#e5bf5e">0123456789abcdef</font><br/><br/><br/>
|
|
||||||
<?cs var:peercfg.ikecfg.remote ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?cs if:peercfg.remote == "%any" ?>
|
|
||||||
<img title="Remote host must be the initiator" src="<?cs var:base ?>/static/client-right.png"></img>
|
|
||||||
<?cs else ?>
|
|
||||||
<img title="Remote host can be the responder" src="<?cs var:base ?>/static/gateway-right.png"></img>
|
|
||||||
<?cs /if ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?cs each:childcfg = peercfg.childcfgs ?>
|
|
||||||
<tr>
|
|
||||||
<td colspan="6" class="expand">
|
|
||||||
<h1><?cs name:childcfg ?>:</h1>
|
|
||||||
</td>
|
|
||||||
<td class="controls">
|
|
||||||
<?cs if:peercfg.remote != "%any" ?>
|
|
||||||
<a title="initiate SA" href="<?cs var:base ?>/control/initiatechild/<?cs name:childcfg ?>">
|
|
||||||
<img src="<?cs var:base ?>/static/initiate.png"/>
|
|
||||||
</a>
|
|
||||||
<?cs /if ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="7"><hr/></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="images">
|
|
||||||
<td colspan="2">
|
|
||||||
<?cs each:net = childcfg.local.networks ?>
|
|
||||||
<p><?cs var:net ?></p>
|
|
||||||
<?cs /each ?>
|
|
||||||
</td>
|
|
||||||
<td style="background-image:url(<?cs var:base ?>/static/pipe-thin-left.png)">
|
|
||||||
<br/><br/><br/>
|
|
||||||
</td>
|
|
||||||
<td style="background-image:url(<?cs var:base ?>/static/pipe-thin.png)">
|
|
||||||
</td>
|
|
||||||
<td class="right" style="background-image:url(<?cs var:base ?>/static/pipe-thin-right.png)">
|
|
||||||
<br/><br/><br/>
|
|
||||||
</td>
|
|
||||||
<td class="right" colspan="2">
|
|
||||||
<?cs each:net = childcfg.remote.networks ?>
|
|
||||||
<p><?cs var:net ?></p>
|
|
||||||
<?cs /each ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?cs /each ?>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?cs /each ?>
|
|
||||||
<?cs include:"templates/footer.cs" ?>
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?cs include:"templates/header.cs" ?>
|
|
||||||
<div class="expand">
|
|
||||||
<h1><?cs var:result ?></h1>
|
|
||||||
<div class="controls"> </div>
|
|
||||||
<div class="expander">
|
|
||||||
<hr/>
|
|
||||||
<ul>
|
|
||||||
<?cs each:item = log ?>
|
|
||||||
<li><?cs var:item ?></li>
|
|
||||||
<?cs /each ?>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?cs include:"templates/footer.cs" ?>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<?cs include:"templates/header.cs" ?>
|
|
||||||
<div><?cs var:error ?></div>
|
|
||||||
<?cs include:"templates/footer.cs" ?>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?cs include:"templates/header.cs" ?>
|
|
||||||
<div class="dialog">
|
|
||||||
<form method="post" action="<?cs var:action ?>">
|
|
||||||
<p>
|
|
||||||
<select name="gateway" size="1">
|
|
||||||
<?cs each:gateway = gateways ?>
|
|
||||||
<option value="<?cs name:gateway ?>"><?cs var:gateway.name ?> (<?cs var:gateway.address ?>)</option>
|
|
||||||
<?cs /each ?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
<input type="submit" value="Select"/>
|
|
||||||
<p>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?cs include:"templates/footer.cs" ?>
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<title><?cs var:title ?> - strongSwan Manager</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="<?cs var:base ?>/static/style.css" />
|
|
||||||
<script type="text/javascript" src="<?cs var:base ?>/static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="<?cs var:base ?>/static/script.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="fleft">
|
|
||||||
<a href="<?cs var:base ?>/ikesa/list">
|
|
||||||
<img class="fleft" src="<?cs var:base ?>/static/strongswan.png"/>
|
|
||||||
</a>
|
|
||||||
<h1>strongSwan Manager</h1>
|
|
||||||
<h2><?cs var:title ?></h2>
|
|
||||||
</div>
|
|
||||||
<div class="menu">
|
|
||||||
| <a href="<?cs var:base ?>/ikesa/list">IKE SAs</a>
|
|
||||||
| <a href="<?cs var:base ?>/config/list">Config</a>
|
|
||||||
| <a href="<?cs var:base ?>/gateway/list">Gateway</a>
|
|
||||||
| <a href="<?cs var:base ?>/auth/logout">Logout</a>
|
|
||||||
</div>
|
|
||||||
<hr class="cleft"/>
|
|
||||||
<div class="center">
|
|
||||||
<div class="content">
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
<?cs include:"templates/header.cs" ?>
|
|
||||||
<?cs each:ikesa = ikesas ?>
|
|
||||||
<div class="expand" id="ikesa-<?cs name:ikesa ?>">
|
|
||||||
<h1>
|
|
||||||
<?cs var:ikesa.peerconfig ?> [IKE #<?cs name:ikesa ?>]:
|
|
||||||
<span><?cs var:ikesa.local.identification ?></span> <->
|
|
||||||
<span><?cs var:ikesa.remote.identification ?></span>
|
|
||||||
</h1>
|
|
||||||
<div class="controls">
|
|
||||||
<a title="close IKE_SA" href="<?cs var:base ?>/control/terminateike/<?cs name:ikesa ?>">
|
|
||||||
<img src="<?cs var:base ?>/static/close.png"/>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="expander">
|
|
||||||
<hr/>
|
|
||||||
<table class="drawing">
|
|
||||||
<tr>
|
|
||||||
<td class="left" colspan="3">
|
|
||||||
<?cs var:ikesa.local.identification ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td class="right" colspan="3">
|
|
||||||
<?cs var:ikesa.remote.identification ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="images">
|
|
||||||
<td>
|
|
||||||
<?cs if:ikesa.role == "initiator" ?>
|
|
||||||
<img title="Local host is the initiator" src="<?cs var:base ?>/static/client-left.png"></img>
|
|
||||||
<?cs else ?>
|
|
||||||
<img title="Local host is the responder" src="<?cs var:base ?>/static/gateway-left.png"></img>
|
|
||||||
<?cs /if ?>
|
|
||||||
</td>
|
|
||||||
<td style="background-image:url(<?cs var:base ?>/static/pipe.png)">
|
|
||||||
<?cs var:ikesa.local.spi ?><br/><br/><br/>
|
|
||||||
<?cs var:ikesa.local.address ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?cs if:ikesa.local.nat == "true" ?>
|
|
||||||
<img title="Local host is behind NAT" src="<?cs var:base ?>/static/router.png"></img>
|
|
||||||
<?cs else ?>
|
|
||||||
<img title="Local host is not NATed" src="<?cs var:base ?>/static/pipe.png"></img>
|
|
||||||
<?cs /if ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?cs if:ikesa.status == "established" ?>
|
|
||||||
<img title="IKE connection <?cs var:ikesa.status ?>" src="<?cs var:base ?>/static/pipe-good.png"></img>
|
|
||||||
<?cs else ?>
|
|
||||||
<img title="IKE connection in state <?cs var:ikesa.status ?>" src="<?cs var:base ?>/static/pipe-bad.png"></img>
|
|
||||||
<?cs /if ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?cs if:ikesa.remote.nat == "true" ?>
|
|
||||||
<img title="Remote host is behind NAT" src="<?cs var:base ?>/static/router.png"></img>
|
|
||||||
<?cs else ?>
|
|
||||||
<img title="Remote host is not NATed" src="<?cs var:base ?>/static/pipe.png"></img>
|
|
||||||
<?cs /if ?>
|
|
||||||
</td>
|
|
||||||
<td class="right" style="background-image:url(<?cs var:base ?>/static/pipe.png)">
|
|
||||||
<?cs var:ikesa.remote.spi ?><br/><br/><br/>
|
|
||||||
<?cs var:ikesa.remote.address ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?cs if:ikesa.role == "responder" ?>
|
|
||||||
<img title="Remote host is the initiator" src="<?cs var:base ?>/static/client-right.png"></img>
|
|
||||||
<?cs else ?>
|
|
||||||
<img title="Remote host is the responder" src="<?cs var:base ?>/static/gateway-right.png"></img>
|
|
||||||
<?cs /if ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?cs each:childsa = ikesa.childsas ?>
|
|
||||||
<tr>
|
|
||||||
<td colspan="6" class="expand">
|
|
||||||
<h1><?cs var:childsa.childconfig ?> [IPsec #<?cs name:childsa ?>]:</h1>
|
|
||||||
</td>
|
|
||||||
<td class="controls">
|
|
||||||
<a title="close CHILD_SA" href="<?cs var:base ?>/control/terminatechild/<?cs name:childsa ?>">
|
|
||||||
<img src="<?cs var:base ?>/static/close.png"/>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="7"><hr/></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="images">
|
|
||||||
<td colspan="2">
|
|
||||||
<?cs each:net = childsa.local.networks ?>
|
|
||||||
<p><?cs var:net ?></p>
|
|
||||||
<?cs /each ?>
|
|
||||||
</td>
|
|
||||||
<td style="background-image:url(<?cs var:base ?>/static/pipe-thin-left-green.png)">
|
|
||||||
<?cs var:childsa.local.spi ?> <-<br/><br/><br/>
|
|
||||||
</td>
|
|
||||||
<td style="background-image:url(<?cs var:base ?>/static/pipe-thin-green.png)">
|
|
||||||
</td>
|
|
||||||
<td class="right" style="background-image:url(<?cs var:base ?>/static/pipe-thin-right-green.png)">
|
|
||||||
-> <?cs var:childsa.remote.spi ?><br/><br/><br/>
|
|
||||||
</td>
|
|
||||||
<td class="right" colspan="2">
|
|
||||||
<?cs each:net = childsa.remote.networks ?>
|
|
||||||
<p><?cs var:net ?></p>
|
|
||||||
<?cs /each ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?cs /each ?>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?cs /each ?>
|
|
||||||
<?cs include:"templates/footer.cs" ?>
|
|
||||||
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 825 B |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 601 B |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 322 B |
|
Before Width: | Height: | Size: 372 B |
|
Before Width: | Height: | Size: 449 B |
|
Before Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 460 B |
|
Before Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 256 B |
|
Before Width: | Height: | Size: 322 B |
|
Before Width: | Height: | Size: 3.2 KiB |
@@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
$(function(){
|
|
||||||
$(".expand > h1").toggle(
|
|
||||||
function(){$(this).parent(".expand").find(".expander").slideUp('fast');},
|
|
||||||
function(){$(this).parent(".expand").find(".expander").slideDown('fast');}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
Before Width: | Height: | Size: 19 KiB |
@@ -1,133 +0,0 @@
|
|||||||
|
|
||||||
body {
|
|
||||||
font-family: Verdana, Helvetica, sans-serif;
|
|
||||||
font-size: .9em;
|
|
||||||
color: #230100;
|
|
||||||
background-color: #f7f4d3;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content > * {
|
|
||||||
background-color: #e5bf5e;
|
|
||||||
border: solid 2px;
|
|
||||||
padding: .2em 1em .2em 1em;
|
|
||||||
margin: 1em;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea, select, input {
|
|
||||||
background-color: #ffec9e;
|
|
||||||
border: 1px solid;
|
|
||||||
padding: 1px 3px 1px 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu {
|
|
||||||
text-align: right;
|
|
||||||
background-color: #e5bf5e;
|
|
||||||
padding: 3px;
|
|
||||||
border-bottom: solid 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: black;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
margin-top: 1em;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
hr {
|
|
||||||
border: solid 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a img {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.expand {
|
|
||||||
}
|
|
||||||
|
|
||||||
.expand h1 {
|
|
||||||
font-size: 1em;
|
|
||||||
cursor: pointer;
|
|
||||||
margin: 0;
|
|
||||||
float: left;
|
|
||||||
padding-top: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.expand h1 span {
|
|
||||||
margin-left: 2em;
|
|
||||||
margin-right: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.expander {
|
|
||||||
clear:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls {
|
|
||||||
margin-top: 3px;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.center {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.left {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight {
|
|
||||||
}
|
|
||||||
|
|
||||||
.fleft {
|
|
||||||
margin-right: 2em;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fright {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cleft {
|
|
||||||
clear:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cright {
|
|
||||||
clear:right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.both {
|
|
||||||
clear:both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawing {
|
|
||||||
border-collapse:collapse
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawing .images {
|
|
||||||
height: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawing .images td {
|
|
||||||
padding: 0px;
|
|
||||||
width: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawing tr .left {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.drawing tr .right {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "xml.h"
|
|
||||||
|
|
||||||
#include <libxml/parser.h>
|
|
||||||
#include <libxml/tree.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct private_xml_t private_xml_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private data of xml
|
|
||||||
*/
|
|
||||||
struct private_xml_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public functions
|
|
||||||
*/
|
|
||||||
xml_t public;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* root node of this xml (part)
|
|
||||||
*/
|
|
||||||
xmlNode *node;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* document, only for root xml_t
|
|
||||||
*/
|
|
||||||
xmlDoc *doc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Root xml_t*
|
|
||||||
*/
|
|
||||||
private_xml_t *root;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* number of enumerator instances
|
|
||||||
*/
|
|
||||||
int enums;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* child element enumerator
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
/** enumerator interface */
|
|
||||||
enumerator_t e;
|
|
||||||
/** current child context (returned to enumerate() caller) */
|
|
||||||
private_xml_t child;
|
|
||||||
/** currently processing node */
|
|
||||||
xmlNode *node;
|
|
||||||
} child_enum_t;
|
|
||||||
|
|
||||||
METHOD(enumerator_t, child_enumerate, bool,
|
|
||||||
child_enum_t *e, va_list args)
|
|
||||||
{
|
|
||||||
private_xml_t **child;
|
|
||||||
char **name, **value;
|
|
||||||
|
|
||||||
VA_ARGS_VGET(args, child, name, value);
|
|
||||||
|
|
||||||
while (e->node && e->node->type != XML_ELEMENT_NODE)
|
|
||||||
{
|
|
||||||
e->node = e->node->next;
|
|
||||||
}
|
|
||||||
if (e->node)
|
|
||||||
{
|
|
||||||
xmlNode *text;
|
|
||||||
|
|
||||||
text = e->node->children;
|
|
||||||
*value = NULL;
|
|
||||||
|
|
||||||
while (text && text->type != XML_TEXT_NODE)
|
|
||||||
{
|
|
||||||
text = text->next;
|
|
||||||
}
|
|
||||||
if (text)
|
|
||||||
{
|
|
||||||
*value = text->content;
|
|
||||||
}
|
|
||||||
*name = (char*)e->node->name;
|
|
||||||
*child = &e->child;
|
|
||||||
e->child.node = e->node->children;
|
|
||||||
e->node = e->node->next;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(xml_t, get_attribute, char*,
|
|
||||||
private_xml_t *this, char *name)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(enumerator_t, child_destroy, void,
|
|
||||||
child_enum_t *this)
|
|
||||||
{
|
|
||||||
if (--this->child.root->enums == 0)
|
|
||||||
{
|
|
||||||
xmlFreeDoc(this->child.root->doc);
|
|
||||||
free(this->child.root);
|
|
||||||
}
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(xml_t, children, enumerator_t*,
|
|
||||||
private_xml_t *this)
|
|
||||||
{
|
|
||||||
child_enum_t *ce;
|
|
||||||
INIT(ce,
|
|
||||||
.e = {
|
|
||||||
.enumerate = enumerator_enumerate_default,
|
|
||||||
.venumerate = _child_enumerate,
|
|
||||||
.destroy = _child_destroy,
|
|
||||||
},
|
|
||||||
.child = {
|
|
||||||
.public = {
|
|
||||||
.get_attribute = _get_attribute,
|
|
||||||
.children = _children,
|
|
||||||
},
|
|
||||||
.doc = this->doc,
|
|
||||||
.root = this->root,
|
|
||||||
},
|
|
||||||
.node = this->node,
|
|
||||||
);
|
|
||||||
this->root->enums++;
|
|
||||||
return &ce->e;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see header file
|
|
||||||
*/
|
|
||||||
xml_t *xml_create(char *xml)
|
|
||||||
{
|
|
||||||
private_xml_t *this;
|
|
||||||
|
|
||||||
INIT(this,
|
|
||||||
.public = {
|
|
||||||
.get_attribute = _get_attribute,
|
|
||||||
.children = _children,
|
|
||||||
},
|
|
||||||
.doc = xmlReadMemory(xml, strlen(xml), NULL, NULL, 0),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!this->doc)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->node = xmlDocGetRootElement(this->doc);
|
|
||||||
this->root = this;
|
|
||||||
|
|
||||||
return &this->public;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 Martin Willi
|
|
||||||
*
|
|
||||||
* Copyright (C) secunet Security Networks AG
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup xml xml
|
|
||||||
* @{ @ingroup manager
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef XML_H_
|
|
||||||
#define XML_H_
|
|
||||||
|
|
||||||
#include <collections/enumerator.h>
|
|
||||||
|
|
||||||
typedef struct xml_t xml_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple enumerator based XML parser.
|
|
||||||
*
|
|
||||||
* An xml_t is a single node of the XML tree, but also serves as root node
|
|
||||||
* and therefore the document.
|
|
||||||
* This object has no destructor, the tree gets destroyed when all enumerator
|
|
||||||
* instances get destroyed.
|
|
||||||
*/
|
|
||||||
struct xml_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an enumerator over all children.
|
|
||||||
*
|
|
||||||
* Enumerated values must not be manipulated or freed.
|
|
||||||
*
|
|
||||||
* @return enumerator over (xml_t* child, char *name, char *value)
|
|
||||||
*/
|
|
||||||
enumerator_t* (*children)(xml_t *this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an attribute value by its name.
|
|
||||||
*
|
|
||||||
* @param name name of the attribute
|
|
||||||
* @return attribute value, NULL if not found
|
|
||||||
*/
|
|
||||||
char *(*get_attribute)(xml_t *this, char *name);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a xml instance.
|
|
||||||
*/
|
|
||||||
xml_t *xml_create(char *xml);
|
|
||||||
|
|
||||||
#endif /** XML_H_ @}*/
|
|
||||||