diff options
Diffstat (limited to 'src/medsrv')
-rw-r--r-- | src/medsrv/Makefile.am | 2 | ||||
-rw-r--r-- | src/medsrv/Makefile.in | 11 | ||||
-rwxr-xr-x | src/medsrv/controller/peer_controller.c | 41 | ||||
-rwxr-xr-x | src/medsrv/controller/user_controller.c | 46 | ||||
-rwxr-xr-x | src/medsrv/filter/auth_filter.c | 137 | ||||
-rwxr-xr-x | src/medsrv/filter/auth_filter.h | 90 | ||||
-rw-r--r-- | src/medsrv/user.c | 34 |
7 files changed, 183 insertions, 178 deletions
diff --git a/src/medsrv/Makefile.am b/src/medsrv/Makefile.am index 171b086cf..43da9c4e5 100644 --- a/src/medsrv/Makefile.am +++ b/src/medsrv/Makefile.am @@ -7,7 +7,7 @@ main.c filter/auth_filter.c filter/auth_filter.h \ controller/user_controller.c controller/user_controller.h \ controller/peer_controller.c controller/peer_controller.h -medsrv_fcgi_LDADD = $(top_srcdir)/src/libstrongswan/libstrongswan.la $(top_builddir)/src/libfast/libfast.la +medsrv_fcgi_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(top_builddir)/src/libfast/libfast.la main.o : $(top_builddir)/config.status INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libfast diff --git a/src/medsrv/Makefile.in b/src/medsrv/Makefile.in index 99a8cc135..95f02c580 100644 --- a/src/medsrv/Makefile.in +++ b/src/medsrv/Makefile.in @@ -64,7 +64,7 @@ am_medsrv_fcgi_OBJECTS = user.$(OBJEXT) main.$(OBJEXT) \ peer_controller.$(OBJEXT) medsrv_fcgi_OBJECTS = $(am_medsrv_fcgi_OBJECTS) medsrv_fcgi_DEPENDENCIES = \ - $(top_srcdir)/src/libstrongswan/libstrongswan.la \ + $(top_builddir)/src/libstrongswan/libstrongswan.la \ $(top_builddir)/src/libfast/libfast.la DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -198,6 +198,9 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +attest_plugins = @attest_plugins@ +axis2c_CFLAGS = @axis2c_CFLAGS@ +axis2c_LIBS = @axis2c_LIBS@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -206,6 +209,7 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ c_plugins = @c_plugins@ +clearsilver_LIBS = @clearsilver_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ dbusservicedir = @dbusservicedir@ @@ -222,11 +226,13 @@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ +imcvdir = @imcvdir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ ipsecdir = @ipsecdir@ ipsecgroup = @ipsecgroup@ +ipseclibdir = @ipseclibdir@ ipsecuser = @ipsecuser@ libcharon_plugins = @libcharon_plugins@ libdir = @libdir@ @@ -270,6 +276,7 @@ sharedstatedir = @sharedstatedir@ soup_CFLAGS = @soup_CFLAGS@ soup_LIBS = @soup_LIBS@ srcdir = @srcdir@ +starter_plugins = @starter_plugins@ strongswan_conf = @strongswan_conf@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ @@ -286,7 +293,7 @@ main.c filter/auth_filter.c filter/auth_filter.h \ controller/user_controller.c controller/user_controller.h \ controller/peer_controller.c controller/peer_controller.h -medsrv_fcgi_LDADD = $(top_srcdir)/src/libstrongswan/libstrongswan.la $(top_builddir)/src/libfast/libfast.la +medsrv_fcgi_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(top_builddir)/src/libfast/libfast.la INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libfast AM_CFLAGS = -rdynamic \ -DIPSECDIR=\"${ipsecdir}\" \ diff --git a/src/medsrv/controller/peer_controller.c b/src/medsrv/controller/peer_controller.c index 5948fcfb7..edcf653b2 100755 --- a/src/medsrv/controller/peer_controller.c +++ b/src/medsrv/controller/peer_controller.c @@ -312,19 +312,15 @@ static void delete(private_peer_controller_t *this, request_t *request, int id) DB_INT, id, DB_UINT, this->user->get_user(this->user)); } -/** - * Implementation of controller_t.get_name - */ -static char* get_name(private_peer_controller_t *this) +METHOD(controller_t, get_name, char*, + private_peer_controller_t *this) { return "peer"; } -/** - * Implementation of controller_t.handle - */ -static void handle(private_peer_controller_t *this, request_t *request, - char *action, char *idstr) +METHOD(controller_t, handle, void, + private_peer_controller_t *this, request_t *request, char *action, + char *idstr, char *p3, char *p4, char *p5) { if (action) { @@ -354,10 +350,8 @@ static void handle(private_peer_controller_t *this, request_t *request, request->redirect(request, "peer/list"); } -/** - * Implementation of controller_t.destroy - */ -static void destroy(private_peer_controller_t *this) +METHOD(controller_t, destroy, void, + private_peer_controller_t *this) { free(this); } @@ -367,14 +361,19 @@ static void destroy(private_peer_controller_t *this) */ controller_t *peer_controller_create(user_t *user, database_t *db) { - private_peer_controller_t *this= malloc_thing(private_peer_controller_t); - - this->public.controller.get_name = (char*(*)(controller_t*))get_name; - this->public.controller.handle = (void(*)(controller_t*, request_t*, char*, char*, char*, char*, char*))handle; - this->public.controller.destroy = (void(*)(controller_t*))destroy; - - this->user = user; - this->db = db; + private_peer_controller_t *this; + + INIT(this, + .public = { + .controller = { + .get_name = _get_name, + .handle = _handle, + .destroy = _destroy, + }, + }, + .user = user, + .db = db, + ); return &this->public.controller; } diff --git a/src/medsrv/controller/user_controller.c b/src/medsrv/controller/user_controller.c index 0f25799d8..12bd938fe 100755 --- a/src/medsrv/controller/user_controller.c +++ b/src/medsrv/controller/user_controller.c @@ -44,7 +44,7 @@ struct private_user_controller_t { user_t *user; /** - * minimum required password lenght + * minimum required password length */ u_int password_length; }; @@ -293,18 +293,15 @@ static void edit(private_user_controller_t *this, request_t *request) request->render(request, "templates/user/edit.cs"); } -/** - * Implementation of controller_t.get_name - */ -static char* get_name(private_user_controller_t *this) +METHOD(controller_t, get_name, char*, + private_user_controller_t *this) { return "user"; } -/** - * Implementation of controller_t.handle - */ -static void handle(private_user_controller_t *this, request_t *request, char *action) +METHOD(controller_t, handle, void, + private_user_controller_t *this, request_t *request, char *action, + char *p2, char *p3, char *p4, char *p5) { if (action) { @@ -332,10 +329,8 @@ static void handle(private_user_controller_t *this, request_t *request, char *ac request->redirect(request, "user/login"); } -/** - * Implementation of controller_t.destroy - */ -static void destroy(private_user_controller_t *this) +METHOD(controller_t, destroy, void, + private_user_controller_t *this) { free(this); } @@ -345,16 +340,21 @@ static void destroy(private_user_controller_t *this) */ controller_t *user_controller_create(user_t *user, database_t *db) { - private_user_controller_t *this= malloc_thing(private_user_controller_t); - - this->public.controller.get_name = (char*(*)(controller_t*))get_name; - this->public.controller.handle = (void(*)(controller_t*, request_t*, char*, char*, char*, char*, char*))handle; - this->public.controller.destroy = (void(*)(controller_t*))destroy; - - this->user = user; - this->db = db; - this->password_length = lib->settings->get_int(lib->settings, - "medsrv.password_length", 6); + private_user_controller_t *this; + + INIT(this, + .public = { + .controller = { + .get_name = _get_name, + .handle = _handle, + .destroy = _destroy, + }, + }, + .user = user, + .db = db, + .password_length = lib->settings->get_int(lib->settings, + "medsrv.password_length", 6), + ); return &this->public.controller; } diff --git a/src/medsrv/filter/auth_filter.c b/src/medsrv/filter/auth_filter.c index 9ed356042..d21abdc46 100755 --- a/src/medsrv/filter/auth_filter.c +++ b/src/medsrv/filter/auth_filter.c @@ -1,50 +1,48 @@ /* - * Copyright (C) 2008 Martin Willi
- * Copyright (C) 2008 Philip Boetschi, Adrian Doerig
- * Hochschule fuer Technik Rapperswil
- *
- * 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_filter.h"
-
-#include <debug.h>
-
-typedef struct private_auth_filter_t private_auth_filter_t;
-
-/**
- * private data of auth_filter
- */
-struct private_auth_filter_t {
- /**
- * public functions
- */
- auth_filter_t public;
-
- /**
- * user session
- */
+ * Copyright (C) 2008 Martin Willi + * Copyright (C) 2008 Philip Boetschi, Adrian Doerig + * Hochschule fuer Technik Rapperswil + * + * 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_filter.h" + +#include <debug.h> + +typedef struct private_auth_filter_t private_auth_filter_t; + +/** + * private data of auth_filter + */ +struct private_auth_filter_t { + /** + * public functions + */ + auth_filter_t public; + + /** + * user session + */ user_t *user; /** * database connection */ - database_t *db;
+ database_t *db; }; -
-/**
- * Implementation of filter_t.run
- */
-static bool run(private_auth_filter_t *this, request_t *request, - char *controller, char *action)
+ +METHOD(filter_t, run, bool, + private_auth_filter_t *this, request_t *request, char *controller, + char *action, char *p2, char *p3, char *p4, char *p5) { if (this->user->get_user(this->user)) { @@ -67,32 +65,35 @@ static bool run(private_auth_filter_t *this, request_t *request, (streq(action, "add") || streq(action, "login") || streq(action, "help"))) { /* add/login allowed */ return TRUE; - }
- request->redirect(request, "user/login");
- return FALSE;
-}
-
-/**
- * Implementation of filter_t.destroy
- */
-static void destroy(private_auth_filter_t *this)
-{
- free(this);
-}
-
-/*
- * see header file
- */
-filter_t *auth_filter_create(user_t *user, database_t *db)
-{
- private_auth_filter_t *this= malloc_thing(private_auth_filter_t);
-
- this->public.filter.destroy = (void(*)(filter_t*))destroy;
- this->public.filter.run = (bool(*)(filter_t*, request_t*,char*,char*,char*,char*,char*,char*))run;
-
- this->user = user; - this->db = db;
-
- return &this->public.filter;
-}
+ } + request->redirect(request, "user/login"); + return FALSE; +} + +METHOD(filter_t, destroy, void, + private_auth_filter_t *this) +{ + free(this); +} + +/* + * see header file + */ +filter_t *auth_filter_create(user_t *user, database_t *db) +{ + private_auth_filter_t *this; + + INIT(this, + .public = { + .filter = { + .destroy = _destroy, + .run = _run, + }, + }, + .user = user, + .db = db, + ); + + return &this->public.filter; +} diff --git a/src/medsrv/filter/auth_filter.h b/src/medsrv/filter/auth_filter.h index f1fc565eb..c46de40a5 100755 --- a/src/medsrv/filter/auth_filter.h +++ b/src/medsrv/filter/auth_filter.h @@ -1,48 +1,48 @@ /* - * Copyright (C) 2008 Martin Willi
- * Copyright (C) 2008 Philip Boetschi, Adrian Doerig
- * Hochschule fuer Technik Rapperswil
- *
- * 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_filter_server auth_filter
- * @{ @ingroup filter_server
- */
-
-#ifndef AUTH_FILTER_H_
-#define AUTH_FILTER_H_
-
-#include <library.h>
+ * Copyright (C) 2008 Martin Willi + * Copyright (C) 2008 Philip Boetschi, Adrian Doerig + * Hochschule fuer Technik Rapperswil + * + * 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_filter_server auth_filter + * @{ @ingroup filter_server + */ + +#ifndef AUTH_FILTER_H_ +#define AUTH_FILTER_H_ + +#include <library.h> #include <filter.h> -#include "user.h"
-
-typedef struct auth_filter_t auth_filter_t;
-
-/**
- * Authentication/Authorization filter.
- */
-struct auth_filter_t {
-
- /**
- * Implements filter_t interface.
- */
- filter_t filter;
-};
-
-/**
- * Create a auth_filter instance.
- */
-filter_t *auth_filter_create(user_t *user, database_t *db);
-
-#endif /* AUTH_FILTER_H_ @}*/
+#include "user.h" + +typedef struct auth_filter_t auth_filter_t; + +/** + * Authentication/Authorization filter. + */ +struct auth_filter_t { + + /** + * Implements filter_t interface. + */ + filter_t filter; +}; + +/** + * Create a auth_filter instance. + */ +filter_t *auth_filter_create(user_t *user, database_t *db); + +#endif /* AUTH_FILTER_H_ @}*/ diff --git a/src/medsrv/user.c b/src/medsrv/user.c index d204dd057..b4859080b 100644 --- a/src/medsrv/user.c +++ b/src/medsrv/user.c @@ -33,26 +33,20 @@ struct private_user_t { u_int user; }; -/** - * Implementation of user_t.set_user - */ -static void set_user(private_user_t *this, u_int id) +METHOD(user_t, set_user, void, + private_user_t *this, u_int id) { this->user = id; } -/** - * Implementation of user_t.get_user - */ -static u_int get_user(private_user_t *this) +METHOD(user_t, get_user, u_int, + private_user_t *this) { return this->user; } -/** - * Implementation of context_t.destroy - */ -static void destroy(private_user_t *this) +METHOD(context_t, destroy, void, + private_user_t *this) { free(this); } @@ -62,13 +56,17 @@ static void destroy(private_user_t *this) */ user_t *user_create(void *param) { - private_user_t *this= malloc_thing(private_user_t); - - this->public.set_user = (void(*)(user_t*,u_int id))set_user; - this->public.get_user = (u_int(*)(user_t*))get_user; - this->public.context.destroy = (void(*)(context_t*))destroy; + private_user_t *this; - this->user = 0; + INIT(this, + .public = { + .set_user = _set_user, + .get_user = _get_user, + .context = { + .destroy = _destroy, + }, + }, + ); return &this->public; } |