diff options
Diffstat (limited to 'src/Core')
-rw-r--r-- | src/Core/ConnectionManager.cpp | 3 | ||||
-rw-r--r-- | src/Core/Makefile.in | 11 | ||||
-rw-r--r-- | src/Core/RequestHandlers/Makefile.am | 8 | ||||
-rw-r--r-- | src/Core/RequestHandlers/Makefile.in | 22 | ||||
-rw-r--r-- | src/Core/RequestHandlers/UserInfoRequestHandler.cpp | 70 | ||||
-rw-r--r-- | src/Core/RequestHandlers/UserInfoRequestHandler.h | 48 | ||||
-rw-r--r-- | src/Core/RequestHandlers/UserListRequestHandler.h | 1 | ||||
-rw-r--r-- | src/Core/Requests/Makefile.in | 11 |
8 files changed, 152 insertions, 22 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index 3d252c2..4f8f90d 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -31,6 +31,7 @@ #include "RequestHandlers/GSSAPIAuthRequestHandler.h" #include "RequestHandlers/IdentifyRequestHandler.h" #include "RequestHandlers/LogRequestHandler.h" +#include "RequestHandlers/UserInfoRequestHandler.h" #include "RequestHandlers/UserListRequestHandler.h" #include <Net/FdManager.h> #include <Net/ServerConnection.h> @@ -177,6 +178,7 @@ void ConnectionManager::doInit() { Common::RequestManager::get()->registerPacketType<RequestHandlers::DaemonStatusRequestHandler>("GetDaemonStatus"); Common::RequestManager::get()->registerPacketType<RequestHandlers::IdentifyRequestHandler>("Identify"); Common::RequestManager::get()->registerPacketType<RequestHandlers::DaemonListRequestHandler>("ListHosts"); + Common::RequestManager::get()->registerPacketType<RequestHandlers::UserInfoRequestHandler>("GetUserInfo"); Common::RequestManager::get()->registerPacketType<RequestHandlers::UserListRequestHandler>("ListUsers"); Common::RequestManager::get()->registerPacketType<RequestHandlers::LogRequestHandler>("Log"); } @@ -194,6 +196,7 @@ void ConnectionManager::doDeinit() { Common::RequestManager::get()->unregisterPacketType("GetDaemonStatus"); Common::RequestManager::get()->unregisterPacketType("Identify"); Common::RequestManager::get()->unregisterPacketType("ListHosts"); + Common::RequestManager::get()->unregisterPacketType("GetUserInfo"); Common::RequestManager::get()->unregisterPacketType("ListUsers"); Common::RequestManager::get()->unregisterPacketType("Log"); diff --git a/src/Core/Makefile.in b/src/Core/Makefile.in index 9f8fa72..4e3ef5a 100644 --- a/src/Core/Makefile.in +++ b/src/Core/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -219,6 +219,8 @@ ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ +pcrecpp_CFLAGS = @pcrecpp_CFLAGS@ +pcrecpp_LIBS = @pcrecpp_LIBS@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ @@ -231,6 +233,7 @@ srcdir = @srcdir@ sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = Requests RequestHandlers @@ -246,8 +249,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -394,7 +397,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/src/Core/RequestHandlers/Makefile.am b/src/Core/RequestHandlers/Makefile.am index 5a044c8..036f936 100644 --- a/src/Core/RequestHandlers/Makefile.am +++ b/src/Core/RequestHandlers/Makefile.am @@ -1,6 +1,6 @@ noinst_LTLIBRARIES = librequesthandlers.la -librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp \ - IdentifyRequestHandler.cpp LogRequestHandler.cpp UserListRequestHandler.cpp +librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp \ + GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp LogRequestHandler.cpp UserInfoRequestHandler.cpp UserListRequestHandler.cpp -noinst_HEADERS = DaemonCommandRequestHandler.h DaemonFSInfoRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h \ - IdentifyRequestHandler.h LogRequestHandler.h UserListRequestHandler.h +noinst_HEADERS = DaemonCommandRequestHandler.h DaemonFSInfoRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h \ + GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h LogRequestHandler.h UserInfoRequestHandler.h UserListRequestHandler.h diff --git a/src/Core/RequestHandlers/Makefile.in b/src/Core/RequestHandlers/Makefile.in index 03a0ddd..70e0df4 100644 --- a/src/Core/RequestHandlers/Makefile.in +++ b/src/Core/RequestHandlers/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -56,7 +56,7 @@ am_librequesthandlers_la_OBJECTS = DaemonCommandRequestHandler.lo \ DaemonFSInfoRequestHandler.lo DaemonListRequestHandler.lo \ DaemonStatusRequestHandler.lo GSSAPIAuthRequestHandler.lo \ IdentifyRequestHandler.lo LogRequestHandler.lo \ - UserListRequestHandler.lo + UserInfoRequestHandler.lo UserListRequestHandler.lo librequesthandlers_la_OBJECTS = $(am_librequesthandlers_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp @@ -212,6 +212,8 @@ ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ +pcrecpp_CFLAGS = @pcrecpp_CFLAGS@ +pcrecpp_LIBS = @pcrecpp_LIBS@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ @@ -224,14 +226,15 @@ srcdir = @srcdir@ sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = librequesthandlers.la -librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp \ - IdentifyRequestHandler.cpp LogRequestHandler.cpp UserListRequestHandler.cpp +librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp \ + GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp LogRequestHandler.cpp UserInfoRequestHandler.cpp UserListRequestHandler.cpp -noinst_HEADERS = DaemonCommandRequestHandler.h DaemonFSInfoRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h \ - IdentifyRequestHandler.h LogRequestHandler.h UserListRequestHandler.h +noinst_HEADERS = DaemonCommandRequestHandler.h DaemonFSInfoRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h \ + GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h LogRequestHandler.h UserInfoRequestHandler.h UserListRequestHandler.h all: all-am @@ -241,8 +244,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -291,6 +294,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequestHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IdentifyRequestHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogRequestHandler.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserInfoRequestHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserListRequestHandler.Plo@am__quote@ .cpp.o: @@ -325,7 +329,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/src/Core/RequestHandlers/UserInfoRequestHandler.cpp b/src/Core/RequestHandlers/UserInfoRequestHandler.cpp new file mode 100644 index 0000000..d3a8aca --- /dev/null +++ b/src/Core/RequestHandlers/UserInfoRequestHandler.cpp @@ -0,0 +1,70 @@ +/* + * UserInfoRequestHandler.cpp + * + * Copyright (C) 2009 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 "UserInfoRequestHandler.h" +#include "../UserBackend.h" +#include <Common/Exception.h> +#include <Common/Logger.h> + +namespace Mad { +namespace Core { +namespace RequestHandlers { + +void UserInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) { + if(packet.getType() != "GetUserInfo") { + Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); + + Common::XmlPacket ret; + ret.setType("Error"); + ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + + sendPacket(ret); + + signalFinished().emit(); + return; + } + + // TODO Require authentication + + if(!UserBackend::getUserInfo(packet["uid"], sigc::mem_fun(this, &UserInfoRequestHandler::userInfoHandler))) { + Common::XmlPacket ret; + ret.setType("Error"); + ret.add("ErrorCode", Common::Exception::NOT_IMPLEMENTED); + + sendPacket(ret); + signalFinished().emit(); + } +} + +void UserInfoRequestHandler::userInfoHandler(const Common::UserInfo &info) { + Common::XmlPacket ret; + ret.setType("OK"); + + ret.add("uid", info.getUid()); + ret.add("gid", info.getGid()); + ret.add("username", info.getUsername()); + ret.add("fullName", info.getFullName()); + + sendPacket(ret); + signalFinished().emit(); +} + +} +} +} diff --git a/src/Core/RequestHandlers/UserInfoRequestHandler.h b/src/Core/RequestHandlers/UserInfoRequestHandler.h new file mode 100644 index 0000000..b3103d4 --- /dev/null +++ b/src/Core/RequestHandlers/UserInfoRequestHandler.h @@ -0,0 +1,48 @@ +/* + * UserInfoRequestHandler.h + * + * Copyright (C) 2009 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/>. + */ + +#ifndef MAD_CORE_REQUESTHANDLERS_USERINFOREQUESTHANDLER_H_ +#define MAD_CORE_REQUESTHANDLERS_USERINFOREQUESTHANDLER_H_ + +#include <Common/RequestHandler.h> +#include <Common/UserInfo.h> + +#include <map> + +namespace Mad { +namespace Core { +namespace RequestHandlers { + +class UserInfoRequestHandler : public Common::RequestHandler { + private: + void userInfoHandler(const Common::UserInfo &info); + + protected: + virtual void handlePacket(const Common::XmlPacket &packet); + + public: + UserInfoRequestHandler(Common::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} +}; + +} +} +} + +#endif /* MAD_CORE_REQUESTHANDLERS_USERINFOREQUESTHANDLER_H_ */ diff --git a/src/Core/RequestHandlers/UserListRequestHandler.h b/src/Core/RequestHandlers/UserListRequestHandler.h index a80c451..e31da67 100644 --- a/src/Core/RequestHandlers/UserListRequestHandler.h +++ b/src/Core/RequestHandlers/UserListRequestHandler.h @@ -24,7 +24,6 @@ #include <Common/UserInfo.h> #include <map> -#include <stdint.h> namespace Mad { namespace Core { diff --git a/src/Core/Requests/Makefile.in b/src/Core/Requests/Makefile.in index 2a0ca94..588f3c5 100644 --- a/src/Core/Requests/Makefile.in +++ b/src/Core/Requests/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -209,6 +209,8 @@ ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ +pcrecpp_CFLAGS = @pcrecpp_CFLAGS@ +pcrecpp_LIBS = @pcrecpp_LIBS@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ @@ -221,6 +223,7 @@ srcdir = @srcdir@ sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = librequests.la @@ -234,8 +237,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -312,7 +315,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS |