]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include/common_fwd: Include Crypto classes
authorMatan Breizman <mbreizma@redhat.com>
Mon, 9 Jun 2025 12:07:49 +0000 (12:07 +0000)
committerPatrick Donnelly <pdonnell@ibm.com>
Mon, 22 Sep 2025 16:32:56 +0000 (12:32 -0400)
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 <mbreizma@redhat.com>
(cherry picked from commit 0e3e34565f5730f8baefecde9be592587129ba9d)

src/auth/Crypto.cc
src/auth/Crypto.h
src/crimson/os/alienstore/CMakeLists.txt
src/include/common_fwd.h

index f9fd54c632493c8c532ae7efb6ed3492dc460c78..d77ceef2fdadc64d16e0a4c6631ec89c58f1ad7c 100644 (file)
@@ -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 <bcrypt.h>
 
+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
index 57b7cc3a32e85214c5c571cfd1e5b997afdca8e1..7bec81aabecf451571ba66d723497649e4843935 100644 (file)
@@ -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<CryptoHandler> crypto_none;
@@ -275,6 +279,6 @@ public:
 
   std::shared_ptr<CryptoHandler> get_handler(int type);
 };
-
+} // namespace TOPNSPC::auth
 
 #endif
index 2ba396d93fa8551d514a32615fff1512f6f7394e..36119d18854ab3a08eda81a0dec7b3ee87754127 100644 (file)
@@ -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
index 3c449513854c10e26e8eca299f2d3cb0d55f0807..6b38e708f3d88be9e1d487b19d62923469e82ed2 100644 (file)
@@ -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;