Automated g4 rollback of changelist 803317436.
*** Reason for rollback ***
b/443840282 build breaks
*** Original change description ***
Removing BMCWEB_ENABLE_GRPC flag on g3 side first since BUILD dependencies need to be amended for reverse workflow to succeed.
b/416589112 Remove support for BMCWEB_ENABLE_GRPC undef code paths.
***
PiperOrigin-RevId: 805016770
Change-Id: Ic5979de6f49a986c85b773e7f9d1bf7e640ecba5
diff --git a/http/http_request.cpp b/http/http_request.cpp
index b0bad07..9e73c00 100644
--- a/http/http_request.cpp
+++ b/http/http_request.cpp
@@ -4,7 +4,9 @@
#include <system_error>
#include <utility>
-#include "absl/log/log.h"
+#ifdef BMCWEB_ENABLE_GRPC
+#include "absl/log/log.h" // NOLINT
+#endif
namespace crow {
@@ -16,7 +18,9 @@
ec = std::make_error_code(std::errc::invalid_argument);
}
+#ifdef BMCWEB_ENABLE_GRPC
LOG(INFO) << "=> HTTP: Request: path: target: " << this->target();
+#endif
}
Request::Request(std::string_view bodyIn, std::error_code& ec)
@@ -25,7 +29,9 @@
ec = std::make_error_code(std::errc::invalid_argument);
}
+#ifdef BMCWEB_ENABLE_GRPC
LOG(INFO) << "=> HTTP: Request: path: target: " << this->target();
+#endif
}
bool Request::setUrlInfo() {
diff --git a/http/http_request.hpp b/http/http_request.hpp
index f25e6f0..9b53e9d 100644
--- a/http/http_request.hpp
+++ b/http/http_request.hpp
@@ -1,5 +1,9 @@
#pragma once
+#ifdef BMCWEB_ENABLE_GRPC
+#include "absl/log/log.h"
+#include "bmcweb_authorizer_singleton.h"
+#endif
#include <memory>
#include <string>
@@ -7,7 +11,6 @@
#include <system_error> // NOLINT
#include <unordered_set>
-#include "absl/log/log.h" // NOLINT(misc-include-cleaner)
#include "boost/asio/io_context.hpp" // NOLINT
#include "boost/asio/ip/address.hpp" // NOLINT
#include "boost/beast/http/message.hpp" // NOLINT
@@ -16,7 +19,6 @@
#include "boost/url/url.hpp" // NOLINT
#include "common.hpp" // NOLINT(misc-include-cleaner)
#include "sessions.hpp"
-#include "bmcweb_authorizer_singleton.h" // NOLINT(misc-include-cleaner)
namespace crow {
diff --git a/http/http_server.hpp b/http/http_server.hpp
index eaa4d7e..ccdd9ee 100644
--- a/http/http_server.hpp
+++ b/http/http_server.hpp
@@ -1,6 +1,10 @@
#ifndef THIRD_PARTY_GBMCWEB_HTTP_HTTP_SERVER_H_
#define THIRD_PARTY_GBMCWEB_HTTP_HTTP_SERVER_H_
+#ifdef BMCWEB_ENABLE_GRPC
+#include "absl/log/log.h"
+#include "bmcweb_authorizer_singleton.h"
+#endif
#include <chrono> // NOLINT
#include <csignal>
@@ -12,7 +16,6 @@
#include <type_traits>
#include <utility>
-#include "absl/log/log.h" // NOLINT
#include "boost/asio/ip/address.hpp" // NOLINT
#include "boost/asio/ip/tcp.hpp" // NOLINT
#include "boost/asio/signal_set.hpp" // NOLINT
@@ -21,7 +24,6 @@
#include "boost/beast/ssl/ssl_stream.hpp" // NOLINT
#include "http_connection.hpp"
#include "logging.hpp"
-#include "bmcweb_authorizer_singleton.h"
namespace crow {
@@ -132,6 +134,7 @@
if (signalNo == SIGHUP) {
BMCWEB_LOG_INFO << "Receivied reload signal";
+#ifdef BMCWEB_ENABLE_GRPC
constexpr const char* persistentBasePrivilegesFolder =
"/var/google/authz_policies";
constexpr const char* rofsBasePrivilegesFolder =
@@ -149,6 +152,7 @@
// reload authz config
authorizer.ReloadConfiguration();
+#endif
loadCertificate();
boost::system::error_code ec2;
diff --git a/http/routing.cpp b/http/routing.cpp
index e6a1832..c43a468 100644
--- a/http/routing.cpp
+++ b/http/routing.cpp
@@ -528,6 +528,7 @@
BMCWEB_LOG_INFO << "Matched rule '" << rule.rule << "' "
<< static_cast<uint32_t>(*verb) << " / " << rule.getMethods();
+#ifdef BMCWEB_ENABLE_GRPC
if (!req.fromGrpc ||
(insecureDisableGrpcRedfishAuthz && req.peer_authenticated)) {
rule.handle(req, asyncResp, params);
@@ -557,6 +558,12 @@
}
rule.handle(req, asyncResp, params);
+#else
+ validatePrivilege(req, asyncResp, rule,
+ [&rule, asyncResp, params](Request& thisReq) mutable {
+ rule.handle(thisReq, asyncResp, params);
+ });
+#endif
}
void Router::debugPrint() {
diff --git a/http/routing.hpp b/http/routing.hpp
index eca115d..80a6512 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -1,6 +1,12 @@
#ifndef THIRD_PARTY_GBMCWEB_HTTP_ROUTING_H_
#define THIRD_PARTY_GBMCWEB_HTTP_ROUTING_H_
+#ifdef BMCWEB_ENABLE_GRPC
+#include "absl/log/log.h"
+#include "authorizer_enums.h"
+#include "bmcweb_authorizer_singleton.h"
+#include "uri_to_entity.h"
+#endif
#include <algorithm>
#include <array>
@@ -19,10 +25,8 @@
#include <utility>
#include <vector>
-#include "absl/log/log.h" // NOLINT(misc-include-cleaner)
#include "boost/beast/ssl/ssl_stream.hpp" // NOLINT
#include "boost/container/flat_map.hpp" // NOLINT
-#include "authorizer_enums.h" // NOLINT(misc-include-cleaner)
#include "common.hpp"
#include "http_request.hpp"
#include "http_response.hpp"
@@ -35,10 +39,8 @@
#include "privileges.hpp"
// TODO(haoooamazing): Remove dbus_utils.h include once indirect include is
// fixed for redfish-core/lib/ethernet.hpp
-#include "dbus_utils.hpp" // NOLINT(unused-includes)
-#include "bmcweb_authorizer_singleton.h" // NOLINT(misc-include-cleaner)
-#include "managed_store.hpp" // NOLINT(misc-include-cleaner)
-#include "uri_to_entity.h" // NOLINT(misc-include-cleaner)
+#include "dbus_utils.hpp" // NOLINT(misc-include-cleaner)
+#include "managed_store.hpp"
#ifdef UNIT_TEST_BUILD
#include "test/g3/mock_managed_store.hpp" // NOLINT