From 53b4175d00cacb17d4b05964c30e8e9a036d004f Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 17 Oct 2012 19:52:55 +0000 Subject: [PATCH] added: plugin message: WINIX_CHECK_PLUGIN_ACCESS this message is sent before calling MakePost() or MakeGet() if you return false (which is default) you can prevent the access to the resource git-svn-id: svn://ttmath.org/publicrep/winix/trunk@901 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/app.cpp | 19 +++++++++++++++++++ core/app.h | 1 + core/pluginmsg.h | 7 ++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/core/app.cpp b/core/app.cpp index 8ba43c9..9abeba6 100755 --- a/core/app.cpp +++ b/core/app.cpp @@ -275,6 +275,23 @@ size_t locale_id; } + +bool App::CheckAccessFromPlugins() +{ + PluginRes res = plugin.Call(WINIX_CHECK_PLUGIN_ACCESS); + + if( res.res_false > 0 ) + { + cur.request->status = WINIX_ERR_PERMISSION_DENIED; + log << log2 << "App: access prevented by a plugin" << logend; + return false; + } + +return true; +} + + + void App::ProcessRequestThrow() { ReadRequest(); @@ -459,6 +476,8 @@ void App::Make() if( cur.request->status == WINIX_ERR_OK ) functions.CheckFunctionAndSymlink(); + CheckAccessFromPlugins(); + // !! CHECK ME CheckFunctionAndSymlink can set redirect_to // may it should be tested before calling CheckIfNeedSSLredirect? CheckIfNeedSSLredirect(); diff --git a/core/app.h b/core/app.h index 9a3d2fd..09c1cdd 100755 --- a/core/app.h +++ b/core/app.h @@ -123,6 +123,7 @@ private: std::string sendfilea, sendfile2a; std::string send_data_buf; + bool CheckAccessFromPlugins(); void ProcessRequestThrow(); void ProcessRequest(); void BaseUrlRedirect(int code, bool add_subdomain); diff --git a/core/pluginmsg.h b/core/pluginmsg.h index 066d527..a305669 100755 --- a/core/pluginmsg.h +++ b/core/pluginmsg.h @@ -246,11 +246,16 @@ // #define WINIX_POST_PARAMS 31040 - // this is the raw string sent in POST method // in p1 there is a pointer to std::string object #define WINIX_RAW_POST_STRING 31050 +// this message is sent before calling MakePost() or MakeGet() +// if you return false (which is default) you can prevent the access +// to the resource +#define WINIX_CHECK_PLUGIN_ACCESS 31060 + + /* messages sent from other threads