1
0
Fork 0

building again system report handler

This commit is contained in:
Kaveh Vahedipour 2019-11-22 11:16:50 +01:00
parent 72cd4fa63c
commit 35f455e5bd
2 changed files with 52 additions and 11 deletions

View File

@ -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 <unistd.h>
#endif
#include <velocypack/Builder.h>
#include <velocypack/velocypack-aliases.h>
#include <fstream>
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;
}

View File

@ -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