From 35f455e5bdaaf0b4d0cbb69c8b45bdcc66bdb884 Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Fri, 22 Nov 2019 11:16:50 +0100 Subject: [PATCH] building again system report handler --- .../RestHandler/RestSystemReportHandler.cpp | 19 ++++---- arangod/RestHandler/RestSystemReportHandler.h | 44 +++++++++++++++++++ 2 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 arangod/RestHandler/RestSystemReportHandler.h diff --git a/arangod/RestHandler/RestSystemReportHandler.cpp b/arangod/RestHandler/RestSystemReportHandler.cpp index ec642792a2..3f4f0da914 100644 --- a/arangod/RestHandler/RestSystemReportHandler.cpp +++ b/arangod/RestHandler/RestSystemReportHandler.cpp @@ -1,8 +1,7 @@ //////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// -/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany -/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany +/// Copyright 2018-2019 ArangoDB GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. @@ -32,13 +31,11 @@ #include "RestServer/ServerFeature.h" #include "Utils/ExecContext.h" -#if defined(TRI_HAVE_POSIX_THREADS) -#include -#endif - #include #include +#include + using namespace arangodb; using namespace arangodb::basics; using namespace arangodb::rest; @@ -47,9 +44,9 @@ using namespace arangodb::rest; /// @brief ArangoDB server //////////////////////////////////////////////////////////////////////////////// -RestSystemReportHandler::RestSystemReportHandler(GeneralRequest* request, - GeneralResponse* response) - : RestBaseHandler(request, response) {} +RestSystemReportHandler::RestSystemReportHandler( + application_features::ApplicationServer& server, GeneralRequest* request, + GeneralResponse* response) : RestBaseHandler(server, request, response) {} std::string executeOSCmd(std::string const& cmd) { static std::string const tmpFile("/tmp/arango-inspect.tmp"); @@ -64,8 +61,8 @@ std::string executeOSCmd(std::string const& cmd) { bool RestSystemReportHandler::isAdminUser() const { if (!ExecContext::isAuthEnabled()) { return true; - } else if (ExecContext::CURRENT != nullptr) { - return ExecContext::CURRENT->isAdminUser(); + } else { + return ExecContext::current().isAdminUser(); } return false; } diff --git a/arangod/RestHandler/RestSystemReportHandler.h b/arangod/RestHandler/RestSystemReportHandler.h new file mode 100644 index 0000000000..60e35b71fd --- /dev/null +++ b/arangod/RestHandler/RestSystemReportHandler.h @@ -0,0 +1,44 @@ +//////////////////////////////////////////////////////////////////////////////// +/// DISCLAIMER +/// +/// Copyright 2018-2019 ArangoDB GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is ArangoDB GmbH, Cologne, Germany +/// +/// @author Kaveh Vahedipour +//////////////////////////////////////////////////////////////////////////////// + +#ifndef ARANGOD_REST_HANDLER_REST_SYSTEM_REPORT_HANDLER_H +#define ARANGOD_REST_HANDLER_REST_SYSTEM_REPORT_HANDLER_H 1 + +#include "RestHandler/RestBaseHandler.h" + +namespace arangodb { +class RestSystemReportHandler : public arangodb::RestBaseHandler { + public: + RestSystemReportHandler( + application_features::ApplicationServer&, GeneralRequest*, + GeneralResponse*); + char const* name() const override final { return "RestSystemReportHandler"; } + RequestLane lane() const override final { return RequestLane::CLIENT_SLOW; } + RestStatus execute() override; +private: + bool isAdminUser() const; + + +}; +} // namespace arangodb + +#endif