From c1c0810f21d8a0451ca36a0fb2dc2683568b824b Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Mon, 9 Jun 2025 12:07:49 +0000 Subject: [PATCH] include/common_fwd: Include Crypto classes CryptoManager::cct is now used in CephContext ctor. To provide this defintion any ceph_context.cc target must also include Crypto.cc. crimson-alien-common library which only had ceph_context.cc must now also include Crypto.cc. However, the fact that crimson-common also includes Crypto.cc would cause multiple defintions to any Crypto classes methods. To resolve this, let's wrap all Crypto classes with TOPNSPC::common that would be forwarded using common_fwd logic. Signed-off-by: Matan Breizman (cherry picked from commit 0e3e34565f5730f8baefecde9be592587129ba9d) --- src/auth/Crypto.cc | 6 ++++++ src/auth/Crypto.h | 6 +++++- src/crimson/os/alienstore/CMakeLists.txt | 1 + src/include/common_fwd.h | 12 ++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/auth/Crypto.cc b/src/auth/Crypto.cc index f9fd54c6324..d77ceef2fda 100644 --- a/src/auth/Crypto.cc +++ b/src/auth/Crypto.cc @@ -73,6 +73,8 @@ static bool getentropy_works() } } +namespace TOPNSPC::auth { + CryptoRandom::CryptoRandom() : fd(getentropy_works() ? -1 : open_urandom()) {} @@ -102,6 +104,8 @@ void CryptoRandom::get_bytes(char *buf, int len) #include +namespace TOPNSPC::auth { + CryptoRandom::CryptoRandom() : fd(0) {} CryptoRandom::~CryptoRandom() = default; @@ -1150,5 +1154,7 @@ bool CryptoManager::crypto_type_supported(int type) const return supported_crypto_types.find(type) != supported_crypto_types.end(); } +} // namespace TOPNSPC::auth + #pragma clang diagnostic pop #pragma GCC diagnostic pop diff --git a/src/auth/Crypto.h b/src/auth/Crypto.h index 57b7cc3a32e..7bec81aabec 100644 --- a/src/auth/Crypto.h +++ b/src/auth/Crypto.h @@ -25,6 +25,8 @@ class CryptoKeyContext; namespace ceph { class Formatter; } +namespace TOPNSPC::auth { + /* * Random byte stream generator suitable for cryptographic use */ @@ -237,6 +239,7 @@ inline std::ostream& operator<<(std::ostream& out, const CryptoKey& k) * To use these functions, you need to call ceph::crypto::init(), see * common/ceph_crypto.h. common_init_finish does this for you. */ + class CryptoHandler { public: virtual ~CryptoHandler() {} @@ -256,6 +259,7 @@ public: }; + class CryptoManager { CephContext *cct; std::shared_ptr crypto_none; @@ -275,6 +279,6 @@ public: std::shared_ptr get_handler(int type); }; - +} // namespace TOPNSPC::auth #endif diff --git a/src/crimson/os/alienstore/CMakeLists.txt b/src/crimson/os/alienstore/CMakeLists.txt index 2ba396d93fa..36119d18854 100644 --- a/src/crimson/os/alienstore/CMakeLists.txt +++ b/src/crimson/os/alienstore/CMakeLists.txt @@ -1,6 +1,7 @@ include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/rocksdb/include") set(crimson_alien_common_srcs + ${PROJECT_SOURCE_DIR}/src/auth/Crypto.cc ${PROJECT_SOURCE_DIR}/src/common/admin_socket.cc ${PROJECT_SOURCE_DIR}/src/common/url_escape.cc ${PROJECT_SOURCE_DIR}/src/common/blkdev.cc diff --git a/src/include/common_fwd.h b/src/include/common_fwd.h index 3c449513854..6b38e708f3d 100644 --- a/src/include/common_fwd.h +++ b/src/include/common_fwd.h @@ -19,6 +19,14 @@ namespace TOPNSPC::common { class RefCountedWaitObject; class ConfigProxy; } + +namespace TOPNSPC::auth { + class CryptoManager; + class CryptoHandler; + class CryptoKey; + class CryptoRandom; +} + using TOPNSPC::common::CephContext; using TOPNSPC::common::PerfCounters; using TOPNSPC::common::PerfCountersBuilder; @@ -30,3 +38,7 @@ using TOPNSPC::common::RefCountedObjectSafe; using TOPNSPC::common::RefCountedCond; using TOPNSPC::common::RefCountedWaitObject; using TOPNSPC::common::ConfigProxy; +using TOPNSPC::auth::CryptoManager; +using TOPNSPC::auth::CryptoHandler; +using TOPNSPC::auth::CryptoKey; +using TOPNSPC::auth::CryptoRandom; -- 2.39.5