Merge pull request #5151 from sfc-gh-tclinkenbeard/fix-non-tls-build

Fix build with DISABLE_TLS=ON
This commit is contained in:
Trevor Clinkenbeard 2021-07-20 15:07:16 -07:00 committed by GitHub
commit 4b83d73f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 40 additions and 11 deletions

View File

@ -170,9 +170,11 @@ public:
}
Reference<IAsyncFile> f =
makeReference<ReadFile>(self->asyncTaskThread, self->containerName, fileName, self->client.get());
#if ENCRYPTION_ENABLED
if (self->usesEncryption()) {
f = makeReference<AsyncFileEncrypted>(f, false);
}
#endif
return f;
}
@ -183,9 +185,11 @@ public:
return Void();
}));
auto f = makeReference<WriteFile>(self->asyncTaskThread, self->containerName, fileName, self->client.get());
#if ENCRYPTION_ENABLED
if (self->usesEncryption()) {
f = makeReference<AsyncFileEncrypted>(f, true);
}
#endif
return makeReference<BackupFile>(fileName, f);
}

View File

@ -1127,6 +1127,7 @@ public:
return false;
}
#if ENCRYPTION_ENABLED
ACTOR static Future<Void> createTestEncryptionKeyFile(std::string filename) {
state Reference<IAsyncFile> keyFile = wait(IAsyncFileSystem::filesystem()->open(
filename,
@ -1163,6 +1164,8 @@ public:
StreamCipher::Key::initializeKey(std::move(key));
return Void();
}
#endif // ENCRYPTION_ENABLED
}; // class BackupContainerFileSystemImpl
Future<Reference<IBackupFile>> BackupContainerFileSystem::writeLogFile(Version beginVersion,
@ -1477,11 +1480,19 @@ Future<Void> BackupContainerFileSystem::encryptionSetupComplete() const {
}
void BackupContainerFileSystem::setEncryptionKey(Optional<std::string> const& encryptionKeyFileName) {
if (encryptionKeyFileName.present()) {
#if ENCRYPTION_ENABLED
encryptionSetupFuture = BackupContainerFileSystemImpl::readEncryptionKey(encryptionKeyFileName.get());
#else
encryptionSetupFuture = Void();
#endif
}
}
Future<Void> BackupContainerFileSystem::createTestEncryptionKeyFile(std::string const &filename) {
#if ENCRYPTION_ENABLED
return BackupContainerFileSystemImpl::createTestEncryptionKeyFile(filename);
#else
return Void();
#endif
}
namespace backup_test {

View File

@ -171,9 +171,11 @@ std::string BackupContainerS3BlobStore::getURLFormat() {
Future<Reference<IAsyncFile>> BackupContainerS3BlobStore::readFile(const std::string& path) {
Reference<IAsyncFile> f = makeReference<AsyncFileS3BlobStoreRead>(m_bstore, m_bucket, dataPath(path));
#if ENCRYPTION_ENABLED
if (usesEncryption()) {
f = makeReference<AsyncFileEncrypted>(f, AsyncFileEncrypted::Mode::READ_ONLY);
}
#endif
f = makeReference<AsyncFileReadAheadCache>(f,
m_bstore->knobs.read_block_size,
m_bstore->knobs.read_ahead_blocks,
@ -189,9 +191,11 @@ Future<std::vector<std::string>> BackupContainerS3BlobStore::listURLs(Reference<
Future<Reference<IBackupFile>> BackupContainerS3BlobStore::writeFile(const std::string& path) {
Reference<IAsyncFile> f = makeReference<AsyncFileS3BlobStoreWrite>(m_bstore, m_bucket, dataPath(path));
#if ENCRYPTION_ENABLED
if (usesEncryption()) {
f = makeReference<AsyncFileEncrypted>(f, AsyncFileEncrypted::Mode::APPEND_ONLY);
}
#endif
return Future<Reference<IBackupFile>>(makeReference<BackupContainerS3BlobStoreImpl::BackupFile>(path, f));
}

View File

@ -26,6 +26,8 @@
#include "flow/IRandom.h"
#include "flow/StreamCipher.h"
#if ENCRYPTION_ENABLED
#include <array>
/*
@ -79,3 +81,5 @@ public:
void releaseZeroCopy(void* data, int length, int64_t offset) override;
int64_t debugFD() const override;
};
#endif // ENCRYPTION_ENABLED

View File

@ -1,6 +1,7 @@
set(FDBRPC_SRCS
AsyncFileCached.actor.h
AsyncFileEIO.actor.h
AsyncFileEncrypted.h
AsyncFileKAIO.actor.h
AsyncFileNonDurable.actor.h
AsyncFileReadAhead.actor.h
@ -36,7 +37,6 @@ set(FDBRPC_SRCS
if(WITH_TLS AND NOT WIN32)
set(FDBRPC_SRCS
${FDBRPC_SRCS}
AsyncFileEncrypted.h
AsyncFileEncrypted.actor.cpp)
endif()

View File

@ -32,9 +32,7 @@
#include "fdbrpc/AsyncFileCached.actor.h"
#include "fdbrpc/AsyncFileEIO.actor.h"
#if (!defined(TLS_DISABLED) && !defined(_WIN32))
#include "fdbrpc/AsyncFileEncrypted.h"
#endif
#include "fdbrpc/AsyncFileWinASIO.actor.h"
#include "fdbrpc/AsyncFileKAIO.actor.h"
#include "flow/AsioReactor.h"
@ -79,14 +77,14 @@ Future<Reference<class IAsyncFile>> Net2FileSystem::open(const std::string& file
static_cast<boost::asio::io_service*>((void*)g_network->global(INetwork::enASIOService)));
if (FLOW_KNOBS->PAGE_WRITE_CHECKSUM_HISTORY > 0)
f = map(f, [=](Reference<IAsyncFile> r) { return Reference<IAsyncFile>(new AsyncFileWriteChecker(r)); });
#if (!defined(TLS_DISABLED) && !defined(_WIN32))
#if ENCRYPTION_ENABLED
if (flags & IAsyncFile::OPEN_ENCRYPTED)
f = map(f, [flags](Reference<IAsyncFile> r) {
auto mode = flags & IAsyncFile::OPEN_READWRITE ? AsyncFileEncrypted::Mode::APPEND_ONLY
: AsyncFileEncrypted::Mode::READ_ONLY;
return Reference<IAsyncFile>(new AsyncFileEncrypted(r, mode));
});
#endif
#endif // ENCRYPTION_ENABLED
return f;
}

View File

@ -33,9 +33,7 @@
#include "flow/Util.h"
#include "fdbrpc/IAsyncFile.h"
#include "fdbrpc/AsyncFileCached.actor.h"
#if (!defined(TLS_DISABLED) && !defined(_WIN32))
#include "fdbrpc/AsyncFileEncrypted.h"
#endif
#include "fdbrpc/AsyncFileNonDurable.actor.h"
#include "flow/crc32c.h"
#include "fdbrpc/TraceFileIO.h"
@ -2477,14 +2475,14 @@ Future<Reference<class IAsyncFile>> Sim2FileSystem::open(const std::string& file
f = AsyncFileDetachable::open(f);
if (FLOW_KNOBS->PAGE_WRITE_CHECKSUM_HISTORY > 0)
f = map(f, [=](Reference<IAsyncFile> r) { return Reference<IAsyncFile>(new AsyncFileWriteChecker(r)); });
#if (!defined(TLS_DISABLED) && !defined(_WIN32))
#if ENCRYPTION_ENABLED
if (flags & IAsyncFile::OPEN_ENCRYPTED)
f = map(f, [flags](Reference<IAsyncFile> r) {
auto mode = flags & IAsyncFile::OPEN_READWRITE ? AsyncFileEncrypted::Mode::APPEND_ONLY
: AsyncFileEncrypted::Mode::READ_ONLY;
return Reference<IAsyncFile>(new AsyncFileEncrypted(r, mode));
});
#endif
#endif // ENCRYPTION_ENABLED
return f;
} else
return AsyncFileCached::open(filename, flags, mode);

View File

@ -53,6 +53,7 @@ set(FLOW_SRCS
SignalSafeUnwind.cpp
SignalSafeUnwind.h
SimpleOpt.h
StreamCipher.h
SystemMonitor.cpp
SystemMonitor.h
TDMetric.actor.h
@ -100,8 +101,7 @@ set(FLOW_SRCS
if(WITH_TLS AND NOT WIN32)
set(FLOW_SRCS
${FLOW_SRCS}
StreamCipher.cpp
StreamCipher.h)
StreamCipher.cpp)
endif()
add_library(stacktrace stacktrace.amalgamation.cpp stacktrace.h)

View File

@ -20,6 +20,14 @@
#pragma once
#if (!defined(TLS_DISABLED) && !defined(_WIN32))
#define ENCRYPTION_ENABLED 1
#else
#define ENCRYPTION_ENABLED 0
#endif
#if ENCRYPTION_ENABLED
#include "flow/Arena.h"
#include "flow/FastRef.h"
#include "flow/flow.h"
@ -78,3 +86,5 @@ public:
StringRef decrypt(unsigned char const* ciphertext, int len, Arena&);
StringRef finish(Arena&);
};
#endif // ENCRYPTION_ENABLED