Make classes final if they're not meant to be derived from
This commit is contained in:
parent
347e3584ee
commit
6786508148
@ -36,6 +36,8 @@ namespace cryfs {
|
||||
|
||||
cpputils::RandomGenerator &_keyGenerator;
|
||||
cpputils::SCryptSettings _scryptSettings;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Cli);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
namespace cryfs {
|
||||
namespace program_options {
|
||||
class Parser {
|
||||
class Parser final {
|
||||
public:
|
||||
Parser(int argc, char *argv[]);
|
||||
|
||||
@ -25,6 +25,8 @@ namespace cryfs {
|
||||
static void _checkValidCipher(const std::string &cipher, const std::vector<std::string> &supportedCiphers);
|
||||
|
||||
std::vector<char*> _options;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Parser);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace cryfs {
|
||||
|
||||
class CryConfigLoader {
|
||||
class CryConfigLoader final {
|
||||
public:
|
||||
CryConfigLoader(cpputils::unique_ref<cpputils::Console> console, cpputils::RandomGenerator &keyGenerator, const cpputils::SCryptSettings &scryptSettings, std::function<std::string()> askPasswordForExistingFilesystem, std::function<std::string()> askPasswordForNewFilesystem, const boost::optional<std::string> &cipher);
|
||||
CryConfigLoader(CryConfigLoader &&rhs) = default;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace cryfs {
|
||||
//TODO Use own exception for cpputils::Serializer/cpputils::Deserializer errors and only catch them
|
||||
class CryConfigEncryptor {
|
||||
class CryConfigEncryptor final {
|
||||
public:
|
||||
static constexpr size_t OuterKeySize = OuterEncryptor::Cipher::EncryptionKey::BINARY_LENGTH;
|
||||
static constexpr size_t MaxTotalKeySize = OuterKeySize + CryCiphers::MAX_KEY_SIZE;
|
||||
@ -35,6 +35,8 @@ namespace cryfs {
|
||||
cpputils::unique_ref<InnerEncryptor> _innerEncryptor(const std::string &cipherName) const;
|
||||
|
||||
cpputils::DerivedKey<MaxTotalKeySize> _derivedKey;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CryConfigEncryptor);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "../CryCipher.h"
|
||||
|
||||
namespace cryfs {
|
||||
class CryConfigEncryptorFactory {
|
||||
class CryConfigEncryptorFactory final {
|
||||
public:
|
||||
static cpputils::unique_ref<CryConfigEncryptor> deriveKey(const std::string &password, const cpputils::SCryptSettings &scryptSettings);
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace cryfs {
|
||||
template<class Cipher>
|
||||
class ConcreteInnerEncryptor: public InnerEncryptor {
|
||||
class ConcreteInnerEncryptor final: public InnerEncryptor {
|
||||
public:
|
||||
static constexpr size_t CONFIG_SIZE = 512; // Inner config data is grown to this size before encryption to hide its actual size
|
||||
|
||||
@ -22,6 +22,8 @@ namespace cryfs {
|
||||
private:
|
||||
|
||||
typename Cipher::EncryptionKey _key;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ConcreteInnerEncryptor);
|
||||
};
|
||||
|
||||
template<class Cipher>
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <messmer/cpp-utils/data/Deserializer.h>
|
||||
|
||||
namespace cryfs {
|
||||
struct InnerConfig {
|
||||
struct InnerConfig final {
|
||||
std::string cipherName;
|
||||
cpputils::Data encryptedConfig;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <messmer/cpp-utils/data/Deserializer.h>
|
||||
|
||||
namespace cryfs {
|
||||
struct OuterConfig {
|
||||
struct OuterConfig final {
|
||||
cpputils::DerivedKeyConfig keyConfig;
|
||||
cpputils::Data encryptedInnerConfig;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "OuterConfig.h"
|
||||
|
||||
namespace cryfs {
|
||||
class OuterEncryptor {
|
||||
class OuterEncryptor final {
|
||||
public:
|
||||
using Cipher = cpputils::AES256_GCM;
|
||||
static constexpr size_t CONFIG_SIZE = 1024; // Config data is grown to this size before encryption to hide its actual size
|
||||
@ -23,6 +23,8 @@ namespace cryfs {
|
||||
|
||||
Cipher::EncryptionKey _key;
|
||||
cpputils::DerivedKeyConfig _keyConfig;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(OuterEncryptor);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ optional<unique_ref<fspp::Node>> CryDevice::Load(const bf::path &path) {
|
||||
return optional<unique_ref<fspp::Node>>(make_unique_ref<CryDir>(this, none, _rootKey));
|
||||
}
|
||||
auto parent = LoadDirBlob(path.parent_path());
|
||||
auto entry = parent->GetChild(path.filename().native());
|
||||
const auto &entry = parent->GetChild(path.filename().native());
|
||||
|
||||
if (entry.type == fspp::Dir::EntryType::DIR) {
|
||||
return optional<unique_ref<fspp::Node>>(make_unique_ref<CryDir>(this, std::move(parent), entry.key));
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
namespace cryfs {
|
||||
|
||||
class CryDir: public fspp::Dir, CryNode {
|
||||
class CryDir final: public fspp::Dir, CryNode {
|
||||
public:
|
||||
CryDir(CryDevice *device, boost::optional<cpputils::unique_ref<parallelaccessfsblobstore::DirBlobRef>> parent, const blockstore::Key &key);
|
||||
virtual ~CryDir();
|
||||
~CryDir();
|
||||
|
||||
//TODO return type variance to CryFile/CryDir?
|
||||
cpputils::unique_ref<fspp::OpenFile> createAndOpenFile(const std::string &name, mode_t mode, uid_t uid, gid_t gid) override;
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
namespace cryfs {
|
||||
|
||||
class CryFile: public fspp::File, CryNode {
|
||||
class CryFile final: public fspp::File, CryNode {
|
||||
public:
|
||||
CryFile(CryDevice *device, cpputils::unique_ref<parallelaccessfsblobstore::DirBlobRef> parent, const blockstore::Key &key);
|
||||
virtual ~CryFile();
|
||||
~CryFile();
|
||||
|
||||
cpputils::unique_ref<fspp::OpenFile> open(int flags) const override;
|
||||
void truncate(off_t size) const override;
|
||||
|
@ -50,7 +50,7 @@ void CryNode::rename(const bf::path &to) {
|
||||
}
|
||||
//TODO More efficient implementation possible: directly rename when it's actually not moved to a different directory
|
||||
// It's also quite ugly code because in the parent==targetDir case, it depends on _parent not overriding the changes made by targetDir.
|
||||
auto old = (*_parent)->GetChild(_key);
|
||||
const auto &old = (*_parent)->GetChild(_key);
|
||||
auto mode = old.mode;
|
||||
auto uid = old.uid;
|
||||
auto gid = old.gid;
|
||||
|
@ -8,10 +8,10 @@
|
||||
namespace cryfs {
|
||||
class CryDevice;
|
||||
|
||||
class CryOpenFile: public fspp::OpenFile {
|
||||
class CryOpenFile final: public fspp::OpenFile {
|
||||
public:
|
||||
explicit CryOpenFile(const CryDevice *device, cpputils::unique_ref<parallelaccessfsblobstore::FileBlobRef> fileBlob);
|
||||
virtual ~CryOpenFile();
|
||||
~CryOpenFile();
|
||||
|
||||
void stat(struct ::stat *result) const override;
|
||||
void truncate(off_t size) const override;
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
namespace cryfs {
|
||||
|
||||
class CrySymlink: public fspp::Symlink, CryNode {
|
||||
class CrySymlink final: public fspp::Symlink, CryNode {
|
||||
public:
|
||||
CrySymlink(CryDevice *device, cpputils::unique_ref<parallelaccessfsblobstore::DirBlobRef> parent, const blockstore::Key &key);
|
||||
virtual ~CrySymlink();
|
||||
~CrySymlink();
|
||||
|
||||
boost::filesystem::path target() const override;
|
||||
|
||||
|
@ -14,10 +14,10 @@ namespace cryfs {
|
||||
//TODO Test classes in cachingfsblobstore
|
||||
|
||||
//TODO Inherit from same interface as FsBlobStore?
|
||||
class CachingFsBlobStore {
|
||||
class CachingFsBlobStore final {
|
||||
public:
|
||||
CachingFsBlobStore(cpputils::unique_ref<fsblobstore::FsBlobStore> baseBlobStore);
|
||||
virtual ~CachingFsBlobStore();
|
||||
~CachingFsBlobStore();
|
||||
|
||||
cpputils::unique_ref<FileBlobRef> createFileBlob();
|
||||
cpputils::unique_ref<DirBlobRef> createDirBlob();
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace cryfs {
|
||||
namespace cachingfsblobstore {
|
||||
|
||||
class DirBlobRef: public FsBlobRef {
|
||||
class DirBlobRef final: public FsBlobRef {
|
||||
public:
|
||||
DirBlobRef(cpputils::unique_ref<fsblobstore::DirBlob> base, CachingFsBlobStore *fsBlobStore):
|
||||
FsBlobRef(std::move(base), fsBlobStore),
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace cryfs {
|
||||
namespace cachingfsblobstore {
|
||||
|
||||
class FileBlobRef: public FsBlobRef {
|
||||
class FileBlobRef final: public FsBlobRef {
|
||||
public:
|
||||
FileBlobRef(cpputils::unique_ref<fsblobstore::FileBlob> base, CachingFsBlobStore *fsBlobStore)
|
||||
:FsBlobRef(std::move(base), fsBlobStore),
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace cryfs {
|
||||
namespace cachingfsblobstore {
|
||||
|
||||
class SymlinkBlobRef: public FsBlobRef {
|
||||
class SymlinkBlobRef final: public FsBlobRef {
|
||||
public:
|
||||
SymlinkBlobRef(cpputils::unique_ref<fsblobstore::SymlinkBlob> base, CachingFsBlobStore *fsBlobStore)
|
||||
:FsBlobRef(std::move(base), fsBlobStore),
|
||||
|
@ -112,7 +112,7 @@ off_t DirBlob::lstat_size() const {
|
||||
}
|
||||
|
||||
void DirBlob::statChild(const Key &key, struct ::stat *result) const {
|
||||
auto child = GetChild(key);
|
||||
const auto &child = GetChild(key);
|
||||
//TODO Loading the blob for only getting the size of the file/symlink is not very performant.
|
||||
// Furthermore, this is the only reason why DirBlob needs a pointer to _fsBlobStore, which is ugly
|
||||
result->st_mode = child.mode;
|
||||
|
@ -13,7 +13,7 @@ namespace cryfs {
|
||||
namespace fsblobstore {
|
||||
class FsBlobStore;
|
||||
|
||||
class DirBlob : public FsBlob {
|
||||
class DirBlob final : public FsBlob {
|
||||
public:
|
||||
|
||||
static cpputils::unique_ref<DirBlob> InitializeEmptyDir(cpputils::unique_ref<blobstore::Blob> blob,
|
||||
@ -21,7 +21,7 @@ namespace cryfs {
|
||||
|
||||
DirBlob(cpputils::unique_ref<blobstore::Blob> blob, std::function<off_t (const blockstore::Key&)> getLstatSize);
|
||||
|
||||
virtual ~DirBlob();
|
||||
~DirBlob();
|
||||
|
||||
off_t lstat_size() const override;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
namespace cryfs {
|
||||
namespace fsblobstore {
|
||||
|
||||
class FileBlob: public FsBlob {
|
||||
class FileBlob final: public FsBlob {
|
||||
public:
|
||||
static cpputils::unique_ref<FileBlob> InitializeEmptyFile(cpputils::unique_ref<blobstore::Blob> blob);
|
||||
|
||||
@ -24,7 +24,8 @@ namespace cryfs {
|
||||
off_t lstat_size() const override;
|
||||
|
||||
off_t size() const;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(FileBlob);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace cryfs {
|
||||
namespace fsblobstore {
|
||||
//TODO Test classes in fsblobstore
|
||||
|
||||
class FsBlobStore {
|
||||
class FsBlobStore final {
|
||||
public:
|
||||
FsBlobStore(cpputils::unique_ref<blobstore::BlobStore> baseBlobStore);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace cryfs {
|
||||
namespace fsblobstore {
|
||||
|
||||
class SymlinkBlob: public FsBlob {
|
||||
class SymlinkBlob final: public FsBlob {
|
||||
public:
|
||||
static cpputils::unique_ref<SymlinkBlob> InitializeSymlink(cpputils::unique_ref<blobstore::Blob> blob,
|
||||
const boost::filesystem::path &target);
|
||||
@ -25,6 +25,8 @@ namespace cryfs {
|
||||
static void _checkMagicNumber(const blobstore::Blob &blob);
|
||||
|
||||
static boost::filesystem::path _readTargetFromBlob(const blobstore::Blob &blob);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SymlinkBlob);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace cryfs {
|
||||
namespace fsblobstore {
|
||||
|
||||
struct DirEntry {
|
||||
struct DirEntry final {
|
||||
DirEntry(fspp::Dir::EntryType type_, const std::string &name_, const blockstore::Key &key_, mode_t mode_,
|
||||
uid_t uid_, gid_t gid_) : type(type_), name(name_), key(key_), mode(mode_), uid(uid_), gid(gid_) {
|
||||
switch (type) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace cryfs {
|
||||
namespace fsblobstore {
|
||||
|
||||
class DirEntryList {
|
||||
class DirEntryList final {
|
||||
public:
|
||||
using const_iterator = std::vector<DirEntry>::const_iterator;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace cryfs {
|
||||
namespace parallelaccessfsblobstore {
|
||||
|
||||
class DirBlobRef: public FsBlobRef {
|
||||
class DirBlobRef final: public FsBlobRef {
|
||||
public:
|
||||
DirBlobRef(cachingfsblobstore::DirBlobRef *base): _base(base) {}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace cryfs {
|
||||
namespace parallelaccessfsblobstore {
|
||||
|
||||
class FileBlobRef: public FsBlobRef {
|
||||
class FileBlobRef final: public FsBlobRef {
|
||||
public:
|
||||
FileBlobRef(cachingfsblobstore::FileBlobRef *base) : _base(base) {}
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace cryfs {
|
||||
// it didn't get written into cache yet, when Thread 2 requests it.
|
||||
// Same race condition in Caching/ParallelAccessBlockStore?
|
||||
|
||||
class ParallelAccessFsBlobStore {
|
||||
class ParallelAccessFsBlobStore final {
|
||||
public:
|
||||
ParallelAccessFsBlobStore(cpputils::unique_ref<cachingfsblobstore::CachingFsBlobStore> baseBlobStore);
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace cryfs {
|
||||
namespace parallelaccessfsblobstore {
|
||||
|
||||
class ParallelAccessFsBlobStoreAdapter: public parallelaccessstore::ParallelAccessBaseStore<cachingfsblobstore::FsBlobRef, blockstore::Key> {
|
||||
class ParallelAccessFsBlobStoreAdapter final: public parallelaccessstore::ParallelAccessBaseStore<cachingfsblobstore::FsBlobRef, blockstore::Key> {
|
||||
public:
|
||||
explicit ParallelAccessFsBlobStoreAdapter(cachingfsblobstore::CachingFsBlobStore *baseBlockStore)
|
||||
:_baseBlockStore(std::move(baseBlockStore)) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace cryfs {
|
||||
namespace parallelaccessfsblobstore {
|
||||
|
||||
class SymlinkBlobRef: public FsBlobRef {
|
||||
class SymlinkBlobRef final: public FsBlobRef {
|
||||
public:
|
||||
SymlinkBlobRef(cachingfsblobstore::SymlinkBlobRef *base) : _base(base) {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user