summaryrefslogtreecommitdiffstats
path: root/src/Core/RequestHandler
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/RequestHandler')
-rw-r--r--src/Core/RequestHandler/CoreStatusRequestHandler.cpp52
-rw-r--r--src/Core/RequestHandler/CoreStatusRequestHandler.h23
-rw-r--r--src/Core/RequestHandler/GSSAPIAuthRequestHandler.cpp113
-rw-r--r--src/Core/RequestHandler/GSSAPIAuthRequestHandler.h84
-rw-r--r--src/Core/RequestHandler/Makefile.am5
-rw-r--r--src/Core/RequestHandler/Makefile.in101
6 files changed, 255 insertions, 123 deletions
diff --git a/src/Core/RequestHandler/CoreStatusRequestHandler.cpp b/src/Core/RequestHandler/CoreStatusRequestHandler.cpp
new file mode 100644
index 0000000..9d923f5
--- /dev/null
+++ b/src/Core/RequestHandler/CoreStatusRequestHandler.cpp
@@ -0,0 +1,52 @@
+/*
+ * CoreStatusRequestHandler.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "CoreStatusRequestHandler.h"
+#include <Common/SystemBackend.h>
+#include <Net/Connection.h>
+#include <Net/Packets/HostStatusPacket.h>
+
+namespace Mad {
+namespace Core {
+namespace RequestHandler {
+
+bool CoreStatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::CORE_STATUS)
+ return false; // TODO Logging
+
+ // TODO Require authentication
+
+ Common::SystemBackend::UptimeInfo uptimeInfo = Common::SystemBackend::getBackend()->getUptimeInfo();
+ Common::SystemBackend::MemoryInfo memInfo = Common::SystemBackend::getBackend()->getMemoryInfo();
+
+ if(!connection->send(Net::Packets::HostStatusPacket(Net::Packet::OK, packet.getRequestId(), uptimeInfo.uptime, uptimeInfo.idleTime,
+ memInfo.totalMem, memInfo.freeMem, memInfo.totalSwap, memInfo.freeSwap)))
+ return false;
+
+ setFinished();
+
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Core/RequestHandler/CoreStatusRequestHandler.h b/src/Core/RequestHandler/CoreStatusRequestHandler.h
index acf941e..dc822cb 100644
--- a/src/Core/RequestHandler/CoreStatusRequestHandler.h
+++ b/src/Core/RequestHandler/CoreStatusRequestHandler.h
@@ -21,8 +21,6 @@
#define MAD_CORE_REQUESTHANDLER_CORESTATUSREQUESTHANDLER_H_
#include <Common/RequestHandler/RequestHandler.h>
-#include <Common/SystemBackend.h>
-#include <Net/Packets/HostStatusPacket.h>
namespace Mad {
namespace Core {
@@ -32,26 +30,7 @@ class CoreStatusRequestHandler : public Common::RequestHandler::RequestHandler {
public:
CoreStatusRequestHandler() {}
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::CORE_STATUS)
- return false; // TODO Logging
-
- // TODO Require authentication
-
- Common::SystemBackend::UptimeInfo uptimeInfo = Common::SystemBackend::getBackend()->getUptimeInfo();
- Common::SystemBackend::MemoryInfo memInfo = Common::SystemBackend::getBackend()->getMemoryInfo();
-
- if(!connection->send(Net::Packets::HostStatusPacket(Net::Packet::OK, packet.getRequestId(), uptimeInfo.uptime, uptimeInfo.idleTime,
- memInfo.totalMem, memInfo.freeMem, memInfo.totalSwap, memInfo.freeSwap)))
- return false;
-
- setFinished();
-
- return true;
- }
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
diff --git a/src/Core/RequestHandler/GSSAPIAuthRequestHandler.cpp b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.cpp
new file mode 100644
index 0000000..08c4751
--- /dev/null
+++ b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.cpp
@@ -0,0 +1,113 @@
+/*
+ * GSSAPIAuthRequestHandler.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "GSSAPIAuthRequestHandler.h"
+#include <Net/Connection.h>
+
+#include <cstring>
+
+#include <iostream>
+
+namespace Mad {
+namespace Core {
+namespace RequestHandler {
+
+// TODO Error handling
+
+bool GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::GSSAPI_AUTH)
+ return false; // TODO Logging
+
+ OM_uint32 majStat, minStat;
+ gss_buffer_desc recvBuffer, sendBuffer;
+
+ if(gssContinue) {
+ recvBuffer.length = packet.getLength();
+ recvBuffer.value = std::malloc(recvBuffer.length);
+ std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
+
+ majStat = gss_accept_sec_context(&minStat, &gssContext, GSS_C_NO_CREDENTIAL, &recvBuffer, GSS_C_NO_CHANNEL_BINDINGS, 0, 0, &sendBuffer, 0, 0, 0);
+
+ std::free(recvBuffer.value);
+
+ if(majStat == GSS_S_COMPLETE) {
+ std::cout << "GSS context established." << std::endl;
+ gssContinue = false;
+ }
+ else if(majStat != GSS_S_CONTINUE_NEEDED) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ gss_release_buffer(&minStat, &sendBuffer);
+ }
+ else if(!sentSignature) {
+ if(packet.getLength() != 0)
+ return false;
+
+ const gnutls_datum_t *cert = connection->getCertificate();
+
+ recvBuffer.length = cert->size;
+ recvBuffer.value = cert->data;
+
+ majStat = gss_get_mic(&minStat, gssContext, GSS_C_QOP_DEFAULT, &recvBuffer, &sendBuffer);
+
+ if(majStat != GSS_S_COMPLETE) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ gss_release_buffer(&minStat, &sendBuffer);
+
+ sentSignature = true;
+ }
+ else {
+ recvBuffer.length = packet.getLength();
+ recvBuffer.value = std::malloc(recvBuffer.length);
+ std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
+
+ majStat = gss_process_context_token(&minStat, gssContext, &recvBuffer);
+
+ std::free(recvBuffer.value);
+
+ if(majStat != GSS_S_COMPLETE)
+ return false;
+
+ setFinished();
+ }
+
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
index c04857b..590919f 100644
--- a/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
+++ b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
@@ -21,18 +21,12 @@
#define MAD_CORE_REQUESTHANDLER_GSSAPIAUTHREQUESTHANDLER_H_
#include <Common/RequestHandler/RequestHandler.h>
-#include <Net/Packet.h>
-#include <cstring>
#include <gssapi/gssapi.h>
-#include <iostream>
-
namespace Mad {
namespace Core {
namespace RequestHandler {
-// TODO Error handling
-
class GSSAPIAuthRequestHandler : public Common::RequestHandler::RequestHandler {
private:
gss_ctx_id_t gssContext;
@@ -42,83 +36,7 @@ class GSSAPIAuthRequestHandler : public Common::RequestHandler::RequestHandler {
public:
GSSAPIAuthRequestHandler() : gssContext(GSS_C_NO_CONTEXT), gssContinue(true), sentSignature(false) {}
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::GSSAPI_AUTH)
- return false; // TODO Logging
-
- OM_uint32 majStat, minStat;
- gss_buffer_desc recvBuffer, sendBuffer;
-
- if(gssContinue) {
- recvBuffer.length = packet.getLength();
- recvBuffer.value = std::malloc(recvBuffer.length);
- std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
-
- majStat = gss_accept_sec_context(&minStat, &gssContext, GSS_C_NO_CREDENTIAL, &recvBuffer, GSS_C_NO_CHANNEL_BINDINGS, 0, 0, &sendBuffer, 0, 0, 0);
-
- std::free(recvBuffer.value);
-
- if(majStat == GSS_S_COMPLETE) {
- std::cout << "GSS context established." << std::endl;
- gssContinue = false;
- }
- else if(majStat != GSS_S_CONTINUE_NEEDED) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- gss_release_buffer(&minStat, &sendBuffer);
- }
- else if(!sentSignature) {
- if(packet.getLength() != 0)
- return false;
-
- const gnutls_datum_t *cert = connection->getCertificate();
-
- recvBuffer.length = cert->size;
- recvBuffer.value = cert->data;
-
- majStat = gss_get_mic(&minStat, gssContext, GSS_C_QOP_DEFAULT, &recvBuffer, &sendBuffer);
-
- if(majStat != GSS_S_COMPLETE) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- gss_release_buffer(&minStat, &sendBuffer);
-
- sentSignature = true;
- }
- else {
- recvBuffer.length = packet.getLength();
- recvBuffer.value = std::malloc(recvBuffer.length);
- std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
-
- majStat = gss_process_context_token(&minStat, gssContext, &recvBuffer);
-
- std::free(recvBuffer.value);
-
- if(majStat != GSS_S_COMPLETE)
- return false;
-
- setFinished();
- }
-
- return true;
- }
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
diff --git a/src/Core/RequestHandler/Makefile.am b/src/Core/RequestHandler/Makefile.am
index c0abc5c..3754a22 100644
--- a/src/Core/RequestHandler/Makefile.am
+++ b/src/Core/RequestHandler/Makefile.am
@@ -1 +1,4 @@
-noinst_HEADERS = CoreStatusRequestHandler.h GSSAPIAuthRequestHandler.h
+noinst_LTLIBRARIES = librequesthandler.la
+librequesthandler_la_SOURCES = CoreStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp
+
+noinst_HEADERS = CoreStatusRequestHandler.h GSSAPIAuthRequestHandler.h
diff --git a/src/Core/RequestHandler/Makefile.in b/src/Core/RequestHandler/Makefile.in
index 2d1cbee..8b20b23 100644
--- a/src/Core/RequestHandler/Makefile.in
+++ b/src/Core/RequestHandler/Makefile.in
@@ -14,6 +14,7 @@
@SET_MAKE@
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -42,8 +43,25 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
-SOURCES =
-DIST_SOURCES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+librequesthandler_la_LIBADD =
+am_librequesthandler_la_OBJECTS = CoreStatusRequestHandler.lo \
+ GSSAPIAuthRequestHandler.lo
+librequesthandler_la_OBJECTS = $(am_librequesthandler_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(librequesthandler_la_SOURCES)
+DIST_SOURCES = $(librequesthandler_la_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
@@ -164,10 +182,13 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = librequesthandler.la
+librequesthandler_la_SOURCES = CoreStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp
noinst_HEADERS = CoreStatusRequestHandler.h GSSAPIAuthRequestHandler.h
all: all-am
.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -198,6 +219,47 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+librequesthandler.la: $(librequesthandler_la_OBJECTS) $(librequesthandler_la_DEPENDENCIES)
+ $(CXXLINK) $(librequesthandler_la_OBJECTS) $(librequesthandler_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoreStatusRequestHandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequestHandler.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
mostlyclean-libtool:
-rm -f *.lo
@@ -279,7 +341,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(HEADERS)
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
@@ -307,11 +369,14 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-tags
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
dvi: dvi-am
@@ -342,12 +407,14 @@ install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
pdf: pdf-am
@@ -362,17 +429,17 @@ uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool ctags distclean distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic \
- mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
- uninstall-am
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.