diff --git a/conf/Makefile.am b/conf/Makefile.am index b36493350..6fefbf630 100644 --- a/conf/Makefile.am +++ b/conf/Makefile.am @@ -20,7 +20,6 @@ options = \ options/imcv.opt \ options/imv_policy_manager.opt \ options/iptfs.opt \ - options/manager.opt \ options/medsrv.opt \ options/pki.opt \ options/pool.opt \ diff --git a/conf/options/manager.opt b/conf/options/manager.opt deleted file mode 100644 index dbac73110..000000000 --- a/conf/options/manager.opt +++ /dev/null @@ -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. diff --git a/configure.ac b/configure.ac index 06d07ee05..9bf20a570 100644 --- a/configure.ac +++ b/configure.ac @@ -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([fuzzing], [enable fuzzing scripts (found in directory fuzz).]) 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([medsrv], [enable mediation server web frontend and daemon plugin.]) 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 fi -if test x$manager = xtrue; then - fast=true -fi - if test x$medsrv = xtrue; then mediation=true fast=true @@ -1534,7 +1529,6 @@ pool_plugins= attest_plugins= pki_plugins= scripts_plugins= -manager_plugins= medsrv_plugins= nm_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([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([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([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([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([x509], [s charon swanctl pki scripts attest nm cmd aikgen fd fc]) ADD_PLUGIN([revocation], [s charon pki nm cmd]) ADD_PLUGIN([constraints], [s charon pki nm cmd]) ADD_PLUGIN([acert], [s charon]) 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([pkcs12], [s charon swanctl pki scripts cmd]) 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([dnscert], [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([openssl], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen fd]) -ADD_PLUGIN([wolfssl], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen]) -ADD_PLUGIN([gcrypt], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen]) -ADD_PLUGIN([botan], [s charon swanctl pki scripts manager medsrv attest nm cmd aikgen]) -ADD_PLUGIN([pkcs8], [s charon swanctl pki scripts manager medsrv attest nm cmd]) +ADD_PLUGIN([openssl], [s charon swanctl pki scripts medsrv attest nm cmd aikgen fd]) +ADD_PLUGIN([wolfssl], [s charon swanctl pki scripts 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 medsrv attest nm cmd aikgen]) +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([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([agent], [s charon nm 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([winhttp], [s charon pki scripts]) ADD_PLUGIN([soup], [s charon pki scripts nm cmd]) -ADD_PLUGIN([mysql], [s charon pki pool manager medsrv attest]) -ADD_PLUGIN([sqlite], [s charon pki pool manager medsrv attest]) +ADD_PLUGIN([mysql], [s charon pki pool medsrv attest]) +ADD_PLUGIN([sqlite], [s charon pki pool medsrv attest]) ADD_PLUGIN([openxpki], [s pki]) ADD_PLUGIN([attr], [c charon]) ADD_PLUGIN([attr-sql], [c charon]) @@ -1695,7 +1689,6 @@ AC_SUBST(pool_plugins) AC_SUBST(attest_plugins) AC_SUBST(pki_plugins) AC_SUBST(scripts_plugins) -AC_SUBST(manager_plugins) AC_SUBST(medsrv_plugins) AC_SUBST(nm_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_LOCK_PROFILER, test x$lock_profiler = 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_INTEGRITY_TEST, test x$integrity_test = 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_IMV_SWIMA], [strongswan_options=${strongswan_options}" sec-updater"]) 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_CMD], [strongswan_options=${strongswan_options}" charon-cmd"]) AM_COND_IF([USE_NM], [strongswan_options=${strongswan_options}" charon-nm"]) @@ -2196,7 +2187,6 @@ AC_CONFIG_FILES([ src/pki/man/Makefile src/pool/Makefile src/libfast/Makefile - src/manager/Makefile src/medsrv/Makefile src/checksum/Makefile src/conftest/Makefile diff --git a/scripts/test.sh b/scripts/test.sh index 630aade59..bc9316e90 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -304,7 +304,7 @@ all|alpine|codeql|coverage|sonarcloud|no-dbg|no-testable-ke) # no TrouSerS either CONFIG="$CONFIG --disable-tss-trousers --disable-aikgen" # and no Clearsilver - CONFIG="$CONFIG --disable-fast --disable-manager --disable-medsrv" + CONFIG="$CONFIG --disable-fast --disable-medsrv" fi if test "$1" = "build-deps"; then build_botan diff --git a/src/Makefile.am b/src/Makefile.am index 8abcbcf67..f74c9010d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -91,10 +91,6 @@ if USE_FAST SUBDIRS += libfast endif -if USE_MANAGER - SUBDIRS += manager -endif - if USE_MEDSRV SUBDIRS += medsrv endif diff --git a/src/manager/.gitignore b/src/manager/.gitignore deleted file mode 100644 index 8081a964f..000000000 --- a/src/manager/.gitignore +++ /dev/null @@ -1 +0,0 @@ -manager.fcgi diff --git a/src/manager/Makefile.am b/src/manager/Makefile.am deleted file mode 100644 index a4f151ca4..000000000 --- a/src/manager/Makefile.am +++ /dev/null @@ -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 diff --git a/src/manager/controller/auth_controller.c b/src/manager/controller/auth_controller.c deleted file mode 100644 index 7550e3f80..000000000 --- a/src/manager/controller/auth_controller.c +++ /dev/null @@ -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 . - * - * 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 - - -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; -} diff --git a/src/manager/controller/auth_controller.h b/src/manager/controller/auth_controller.h deleted file mode 100644 index 2ac120f83..000000000 --- a/src/manager/controller/auth_controller.h +++ /dev/null @@ -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 . - * - * 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 - -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_ @}*/ diff --git a/src/manager/controller/config_controller.c b/src/manager/controller/config_controller.c deleted file mode 100644 index f45fe05f6..000000000 --- a/src/manager/controller/config_controller.c +++ /dev/null @@ -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 . - * - * 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 - -#include - - -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; -} diff --git a/src/manager/controller/config_controller.h b/src/manager/controller/config_controller.h deleted file mode 100644 index 59b60bebe..000000000 --- a/src/manager/controller/config_controller.h +++ /dev/null @@ -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 . - * - * 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 - -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_ @}*/ diff --git a/src/manager/controller/control_controller.c b/src/manager/controller/control_controller.c deleted file mode 100644 index 669a5fc29..000000000 --- a/src/manager/controller/control_controller.c +++ /dev/null @@ -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 . - * - * 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 - -#include - - -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; -} diff --git a/src/manager/controller/control_controller.h b/src/manager/controller/control_controller.h deleted file mode 100644 index 8ca51becb..000000000 --- a/src/manager/controller/control_controller.h +++ /dev/null @@ -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 . - * - * 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 - -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_ @}*/ diff --git a/src/manager/controller/gateway_controller.c b/src/manager/controller/gateway_controller.c deleted file mode 100644 index 7eeeb39b2..000000000 --- a/src/manager/controller/gateway_controller.c +++ /dev/null @@ -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 . - * - * 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 - - -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; -} diff --git a/src/manager/controller/gateway_controller.h b/src/manager/controller/gateway_controller.h deleted file mode 100644 index 69c877df9..000000000 --- a/src/manager/controller/gateway_controller.h +++ /dev/null @@ -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 . - * - * 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 - -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_ @}*/ diff --git a/src/manager/controller/ikesa_controller.c b/src/manager/controller/ikesa_controller.c deleted file mode 100644 index 698467549..000000000 --- a/src/manager/controller/ikesa_controller.c +++ /dev/null @@ -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 . - * - * 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 - -#include - - -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; -} diff --git a/src/manager/controller/ikesa_controller.h b/src/manager/controller/ikesa_controller.h deleted file mode 100644 index 8d6a82617..000000000 --- a/src/manager/controller/ikesa_controller.h +++ /dev/null @@ -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 . - * - * 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 - -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_ @}*/ diff --git a/src/manager/gateway.c b/src/manager/gateway.c deleted file mode 100644 index 4bb6d857a..000000000 --- a/src/manager/gateway.c +++ /dev/null @@ -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 . - * - * 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 -#include -#include -#include -#include -#include - -#include - -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, "" - "" - "" - "" - "", 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, "" - "" - "" - "" - "", 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, "" - "" - "<%ssainitiate>%s" - "" - "", 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, "" - "" - "<%ssaterminate>%d" - "" - "", 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; -} - diff --git a/src/manager/gateway.h b/src/manager/gateway.h deleted file mode 100644 index 529805a30..000000000 --- a/src/manager/gateway.h +++ /dev/null @@ -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 . - * - * 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 -#include - -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_ @}*/ diff --git a/src/manager/main.c b/src/manager/main.c deleted file mode 100644 index d4b3b917d..000000000 --- a/src/manager/main.c +++ /dev/null @@ -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 . - * - * 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 -#include -#include - -#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; -} diff --git a/src/manager/make-debug b/src/manager/make-debug deleted file mode 100755 index c1093a138..000000000 --- a/src/manager/make-debug +++ /dev/null @@ -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 diff --git a/src/manager/manager.c b/src/manager/manager.c deleted file mode 100644 index 14e80e390..000000000 --- a/src/manager/manager.c +++ /dev/null @@ -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 . - * - * 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 - -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; -} diff --git a/src/manager/manager.h b/src/manager/manager.h deleted file mode 100644 index 76fae32f8..000000000 --- a/src/manager/manager.h +++ /dev/null @@ -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 . - * - * 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 - -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_ @}*/ diff --git a/src/manager/sqlite.sql b/src/manager/sqlite.sql deleted file mode 100644 index c60025e0e..000000000 --- a/src/manager/sqlite.sql +++ /dev/null @@ -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 -); diff --git a/src/manager/storage.c b/src/manager/storage.c deleted file mode 100644 index 55580956b..000000000 --- a/src/manager/storage.c +++ /dev/null @@ -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 . - * - * 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 -#include - - -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; -} - diff --git a/src/manager/storage.h b/src/manager/storage.h deleted file mode 100644 index cb60a90a1..000000000 --- a/src/manager/storage.h +++ /dev/null @@ -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 . - * - * 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 - - -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_ @}*/ diff --git a/src/manager/templates/auth/login.cs b/src/manager/templates/auth/login.cs deleted file mode 100644 index 49a8ec6e0..000000000 --- a/src/manager/templates/auth/login.cs +++ /dev/null @@ -1,17 +0,0 @@ - -
-
- - - - - - - - - - -
Username
Password
-
-
- diff --git a/src/manager/templates/config/list.cs b/src/manager/templates/config/list.cs deleted file mode 100644 index 547a4aee7..000000000 --- a/src/manager/templates/config/list.cs +++ /dev/null @@ -1,104 +0,0 @@ - - -
-

: - <-> - -

-
- - - - - -   - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - - - - 0123456789abdcef


- -
- - - - - - - 0123456789abcdef


- -
- - - - - -
-

:

-
- - - - - -

- -

- -
-


-
- -


-
- -

- -
-
-
- - diff --git a/src/manager/templates/control/result.cs b/src/manager/templates/control/result.cs deleted file mode 100644 index 1d59df65f..000000000 --- a/src/manager/templates/control/result.cs +++ /dev/null @@ -1,14 +0,0 @@ - -
-

-
 
-
-
-
    - -
  • - -
-
-
- diff --git a/src/manager/templates/error.cs b/src/manager/templates/error.cs deleted file mode 100644 index be9b1a3a1..000000000 --- a/src/manager/templates/error.cs +++ /dev/null @@ -1,3 +0,0 @@ - -
- diff --git a/src/manager/templates/footer.cs b/src/manager/templates/footer.cs deleted file mode 100644 index 9b151ee89..000000000 --- a/src/manager/templates/footer.cs +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/manager/templates/gateway/list.cs b/src/manager/templates/gateway/list.cs deleted file mode 100644 index b93364d6f..000000000 --- a/src/manager/templates/gateway/list.cs +++ /dev/null @@ -1,15 +0,0 @@ - -
-
-

- -

- -

-

-
- diff --git a/src/manager/templates/header.cs b/src/manager/templates/header.cs deleted file mode 100644 index 5d174c4c8..000000000 --- a/src/manager/templates/header.cs +++ /dev/null @@ -1,26 +0,0 @@ - - - - <?cs var:title ?> - strongSwan Manager - - - - - -
- - - -

strongSwan Manager

-

-
- -
-
-
diff --git a/src/manager/templates/ikesa/list.cs b/src/manager/templates/ikesa/list.cs deleted file mode 100644 index 88a88c175..000000000 --- a/src/manager/templates/ikesa/list.cs +++ /dev/null @@ -1,111 +0,0 @@ - - -
-

- [IKE #]: - <-> - -

-
- - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - - - -


- -
- - - - - - - - - - - - - - - - - - -


- -
- - - - - -
-

[IPsec #]:

-
- - - -

- -

- -
- <-


-
- - ->


-
- -

- -
-
-
- - diff --git a/src/manager/templates/static/client-left.png b/src/manager/templates/static/client-left.png deleted file mode 100644 index 8a082ff9e..000000000 Binary files a/src/manager/templates/static/client-left.png and /dev/null differ diff --git a/src/manager/templates/static/client-right.png b/src/manager/templates/static/client-right.png deleted file mode 100644 index c841eebaf..000000000 Binary files a/src/manager/templates/static/client-right.png and /dev/null differ diff --git a/src/manager/templates/static/close.png b/src/manager/templates/static/close.png deleted file mode 100644 index 7cb058d69..000000000 Binary files a/src/manager/templates/static/close.png and /dev/null differ diff --git a/src/manager/templates/static/gateway-left.png b/src/manager/templates/static/gateway-left.png deleted file mode 100644 index 9ddd3624d..000000000 Binary files a/src/manager/templates/static/gateway-left.png and /dev/null differ diff --git a/src/manager/templates/static/gateway-right.png b/src/manager/templates/static/gateway-right.png deleted file mode 100644 index 0be446827..000000000 Binary files a/src/manager/templates/static/gateway-right.png and /dev/null differ diff --git a/src/manager/templates/static/initiate.png b/src/manager/templates/static/initiate.png deleted file mode 100644 index 4463e3b7a..000000000 Binary files a/src/manager/templates/static/initiate.png and /dev/null differ diff --git a/src/manager/templates/static/jquery.js b/src/manager/templates/static/jquery.js deleted file mode 100644 index 7aaed5e4d..000000000 --- a/src/manager/templates/static/jquery.js +++ /dev/null @@ -1,2965 +0,0 @@ -(function(){ -/* - * jQuery 1.2 - New Wave Javascript - * - * Copyright (c) 2007 John Resig (jquery.com) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * $Date: 2007-09-10 15:45:49 -0400 (Mon, 10 Sep 2007) $ - * $Rev: 3219 $ - */ - -// Map over jQuery in case of overwrite -if ( typeof jQuery != "undefined" ) - var _jQuery = jQuery; - -var jQuery = window.jQuery = function(a,c) { - // If the context is global, return a new object - if ( window == this || !this.init ) - return new jQuery(a,c); - - return this.init(a,c); -}; - -// Map over the $ in case of overwrite -if ( typeof $ != "undefined" ) - var _$ = $; - -// Map the jQuery namespace to the '$' one -window.$ = jQuery; - -var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; - -jQuery.fn = jQuery.prototype = { - init: function(a,c) { - // Make sure that a selection was provided - a = a || document; - - // Handle HTML strings - if ( typeof a == "string" ) { - var m = quickExpr.exec(a); - if ( m && (m[1] || !c) ) { - // HANDLE: $(html) -> $(array) - if ( m[1] ) - a = jQuery.clean( [ m[1] ], c ); - - // HANDLE: $("#id") - else { - var tmp = document.getElementById( m[3] ); - if ( tmp ) - // Handle the case where IE and Opera return items - // by name instead of ID - if ( tmp.id != m[3] ) - return jQuery().find( a ); - else { - this[0] = tmp; - this.length = 1; - return this; - } - else - a = []; - } - - // HANDLE: $(expr) - } else - return new jQuery( c ).find( a ); - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction(a) ) - return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a ); - - return this.setArray( - // HANDLE: $(array) - a.constructor == Array && a || - - // HANDLE: $(arraylike) - // Watch for when an array-like object is passed as the selector - (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) || - - // HANDLE: $(*) - [ a ] ); - }, - - jquery: "1.2", - - size: function() { - return this.length; - }, - - length: 0, - - get: function( num ) { - return num == undefined ? - - // Return a 'clean' array - jQuery.makeArray( this ) : - - // Return just the object - this[num]; - }, - - pushStack: function( a ) { - var ret = jQuery(a); - ret.prevObject = this; - return ret; - }, - - setArray: function( a ) { - this.length = 0; - Array.prototype.push.apply( this, a ); - return this; - }, - - each: function( fn, args ) { - return jQuery.each( this, fn, args ); - }, - - index: function( obj ) { - var pos = -1; - this.each(function(i){ - if ( this == obj ) pos = i; - }); - return pos; - }, - - attr: function( key, value, type ) { - var obj = key; - - // Look for the case where we're accessing a style value - if ( key.constructor == String ) - if ( value == undefined ) - return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined; - else { - obj = {}; - obj[ key ] = value; - } - - // Check to see if we're setting style values - return this.each(function(index){ - // Set all the styles - for ( var prop in obj ) - jQuery.attr( - type ? this.style : this, - prop, jQuery.prop(this, obj[prop], type, index, prop) - ); - }); - }, - - css: function( key, value ) { - return this.attr( key, value, "curCSS" ); - }, - - text: function(e) { - if ( typeof e != "object" && e != null ) - return this.empty().append( document.createTextNode( e ) ); - - var t = ""; - jQuery.each( e || this, function(){ - jQuery.each( this.childNodes, function(){ - if ( this.nodeType != 8 ) - t += this.nodeType != 1 ? - this.nodeValue : jQuery.fn.text([ this ]); - }); - }); - return t; - }, - - wrapAll: function(html) { - if ( this[0] ) - // The elements to wrap the target around - jQuery(html, this[0].ownerDocument) - .clone() - .insertBefore(this[0]) - .map(function(){ - var elem = this; - while ( elem.firstChild ) - elem = elem.firstChild; - return elem; - }) - .append(this); - - return this; - }, - - wrapInner: function(html) { - return this.each(function(){ - jQuery(this).contents().wrapAll(html); - }); - }, - - wrap: function(html) { - return this.each(function(){ - jQuery(this).wrapAll(html); - }); - }, - - append: function() { - return this.domManip(arguments, true, 1, function(a){ - this.appendChild( a ); - }); - }, - - prepend: function() { - return this.domManip(arguments, true, -1, function(a){ - this.insertBefore( a, this.firstChild ); - }); - }, - - before: function() { - return this.domManip(arguments, false, 1, function(a){ - this.parentNode.insertBefore( a, this ); - }); - }, - - after: function() { - return this.domManip(arguments, false, -1, function(a){ - this.parentNode.insertBefore( a, this.nextSibling ); - }); - }, - - end: function() { - return this.prevObject || jQuery([]); - }, - - find: function(t) { - var data = jQuery.map(this, function(a){ return jQuery.find(t,a); }); - return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ? - jQuery.unique( data ) : data ); - }, - - clone: function(events) { - // Do the clone - var ret = this.map(function(){ - return this.outerHTML ? jQuery(this.outerHTML)[0] : this.cloneNode(true); - }); - - if (events === true) { - var clone = ret.find("*").andSelf(); - - this.find("*").andSelf().each(function(i) { - var events = jQuery.data(this, "events"); - for ( var type in events ) - for ( var handler in events[type] ) - jQuery.event.add(clone[i], type, events[type][handler], events[type][handler].data); - }); - } - - // Return the cloned set - return ret; - }, - - filter: function(t) { - return this.pushStack( - jQuery.isFunction( t ) && - jQuery.grep(this, function(el, index){ - return t.apply(el, [index]); - }) || - - jQuery.multiFilter(t,this) ); - }, - - not: function(t) { - return this.pushStack( - t.constructor == String && - jQuery.multiFilter(t, this, true) || - - jQuery.grep(this, function(a) { - return ( t.constructor == Array || t.jquery ) - ? jQuery.inArray( a, t ) < 0 - : a != t; - }) - ); - }, - - add: function(t) { - return this.pushStack( jQuery.merge( - this.get(), - t.constructor == String ? - jQuery(t).get() : - t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ? - t : [t] ) - ); - }, - - is: function(expr) { - return expr ? jQuery.multiFilter(expr,this).length > 0 : false; - }, - - hasClass: function(expr) { - return this.is("." + expr); - }, - - val: function( val ) { - if ( val == undefined ) { - if ( this.length ) { - var elem = this[0]; - - // We need to handle select boxes special - if ( jQuery.nodeName(elem, "select") ) { - var index = elem.selectedIndex, - a = [], - options = elem.options, - one = elem.type == "select-one"; - - // Nothing was selected - if ( index < 0 ) - return null; - - // Loop through all the selected options - for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { - var option = options[i]; - if ( option.selected ) { - // Get the specific value for the option - var val = jQuery.browser.msie && !option.attributes["value"].specified ? option.text : option.value; - - // We don't need an array for one selects - if ( one ) - return val; - - // Multi-Selects return an array - a.push(val); - } - } - - return a; - - // Everything else, we just grab the value - } else - return this[0].value.replace(/\r/g, ""); - } - } else - return this.each(function(){ - if ( val.constructor == Array && /radio|checkbox/.test(this.type) ) - this.checked = (jQuery.inArray(this.value, val) >= 0 || - jQuery.inArray(this.name, val) >= 0); - else if ( jQuery.nodeName(this, "select") ) { - var tmp = val.constructor == Array ? val : [val]; - - jQuery("option", this).each(function(){ - this.selected = (jQuery.inArray(this.value, tmp) >= 0 || - jQuery.inArray(this.text, tmp) >= 0); - }); - - if ( !tmp.length ) - this.selectedIndex = -1; - } else - this.value = val; - }); - }, - - html: function( val ) { - return val == undefined ? - ( this.length ? this[0].innerHTML : null ) : - this.empty().append( val ); - }, - - replaceWith: function( val ) { - return this.after( val ).remove(); - }, - - slice: function() { - return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); - }, - - map: function(fn) { - return this.pushStack(jQuery.map( this, function(elem,i){ - return fn.call( elem, i, elem ); - })); - }, - - andSelf: function() { - return this.add( this.prevObject ); - }, - - domManip: function(args, table, dir, fn) { - var clone = this.length > 1, a; - - return this.each(function(){ - if ( !a ) { - a = jQuery.clean(args, this.ownerDocument); - if ( dir < 0 ) - a.reverse(); - } - - var obj = this; - - if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") ) - obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody")); - - jQuery.each( a, function(){ - if ( jQuery.nodeName(this, "script") ) { - if ( this.src ) - jQuery.ajax({ url: this.src, async: false, dataType: "script" }); - else - jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" ); - } else - fn.apply( obj, [ clone ? this.cloneNode(true) : this ] ); - }); - }); - } -}; - -jQuery.extend = jQuery.fn.extend = function() { - // copy reference to target object - var target = arguments[0] || {}, a = 1, al = arguments.length, deep = false; - - // Handle a deep copy situation - if ( target.constructor == Boolean ) { - deep = target; - target = arguments[1] || {}; - } - - // extend jQuery itself if only one argument is passed - if ( al == 1 ) { - target = this; - a = 0; - } - - var prop; - - for ( ; a < al; a++ ) - // Only deal with non-null/undefined values - if ( (prop = arguments[a]) != null ) - // Extend the base object - for ( var i in prop ) { - // Prevent never-ending loop - if ( target == prop[i] ) - continue; - - // Recurse if we're merging object values - if ( deep && typeof prop[i] == 'object' && target[i] ) - jQuery.extend( target[i], prop[i] ); - - // Don't bring in undefined values - else if ( prop[i] != undefined ) - target[i] = prop[i]; - } - - // Return the modified object - return target; -}; - -var expando = "jQuery" + (new Date()).getTime(), uuid = 0, win = {}; - -jQuery.extend({ - noConflict: function(deep) { - window.$ = _$; - if ( deep ) - window.jQuery = _jQuery; - return jQuery; - }, - - // This may seem like some crazy code, but trust me when I say that this - // is the only cross-browser way to do this. --John - isFunction: function( fn ) { - return !!fn && typeof fn != "string" && !fn.nodeName && - fn.constructor != Array && /function/i.test( fn + "" ); - }, - - // check if an element is in a XML document - isXMLDoc: function(elem) { - return elem.documentElement && !elem.body || - elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; - }, - - // Evaluates a script in a global context - // Evaluates Async. in Safari 2 :-( - globalEval: function( data ) { - data = jQuery.trim( data ); - if ( data ) { - if ( window.execScript ) - window.execScript( data ); - else if ( jQuery.browser.safari ) - // safari doesn't provide a synchronous global eval - window.setTimeout( data, 0 ); - else - eval.call( window, data ); - } - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); - }, - - cache: {}, - - data: function( elem, name, data ) { - elem = elem == window ? win : elem; - - var id = elem[ expando ]; - - // Compute a unique ID for the element - if ( !id ) - id = elem[ expando ] = ++uuid; - - // Only generate the data cache if we're - // trying to access or manipulate it - if ( name && !jQuery.cache[ id ] ) - jQuery.cache[ id ] = {}; - - // Prevent overriding the named cache with undefined values - if ( data != undefined ) - jQuery.cache[ id ][ name ] = data; - - // Return the named cache data, or the ID for the element - return name ? jQuery.cache[ id ][ name ] : id; - }, - - removeData: function( elem, name ) { - elem = elem == window ? win : elem; - - var id = elem[ expando ]; - - // If we want to remove a specific section of the element's data - if ( name ) { - if ( jQuery.cache[ id ] ) { - // Remove the section of cache data - delete jQuery.cache[ id ][ name ]; - - // If we've removed all the data, remove the element's cache - name = ""; - for ( name in jQuery.cache[ id ] ) break; - if ( !name ) - jQuery.removeData( elem ); - } - - // Otherwise, we want to remove all of the element's data - } else { - // Clean up the element expando - try { - delete elem[ expando ]; - } catch(e){ - // IE has trouble directly removing the expando - // but it's ok with using removeAttribute - if ( elem.removeAttribute ) - elem.removeAttribute( expando ); - } - - // Completely remove the data cache - delete jQuery.cache[ id ]; - } - }, - - // args is for internal usage only - each: function( obj, fn, args ) { - if ( args ) { - if ( obj.length == undefined ) - for ( var i in obj ) - fn.apply( obj[i], args ); - else - for ( var i = 0, ol = obj.length; i < ol; i++ ) - if ( fn.apply( obj[i], args ) === false ) break; - - // A special, fast, case for the most common use of each - } else { - if ( obj.length == undefined ) - for ( var i in obj ) - fn.call( obj[i], i, obj[i] ); - else - for ( var i = 0, ol = obj.length, val = obj[0]; - i < ol && fn.call(val,i,val) !== false; val = obj[++i] ){} - } - - return obj; - }, - - prop: function(elem, value, type, index, prop){ - // Handle executable functions - if ( jQuery.isFunction( value ) ) - value = value.call( elem, [index] ); - - // exclude the following css properties to add px - var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; - - // Handle passing in a number to a CSS property - return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ? - value + "px" : - value; - }, - - className: { - // internal only, use addClass("class") - add: function( elem, c ){ - jQuery.each( (c || "").split(/\s+/), function(i, cur){ - if ( !jQuery.className.has( elem.className, cur ) ) - elem.className += ( elem.className ? " " : "" ) + cur; - }); - }, - - // internal only, use removeClass("class") - remove: function( elem, c ){ - elem.className = c != undefined ? - jQuery.grep( elem.className.split(/\s+/), function(cur){ - return !jQuery.className.has( c, cur ); - }).join(" ") : ""; - }, - - // internal only, use is(".class") - has: function( t, c ) { - return jQuery.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1; - } - }, - - swap: function(e,o,f) { - for ( var i in o ) { - e.style["old"+i] = e.style[i]; - e.style[i] = o[i]; - } - f.apply( e, [] ); - for ( var i in o ) - e.style[i] = e.style["old"+i]; - }, - - css: function(e,p) { - if ( p == "height" || p == "width" ) { - var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"]; - - jQuery.each( d, function(){ - old["padding" + this] = 0; - old["border" + this + "Width"] = 0; - }); - - jQuery.swap( e, old, function() { - if ( jQuery(e).is(':visible') ) { - oHeight = e.offsetHeight; - oWidth = e.offsetWidth; - } else { - e = jQuery(e.cloneNode(true)) - .find(":radio").removeAttr("checked").end() - .css({ - visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0" - }).appendTo(e.parentNode)[0]; - - var parPos = jQuery.css(e.parentNode,"position") || "static"; - if ( parPos == "static" ) - e.parentNode.style.position = "relative"; - - oHeight = e.clientHeight; - oWidth = e.clientWidth; - - if ( parPos == "static" ) - e.parentNode.style.position = "static"; - - e.parentNode.removeChild(e); - } - }); - - return p == "height" ? oHeight : oWidth; - } - - return jQuery.curCSS( e, p ); - }, - - curCSS: function(elem, prop, force) { - var ret, stack = [], swap = []; - - // A helper method for determining if an element's values are broken - function color(a){ - if ( !jQuery.browser.safari ) - return false; - - var ret = document.defaultView.getComputedStyle(a,null); - return !ret || ret.getPropertyValue("color") == ""; - } - - if (prop == "opacity" && jQuery.browser.msie) { - ret = jQuery.attr(elem.style, "opacity"); - return ret == "" ? "1" : ret; - } - - if (prop.match(/float/i)) - prop = styleFloat; - - if (!force && elem.style[prop]) - ret = elem.style[prop]; - - else if (document.defaultView && document.defaultView.getComputedStyle) { - - if (prop.match(/float/i)) - prop = "float"; - - prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase(); - var cur = document.defaultView.getComputedStyle(elem, null); - - if ( cur && !color(elem) ) - ret = cur.getPropertyValue(prop); - - // If the element isn't reporting its values properly in Safari - // then some display: none elements are involved - else { - // Locate all of the parent display: none elements - for ( var a = elem; a && color(a); a = a.parentNode ) - stack.unshift(a); - - // Go through and make them visible, but in reverse - // (It would be better if we knew the exact display type that they had) - for ( a = 0; a < stack.length; a++ ) - if ( color(stack[a]) ) { - swap[a] = stack[a].style.display; - stack[a].style.display = "block"; - } - - // Since we flip the display style, we have to handle that - // one special, otherwise get the value - ret = prop == "display" && swap[stack.length-1] != null ? - "none" : - document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) || ""; - - // Finally, revert the display styles back - for ( a = 0; a < swap.length; a++ ) - if ( swap[a] != null ) - stack[a].style.display = swap[a]; - } - - if ( prop == "opacity" && ret == "" ) - ret = "1"; - - } else if (elem.currentStyle) { - var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();}); - ret = elem.currentStyle[prop] || elem.currentStyle[newProp]; - - // From the awesome hack by Dean Edwards - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 - - // If we're not dealing with a regular pixel number - // but a number that has a weird ending, we need to convert it to pixels - if ( !/^\d+(px)?$/i.test(ret) && /^\d/.test(ret) ) { - var style = elem.style.left; - var runtimeStyle = elem.runtimeStyle.left; - elem.runtimeStyle.left = elem.currentStyle.left; - elem.style.left = ret || 0; - ret = elem.style.pixelLeft + "px"; - elem.style.left = style; - elem.runtimeStyle.left = runtimeStyle; - } - } - - return ret; - }, - - clean: function(a, doc) { - var r = []; - doc = doc || document; - - jQuery.each( a, function(i,arg){ - if ( !arg ) return; - - if ( arg.constructor == Number ) - arg = arg.toString(); - - // Convert html string into DOM nodes - if ( typeof arg == "string" ) { - // Fix "XHTML"-style tags in all browsers - arg = arg.replace(/(<(\w+)[^>]*?)\/>/g, function(m, all, tag){ - return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i)? m : all+">"; - }); - - // Trim whitespace, otherwise indexOf won't work as expected - var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = []; - - var wrap = - // option or optgroup - !s.indexOf("", ""] || - - !s.indexOf("", ""] || - - s.match(/^<(thead|tbody|tfoot|colg|cap)/) && - [1, "", "
"] || - - !s.indexOf("", ""] || - - // matched above - (!s.indexOf("", ""] || - - !s.indexOf("", ""] || - - // IE can't serialize and