mirror of
https://github.com/vgough/encfs.git
synced 2025-02-16 09:49:46 +01:00
modernize: use C++ headers, auto, make_shared
This commit is contained in:
parent
b04c4124d4
commit
5a99506ea8
@ -18,10 +18,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stddef.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -184,13 +184,13 @@ bool Cipher::nameDecode(unsigned char *data, int len, uint64_t iv64,
|
|||||||
string Cipher::encodeAsString(const CipherKey &key,
|
string Cipher::encodeAsString(const CipherKey &key,
|
||||||
const CipherKey &encodingKey) {
|
const CipherKey &encodingKey) {
|
||||||
int encodedKeySize = this->encodedKeySize();
|
int encodedKeySize = this->encodedKeySize();
|
||||||
unsigned char *keyBuf = new unsigned char[encodedKeySize];
|
auto *keyBuf = new unsigned char[encodedKeySize];
|
||||||
|
|
||||||
// write the key, encoding it with itself.
|
// write the key, encoding it with itself.
|
||||||
this->writeKey(key, keyBuf, encodingKey);
|
this->writeKey(key, keyBuf, encodingKey);
|
||||||
|
|
||||||
int b64Len = B256ToB64Bytes(encodedKeySize);
|
int b64Len = B256ToB64Bytes(encodedKeySize);
|
||||||
unsigned char *b64Key = new unsigned char[b64Len + 1];
|
auto *b64Key = new unsigned char[b64Len + 1];
|
||||||
|
|
||||||
changeBase2(keyBuf, encodedKeySize, 8, b64Key, b64Len, 6);
|
changeBase2(keyBuf, encodedKeySize, 8, b64Key, b64Len, 6);
|
||||||
B64ToAscii(b64Key, b64Len);
|
B64ToAscii(b64Key, b64Len);
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
|
|
||||||
#include "internal/easylogging++.h"
|
#include "internal/easylogging++.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <cstring>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
#include <string.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "BlockFileIO.h"
|
#include "BlockFileIO.h"
|
||||||
|
@ -49,7 +49,7 @@ bool ConfigReader::load(const char *fileName) {
|
|||||||
int fd = open(fileName, O_RDONLY);
|
int fd = open(fileName, O_RDONLY);
|
||||||
if (fd < 0) return false;
|
if (fd < 0) return false;
|
||||||
|
|
||||||
char *buf = new char[size];
|
auto *buf = new char[size];
|
||||||
|
|
||||||
int res = ::read(fd, buf, size);
|
int res = ::read(fd, buf, size);
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -126,7 +126,7 @@ ConfigVar ConfigReader::toVar() const {
|
|||||||
|
|
||||||
ConfigVar ConfigReader::operator[](const std::string &varName) const {
|
ConfigVar ConfigReader::operator[](const std::string &varName) const {
|
||||||
// read only
|
// read only
|
||||||
map<string, ConfigVar>::const_iterator it = vars.find(varName);
|
auto it = vars.find(varName);
|
||||||
if (it == vars.end())
|
if (it == vars.end())
|
||||||
return ConfigVar();
|
return ConfigVar();
|
||||||
else
|
else
|
||||||
|
@ -112,7 +112,7 @@ void ConfigVar::writeInt(int val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ConfigVar::readInt() const {
|
int ConfigVar::readInt() const {
|
||||||
const unsigned char *buf = (const unsigned char *)buffer();
|
const auto *buf = (const unsigned char *)buffer();
|
||||||
int bytes = this->size();
|
int bytes = this->size();
|
||||||
int offset = at();
|
int offset = at();
|
||||||
int value = 0;
|
int value = 0;
|
||||||
@ -184,7 +184,7 @@ const ConfigVar &operator>>(const ConfigVar &src, std::string &result) {
|
|||||||
|
|
||||||
unsigned char tmpBuf[32];
|
unsigned char tmpBuf[32];
|
||||||
if (length > (int)sizeof(tmpBuf)) {
|
if (length > (int)sizeof(tmpBuf)) {
|
||||||
unsigned char *ptr = new unsigned char[length];
|
auto *ptr = new unsigned char[length];
|
||||||
readLen = src.read(ptr, length);
|
readLen = src.read(ptr, length);
|
||||||
result.assign((char *)ptr, length);
|
result.assign((char *)ptr, length);
|
||||||
delete[] ptr;
|
delete[] ptr;
|
||||||
|
@ -87,7 +87,7 @@ void EncFS_Context::getAndResetUsageCounter(int *usage, int *openCount) {
|
|||||||
std::shared_ptr<FileNode> EncFS_Context::lookupNode(const char *path) {
|
std::shared_ptr<FileNode> EncFS_Context::lookupNode(const char *path) {
|
||||||
Lock lock(contextMutex);
|
Lock lock(contextMutex);
|
||||||
|
|
||||||
FileMap::iterator it = openFiles.find(std::string(path));
|
auto it = openFiles.find(std::string(path));
|
||||||
if (it != openFiles.end()) {
|
if (it != openFiles.end()) {
|
||||||
// every entry in the list is fine... so just use the
|
// every entry in the list is fine... so just use the
|
||||||
// first
|
// first
|
||||||
@ -99,7 +99,7 @@ std::shared_ptr<FileNode> EncFS_Context::lookupNode(const char *path) {
|
|||||||
void EncFS_Context::renameNode(const char *from, const char *to) {
|
void EncFS_Context::renameNode(const char *from, const char *to) {
|
||||||
Lock lock(contextMutex);
|
Lock lock(contextMutex);
|
||||||
|
|
||||||
FileMap::iterator it = openFiles.find(std::string(from));
|
auto it = openFiles.find(std::string(from));
|
||||||
if (it != openFiles.end()) {
|
if (it != openFiles.end()) {
|
||||||
auto val = it->second;
|
auto val = it->second;
|
||||||
openFiles.erase(it);
|
openFiles.erase(it);
|
||||||
@ -123,7 +123,7 @@ void EncFS_Context::eraseNode(const char *path,
|
|||||||
std::shared_ptr<FileNode> fnode) {
|
std::shared_ptr<FileNode> fnode) {
|
||||||
Lock lock(contextMutex);
|
Lock lock(contextMutex);
|
||||||
|
|
||||||
FileMap::iterator it = openFiles.find(std::string(path));
|
auto it = openFiles.find(std::string(path));
|
||||||
rAssert(it != openFiles.end());
|
rAssert(it != openFiles.end());
|
||||||
auto &list = it->second;
|
auto &list = it->second;
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ void RenameOp::undo() {
|
|||||||
// list has to be processed backwards, otherwise we may rename
|
// list has to be processed backwards, otherwise we may rename
|
||||||
// directories and directory contents in the wrong order!
|
// directories and directory contents in the wrong order!
|
||||||
int undoCount = 0;
|
int undoCount = 0;
|
||||||
list<RenameEl>::const_iterator it = last;
|
auto it = last;
|
||||||
|
|
||||||
while (it != renameList->begin()) {
|
while (it != renameList->begin()) {
|
||||||
--it;
|
--it;
|
||||||
@ -485,7 +485,7 @@ std::shared_ptr<RenameOp> DirNode::newRenameOp(const char *fromP,
|
|||||||
RLOG(WARNING) << "Error during generation of recursive rename list";
|
RLOG(WARNING) << "Error during generation of recursive rename list";
|
||||||
return std::shared_ptr<RenameOp>();
|
return std::shared_ptr<RenameOp>();
|
||||||
} else
|
} else
|
||||||
return std::shared_ptr<RenameOp>(new RenameOp(this, renameList));
|
return std::make_shared<RenameOp>(this, renameList);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DirNode::mkdir(const char *plaintextPath, mode_t mode, uid_t uid,
|
int DirNode::mkdir(const char *plaintextPath, mode_t mode, uid_t uid,
|
||||||
|
@ -21,7 +21,7 @@ class Error : public std::runtime_error {
|
|||||||
RLOG(ERROR) << "Assert failed: " << STR(cond); \
|
RLOG(ERROR) << "Assert failed: " << STR(cond); \
|
||||||
throw encfs::Error(STR(cond)); \
|
throw encfs::Error(STR(cond)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (false)
|
||||||
|
|
||||||
void initLogging(bool enable_debug = false, bool is_daemon = false);
|
void initLogging(bool enable_debug = false, bool is_daemon = false);
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
|
#include <cinttypes>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -323,7 +323,7 @@ bool readV6Config(const char *configFile, EncFSConfig *cfg, ConfigInfo *info) {
|
|||||||
|
|
||||||
int encodedSize;
|
int encodedSize;
|
||||||
config->read("encodedKeySize", &encodedSize);
|
config->read("encodedKeySize", &encodedSize);
|
||||||
unsigned char *key = new unsigned char[encodedSize];
|
auto *key = new unsigned char[encodedSize];
|
||||||
config->readB64("encodedKeyData", key, encodedSize);
|
config->readB64("encodedKeyData", key, encodedSize);
|
||||||
cfg->assignKeyData(key, encodedSize);
|
cfg->assignKeyData(key, encodedSize);
|
||||||
delete[] key;
|
delete[] key;
|
||||||
@ -331,7 +331,7 @@ bool readV6Config(const char *configFile, EncFSConfig *cfg, ConfigInfo *info) {
|
|||||||
if (cfg->subVersion >= 20080816) {
|
if (cfg->subVersion >= 20080816) {
|
||||||
int saltLen;
|
int saltLen;
|
||||||
config->read("saltLen", &saltLen);
|
config->read("saltLen", &saltLen);
|
||||||
unsigned char *salt = new unsigned char[saltLen];
|
auto *salt = new unsigned char[saltLen];
|
||||||
config->readB64("saltData", salt, saltLen);
|
config->readB64("saltData", salt, saltLen);
|
||||||
cfg->assignSaltData(salt, saltLen);
|
cfg->assignSaltData(salt, saltLen);
|
||||||
delete[] salt;
|
delete[] salt;
|
||||||
@ -1161,7 +1161,7 @@ RootPtr createV6Config(EncFS_Context *ctx,
|
|||||||
"later using encfsctl.\n\n");
|
"later using encfsctl.\n\n");
|
||||||
|
|
||||||
int encodedKeySize = cipher->encodedKeySize();
|
int encodedKeySize = cipher->encodedKeySize();
|
||||||
unsigned char *encodedKey = new unsigned char[encodedKeySize];
|
auto *encodedKey = new unsigned char[encodedKeySize];
|
||||||
|
|
||||||
CipherKey volumeKey = cipher->newRandomKey();
|
CipherKey volumeKey = cipher->newRandomKey();
|
||||||
|
|
||||||
@ -1216,11 +1216,10 @@ RootPtr createV6Config(EncFS_Context *ctx,
|
|||||||
fsConfig->idleTracking = enableIdleTracking;
|
fsConfig->idleTracking = enableIdleTracking;
|
||||||
fsConfig->opts = opts;
|
fsConfig->opts = opts;
|
||||||
|
|
||||||
rootInfo = RootPtr(new EncFS_Root);
|
rootInfo = std::make_shared<encfs::EncFS_Root>();
|
||||||
rootInfo->cipher = cipher;
|
rootInfo->cipher = cipher;
|
||||||
rootInfo->volumeKey = volumeKey;
|
rootInfo->volumeKey = volumeKey;
|
||||||
rootInfo->root =
|
rootInfo->root = std::make_shared<DirNode>(ctx, rootDir, fsConfig);
|
||||||
std::shared_ptr<DirNode>(new DirNode(ctx, rootDir, fsConfig));
|
|
||||||
|
|
||||||
return rootInfo;
|
return rootInfo;
|
||||||
}
|
}
|
||||||
@ -1576,7 +1575,7 @@ RootPtr initFS(EncFS_Context *ctx, const std::shared_ptr<EncFS_Opts> &opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opts->delayMount) {
|
if (opts->delayMount) {
|
||||||
rootInfo = RootPtr(new EncFS_Root);
|
rootInfo = std::make_shared<encfs::EncFS_Root>();
|
||||||
rootInfo->cipher = cipher;
|
rootInfo->cipher = cipher;
|
||||||
rootInfo->root = std::shared_ptr<DirNode>();
|
rootInfo->root = std::shared_ptr<DirNode>();
|
||||||
return rootInfo;
|
return rootInfo;
|
||||||
@ -1632,11 +1631,10 @@ RootPtr initFS(EncFS_Context *ctx, const std::shared_ptr<EncFS_Opts> &opts) {
|
|||||||
fsConfig->reverseEncryption = opts->reverseEncryption;
|
fsConfig->reverseEncryption = opts->reverseEncryption;
|
||||||
fsConfig->opts = opts;
|
fsConfig->opts = opts;
|
||||||
|
|
||||||
rootInfo = RootPtr(new EncFS_Root);
|
rootInfo = std::make_shared<encfs::EncFS_Root>();
|
||||||
rootInfo->cipher = cipher;
|
rootInfo->cipher = cipher;
|
||||||
rootInfo->volumeKey = volumeKey;
|
rootInfo->volumeKey = volumeKey;
|
||||||
rootInfo->root =
|
rootInfo->root = std::make_shared<DirNode>(ctx, opts->rootDir, fsConfig);
|
||||||
std::shared_ptr<DirNode>(new DirNode(ctx, opts->rootDir, fsConfig));
|
|
||||||
} else {
|
} else {
|
||||||
if (opts->createIfNotFound) {
|
if (opts->createIfNotFound) {
|
||||||
// creating a new encrypted filesystem
|
// creating a new encrypted filesystem
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#include "MACFileIO.h"
|
#include "MACFileIO.h"
|
||||||
|
|
||||||
#include "internal/easylogging++.h"
|
#include "internal/easylogging++.h"
|
||||||
|
#include <cinttypes>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <inttypes.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "BlockFileIO.h"
|
#include "BlockFileIO.h"
|
||||||
|
@ -44,7 +44,7 @@ struct BlockList {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static BlockList *allocBlock(int size) {
|
static BlockList *allocBlock(int size) {
|
||||||
BlockList *block = new BlockList;
|
auto *block = new BlockList;
|
||||||
block->size = size;
|
block->size = size;
|
||||||
block->data = BUF_MEM_new();
|
block->data = BUF_MEM_new();
|
||||||
BUF_MEM_grow(block->data, size);
|
BUF_MEM_grow(block->data, size);
|
||||||
@ -98,7 +98,7 @@ MemBlock MemoryPool::allocate(int size) {
|
|||||||
void MemoryPool::release(const MemBlock &mb) {
|
void MemoryPool::release(const MemBlock &mb) {
|
||||||
pthread_mutex_lock(&gMPoolMutex);
|
pthread_mutex_lock(&gMPoolMutex);
|
||||||
|
|
||||||
BlockList *block = (BlockList *)mb.internalData;
|
auto *block = (BlockList *)mb.internalData;
|
||||||
|
|
||||||
// just to be sure there's nothing important left in buffers..
|
// just to be sure there's nothing important left in buffers..
|
||||||
VALGRIND_MAKE_MEM_UNDEFINED(block->data->data, block->size);
|
VALGRIND_MAKE_MEM_UNDEFINED(block->data->data, block->size);
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "internal/easylogging++.h"
|
#include "internal/easylogging++.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <cinttypes>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ static uint64_t _checksum_64(SSLKey *key, const unsigned char *data,
|
|||||||
for (unsigned int i = 0; i < (mdLen - 1); ++i)
|
for (unsigned int i = 0; i < (mdLen - 1); ++i)
|
||||||
h[i % 8] ^= (unsigned char)(md[i]);
|
h[i % 8] ^= (unsigned char)(md[i]);
|
||||||
|
|
||||||
uint64_t value = (uint64_t)h[0];
|
auto value = (uint64_t)h[0];
|
||||||
for (int i = 1; i < 8; ++i) value = (value << 8) | (uint64_t)h[i];
|
for (int i = 1; i < 8; ++i) value = (value << 8) | (uint64_t)h[i];
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -145,7 +145,7 @@ class XmlNode : virtual public XmlValue {
|
|||||||
if (name[0] == '@') {
|
if (name[0] == '@') {
|
||||||
const char *value = element->Attribute(name + 1);
|
const char *value = element->Attribute(name + 1);
|
||||||
if (value)
|
if (value)
|
||||||
return XmlValuePtr(new XmlValue(value));
|
return std::make_shared<encfs::XmlValue>(value);
|
||||||
else
|
else
|
||||||
return XmlValuePtr();
|
return XmlValuePtr();
|
||||||
} else {
|
} else {
|
||||||
@ -182,13 +182,13 @@ XmlValuePtr XmlReader::operator[](const char *name) const {
|
|||||||
tinyxml2::XMLNode *node = pd->doc->FirstChildElement(name);
|
tinyxml2::XMLNode *node = pd->doc->FirstChildElement(name);
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
RLOG(ERROR) << "Xml node " << name << " not found";
|
RLOG(ERROR) << "Xml node " << name << " not found";
|
||||||
return XmlValuePtr(new XmlValue());
|
return std::make_shared<encfs::XmlValue>();
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyxml2::XMLElement *element = node->ToElement();
|
tinyxml2::XMLElement *element = node->ToElement();
|
||||||
if (element == nullptr) {
|
if (element == nullptr) {
|
||||||
RLOG(ERROR) << "Xml node " << name << " not element";
|
RLOG(ERROR) << "Xml node " << name << " not element";
|
||||||
return XmlValuePtr(new XmlValue());
|
return std::make_shared<encfs::XmlValue>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return XmlValuePtr(new XmlNode(element));
|
return XmlValuePtr(new XmlNode(element));
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
/* Specification. */
|
/* Specification. */
|
||||||
#include "autosprintf.h"
|
#include "autosprintf.h"
|
||||||
|
|
||||||
#include <stdarg.h> // for va_list
|
#include <cstdarg> // for va_list
|
||||||
#include <stdio.h> // for NULL, vasprintf
|
#include <cstdio> // for NULL, vasprintf
|
||||||
#include <stdlib.h> // for free
|
#include <cstdlib> // for free
|
||||||
#include <string.h> // for strdup
|
#include <cstring> // for strdup
|
||||||
|
|
||||||
namespace gnu {
|
namespace gnu {
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ autosprintf::~autosprintf() { free(str); }
|
|||||||
autosprintf::operator char *() const {
|
autosprintf::operator char *() const {
|
||||||
if (str != nullptr) {
|
if (str != nullptr) {
|
||||||
size_t length = strlen(str) + 1;
|
size_t length = strlen(str) + 1;
|
||||||
char *copy = new char[length];
|
auto *copy = new char[length];
|
||||||
memcpy(copy, str, length);
|
memcpy(copy, str, length);
|
||||||
return copy;
|
return copy;
|
||||||
} else
|
} else
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
|
||||||
#include <ctype.h> // for toupper
|
#include <cctype> // for toupper
|
||||||
|
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ std::string B64StandardEncode(std::vector<unsigned char> inputBuffer) {
|
|||||||
std::string encodedString;
|
std::string encodedString;
|
||||||
encodedString.reserve(B256ToB64Bytes(inputBuffer.size()));
|
encodedString.reserve(B256ToB64Bytes(inputBuffer.size()));
|
||||||
long temp;
|
long temp;
|
||||||
std::vector<unsigned char>::iterator cursor = inputBuffer.begin();
|
auto cursor = inputBuffer.begin();
|
||||||
for (size_t idx = 0; idx < inputBuffer.size() / 3; idx++) {
|
for (size_t idx = 0; idx < inputBuffer.size() / 3; idx++) {
|
||||||
temp = (*cursor++) << 16; // Convert to big endian
|
temp = (*cursor++) << 16; // Convert to big endian
|
||||||
temp += (*cursor++) << 8;
|
temp += (*cursor++) << 8;
|
||||||
|
@ -18,17 +18,17 @@
|
|||||||
#include "encfs.h"
|
#include "encfs.h"
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <cinttypes>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdint.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
|
@ -18,18 +18,18 @@
|
|||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "Context.h"
|
#include "Context.h"
|
||||||
@ -493,7 +493,7 @@ static bool processArgs(int argc, char *argv[],
|
|||||||
static void *idleMonitor(void *);
|
static void *idleMonitor(void *);
|
||||||
|
|
||||||
void *encfs_init(fuse_conn_info *conn) {
|
void *encfs_init(fuse_conn_info *conn) {
|
||||||
EncFS_Context *ctx = (EncFS_Context *)fuse_get_context()->private_data;
|
auto *ctx = (EncFS_Context *)fuse_get_context()->private_data;
|
||||||
|
|
||||||
// set fuse connection options
|
// set fuse connection options
|
||||||
conn->async_read = true;
|
conn->async_read = true;
|
||||||
@ -599,7 +599,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// context is not a smart pointer because it will live for the life of
|
// context is not a smart pointer because it will live for the life of
|
||||||
// the filesystem.
|
// the filesystem.
|
||||||
auto ctx = std::shared_ptr<EncFS_Context>(new EncFS_Context);
|
auto ctx = std::make_shared<EncFS_Context>();
|
||||||
ctx->publicFilesystem = encfsArgs->opts->ownerCreate;
|
ctx->publicFilesystem = encfsArgs->opts->ownerCreate;
|
||||||
RootPtr rootInfo = initFS(ctx.get(), encfsArgs->opts);
|
RootPtr rootInfo = initFS(ctx.get(), encfsArgs->opts);
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ const int ActivityCheckInterval = 10;
|
|||||||
static bool unmountFS(EncFS_Context *ctx);
|
static bool unmountFS(EncFS_Context *ctx);
|
||||||
|
|
||||||
static void *idleMonitor(void *_arg) {
|
static void *idleMonitor(void *_arg) {
|
||||||
EncFS_Context *ctx = (EncFS_Context *)_arg;
|
auto *ctx = (EncFS_Context *)_arg;
|
||||||
std::shared_ptr<EncFS_Args> arg = ctx->args;
|
std::shared_ptr<EncFS_Args> arg = ctx->args;
|
||||||
|
|
||||||
const int timeoutCycles = 60 * arg->idleTimeout / ActivityCheckInterval;
|
const int timeoutCycles = 60 * arg->idleTimeout / ActivityCheckInterval;
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
#include "openssl.h"
|
#include "openssl.h"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define NO_DES
|
#define NO_DES
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user