diff --git a/CMakeLists.txt b/CMakeLists.txt index 46e13d6..de97cb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,9 @@ project(EncFS C CXX) set (ENCFS_MAJOR 1) set (ENCFS_MINOR 9) -set (ENCFS_VERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}") -set (ENCFS_SOVERSION 7) +set (ENCFS_PATCH 0) +set (ENCFS_VERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}.${ENCFS_PATCH}") +set (ENCFS_SOVERSION "1.9") set (ENCFS_NAME "Encrypted Filesystem") set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} diff --git a/encfs/BlockFileIO.cpp b/encfs/BlockFileIO.cpp index fb0fabe..ba9d060 100644 --- a/encfs/BlockFileIO.cpp +++ b/encfs/BlockFileIO.cpp @@ -20,14 +20,16 @@ #include "BlockFileIO.h" -#include "MemoryPool.h" - -#include +#include #include +#include +#include -#include "i18n.h" - +#include "FSConfig.h" +#include "FileIO.h" #include "FileUtils.h" +#include "MemoryPool.h" +#include "i18n.h" template inline Type min(Type A, Type B) { @@ -67,11 +69,11 @@ ssize_t BlockFileIO::cacheReadOneBlock(const IORequest &req) const { * in the last block of a file, which may be smaller than the blocksize. * For reverse encryption, the cache must not be used at all, because * the lower file may have changed behind our back. */ - if ( (_noCache == false) && (req.offset == _cache.offset) && - (_cache.dataLen != 0)) { + if ((_noCache == false) && (req.offset == _cache.offset) && + (_cache.dataLen != 0)) { // satisfy request from cache int len = req.dataLen; - if (_cache.dataLen < len) len = _cache.dataLen; // Don't read past EOF + if (_cache.dataLen < len) len = _cache.dataLen; // Don't read past EOF memcpy(req.data, _cache.data, len); return len; } else { diff --git a/encfs/BlockFileIO.h b/encfs/BlockFileIO.h index 24d8ef5..cbd6a7f 100644 --- a/encfs/BlockFileIO.h +++ b/encfs/BlockFileIO.h @@ -21,8 +21,10 @@ #ifndef _BlockFileIO_incl_ #define _BlockFileIO_incl_ -#include "FileIO.h" +#include + #include "FSConfig.h" +#include "FileIO.h" /* Implements block scatter / gather interface. Requires derived classes to diff --git a/encfs/BlockNameIO.cpp b/encfs/BlockNameIO.cpp index 2c25b54..863d68c 100644 --- a/encfs/BlockNameIO.cpp +++ b/encfs/BlockNameIO.cpp @@ -20,15 +20,19 @@ #include "BlockNameIO.h" -#include "Cipher.h" -#include "base64.h" - -#include -#include #include -#include +#include +#include -#include "i18n.h" +#include "Cipher.h" +#include "CipherKey.h" +#include "NameIO.h" +#include "base64.h" +#include "intl/gettext.h" + +namespace rlog { +class RLogChannel; +} // namespace rlog using namespace rlog; using namespace rel; @@ -151,7 +155,7 @@ int BlockNameIO::encodeName(const char *plaintextName, int length, uint64_t *iv, // add checksum bytes encodedName[0] = (mac >> 8) & 0xff; - encodedName[1] = (mac) & 0xff; + encodedName[1] = (mac)&0xff; _cipher->blockEncode((unsigned char *)encodedName + 2, length + padding, (uint64_t)mac ^ tmpIV, _key); @@ -184,8 +188,7 @@ int BlockNameIO::decodeName(const char *encodedName, int length, uint64_t *iv, int decodedStreamLen = decLen256 - 2; // don't bother trying to decode files which are too small - if (decodedStreamLen < _bs) - { + if (decodedStreamLen < _bs) { rDebug("Rejecting filename '%s'", encodedName); throw ERROR("Filename too small to decode"); } diff --git a/encfs/BlockNameIO.h b/encfs/BlockNameIO.h index b253d89..3f51257 100644 --- a/encfs/BlockNameIO.h +++ b/encfs/BlockNameIO.h @@ -21,8 +21,12 @@ #ifndef _BlockNameIO_incl_ #define _BlockNameIO_incl_ -#include "NameIO.h" +#include +#include + #include "CipherKey.h" +#include "Interface.h" +#include "NameIO.h" #include "shared_ptr.h" class Cipher; diff --git a/encfs/Cipher.cpp b/encfs/Cipher.cpp index 48f7681..c8e9101 100644 --- a/encfs/Cipher.cpp +++ b/encfs/Cipher.cpp @@ -18,22 +18,22 @@ * along with this program. If not, see . */ -#include "config.h" +#include +#include +#include +#include +#include +#include #include "Cipher.h" +#include "CipherKey.h" #include "Interface.h" -#include "Range.h" -#include "base64.h" - -#include -#include -#include -#include - // for static build. Need to reference the modules which are registered at // run-time, to ensure that the linker doesn't optimize them away. #include "NullCipher.h" +#include "Range.h" #include "SSL_Cipher.h" +#include "base64.h" using namespace std; using namespace rel; diff --git a/encfs/Cipher.h b/encfs/Cipher.h index 310f60b..c21ea69 100644 --- a/encfs/Cipher.h +++ b/encfs/Cipher.h @@ -21,15 +21,16 @@ #ifndef _Cipher_incl_ #define _Cipher_incl_ -#include "encfs.h" - -#include "Range.h" -#include "Interface.h" -#include "CipherKey.h" - -#include -#include #include +#include +#include +#include +#include + +#include "CipherKey.h" +#include "Interface.h" +#include "Range.h" +#include "encfs.h" /* Mostly pure virtual interface defining operations on a cipher. diff --git a/encfs/CipherFileIO.cpp b/encfs/CipherFileIO.cpp index 432c760..dfbb171 100644 --- a/encfs/CipherFileIO.cpp +++ b/encfs/CipherFileIO.cpp @@ -20,17 +20,19 @@ #include "CipherFileIO.h" -#include "Cipher.h" -#include "MemoryPool.h" - -#include -#include - #include -#include -#include - +#include #include +#include +#include +#include +#include +#include + +#include "BlockFileIO.h" +#include "Cipher.h" +#include "CipherKey.h" +#include "FileIO.h" /* - Version 2:0 adds support for a per-file initialization vector with a @@ -144,15 +146,12 @@ int CipherFileIO::getAttr(struct stat *stbuf) const { // adjust size if we have a file header if ((res == 0) && haveHeader && S_ISREG(stbuf->st_mode) && (stbuf->st_size > 0)) { - if(!fsConfig->reverseEncryption) - { + if (!fsConfig->reverseEncryption) { /* In normal mode, the upper file (plaintext) is smaller * than the backing ciphertext file */ rAssert(stbuf->st_size >= HEADER_SIZE); stbuf->st_size -= HEADER_SIZE; - } - else - { + } else { /* In reverse mode, the upper file (ciphertext) is larger than * the backing plaintext file */ stbuf->st_size += HEADER_SIZE; @@ -171,13 +170,10 @@ off_t CipherFileIO::getSize() const { // No check on S_ISREG here -- don't call getSize over getAttr unless this // is a normal file! if (haveHeader && size > 0) { - if(!fsConfig->reverseEncryption) - { + if (!fsConfig->reverseEncryption) { rAssert(size >= HEADER_SIZE); size -= HEADER_SIZE; - } - else - { + } else { size += HEADER_SIZE; } } @@ -278,13 +274,13 @@ bool CipherFileIO::writeHeader() { * the IV. This guarantees unpredictability and prevents watermarking * attacks. */ -void CipherFileIO::generateReverseHeader(unsigned char* headerBuf) { +void CipherFileIO::generateReverseHeader(unsigned char *headerBuf) { struct stat stbuf; int res = getAttr(&stbuf); - rAssert( res == 0 ); + rAssert(res == 0); ino_t ino = stbuf.st_ino; - rAssert( ino != 0 ); + rAssert(ino != 0); rDebug("generating reverse file IV header from ino=%lu", (unsigned long)ino); @@ -300,7 +296,7 @@ void CipherFileIO::generateReverseHeader(unsigned char* headerBuf) { * may lead to duplicate IVs (see readOneBlock) */ unsigned char md[20]; SHA1(inoBuf, sizeof(ino), md); - rAssert( HEADER_SIZE <= 20 ); + rAssert(HEADER_SIZE <= 20); memcpy(headerBuf, md, HEADER_SIZE); // Save the IV in fileIV for internal use @@ -329,7 +325,7 @@ ssize_t CipherFileIO::readOneBlock(const IORequest &req) const { // adjust offset if we have a file header if (haveHeader && !fsConfig->reverseEncryption) { - tmpReq.offset += HEADER_SIZE; + tmpReq.offset += HEADER_SIZE; } readSize = base->read(tmpReq); @@ -464,12 +460,14 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const { /* if reverse mode is not active with uniqueIV, * the read request is handled by the base class */ - if ( !(fsConfig->reverseEncryption && haveHeader) ) { - rDebug("relaying request to base class: offset=%d, dataLen=%d", origReq.offset, origReq.dataLen); + if (!(fsConfig->reverseEncryption && haveHeader)) { + rDebug("relaying request to base class: offset=%d, dataLen=%d", + origReq.offset, origReq.dataLen); return BlockFileIO::read(origReq); } - rDebug("handling reverse unique IV read: offset=%d, dataLen=%d", origReq.offset, origReq.dataLen); + rDebug("handling reverse unique IV read: offset=%d, dataLen=%d", + origReq.offset, origReq.dataLen); // generate the file IV header // this is needed in any case - without IV the file cannot be decoded @@ -483,14 +481,14 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const { * plain text file. Values below zero are the header. */ req.offset -= HEADER_SIZE; - int headerBytes = 0; // number of header bytes to add + int headerBytes = 0; // number of header bytes to add /* The request contains (a part of) the header, so we prefix that part * to the data. */ if (req.offset < 0) { headerBytes = -req.offset; - if ( req.dataLen < headerBytes ) - headerBytes = req.dataLen; // only up to the number of bytes requested + if (req.dataLen < headerBytes) + headerBytes = req.dataLen; // only up to the number of bytes requested rDebug("Adding %d header bytes", headerBytes); // copy the header bytes into the data @@ -498,14 +496,13 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const { memcpy(req.data, &headerBuf[headerOffset], headerBytes); // the read does not want data beyond the header - if ( headerBytes == req.dataLen) - return headerBytes; + if (headerBytes == req.dataLen) return headerBytes; /* The rest of the request will be read from the backing file. * As we have already generated n=headerBytes bytes, the request is * shifted by headerBytes */ req.offset += headerBytes; - rAssert( req.offset == 0 ); + rAssert(req.offset == 0); req.data += headerBytes; req.dataLen -= headerBytes; } @@ -513,10 +510,9 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const { // read the payload ssize_t readBytes = BlockFileIO::read(req); rDebug("read %ld bytes from backing file", (long)readBytes); - if ( readBytes < 0) - return readBytes; // Return error code - else - { + if (readBytes < 0) + return readBytes; // Return error code + else { ssize_t sum = headerBytes + readBytes; rDebug("returning sum=%ld", (long)sum); return sum; diff --git a/encfs/CipherFileIO.h b/encfs/CipherFileIO.h index 4042e29..e73e6ff 100644 --- a/encfs/CipherFileIO.h +++ b/encfs/CipherFileIO.h @@ -21,13 +21,20 @@ #ifndef _CipherFileIO_incl_ #define _CipherFileIO_incl_ +#include +#include +#include +#include + #include "BlockFileIO.h" #include "CipherKey.h" +#include "FSConfig.h" #include "FileUtils.h" - -#include +#include "Interface.h" class Cipher; +class FileIO; +struct IORequest; /* Implement the FileIO interface encrypting data in blocks. @@ -57,7 +64,7 @@ class CipherFileIO : public BlockFileIO { private: virtual ssize_t readOneBlock(const IORequest &req) const; virtual bool writeOneBlock(const IORequest &req); - virtual void generateReverseHeader(unsigned char* data); + virtual void generateReverseHeader(unsigned char *data); void initHeader(); bool writeHeader(); diff --git a/encfs/CipherKey.h b/encfs/CipherKey.h index 1de3bc8..7054fd8 100644 --- a/encfs/CipherKey.h +++ b/encfs/CipherKey.h @@ -21,6 +21,8 @@ #ifndef _CipherKey_incl_ #define _CipherKey_incl_ +#include + #include "shared_ptr.h" class AbstractCipherKey { diff --git a/encfs/ConfigReader.cpp b/encfs/ConfigReader.cpp index 4fa9d04..ee298c8 100644 --- a/encfs/ConfigReader.cpp +++ b/encfs/ConfigReader.cpp @@ -20,13 +20,14 @@ #include "ConfigReader.h" -#include - -#include -#include #include +#include +#include #include #include +#include + +#include "ConfigVar.h" using namespace std; using namespace rlog; diff --git a/encfs/ConfigVar.cpp b/encfs/ConfigVar.cpp index b107e2a..4c38941 100644 --- a/encfs/ConfigVar.cpp +++ b/encfs/ConfigVar.cpp @@ -19,8 +19,8 @@ */ #include "ConfigVar.h" -#include +#include #include using namespace rlog; diff --git a/encfs/ConfigVar.h b/encfs/ConfigVar.h index f6c40b5..aad8a87 100644 --- a/encfs/ConfigVar.h +++ b/encfs/ConfigVar.h @@ -21,7 +21,9 @@ #ifndef _ConfigVar_incl_ #define _ConfigVar_incl_ +#include #include + #include "shared_ptr.h" class ConfigVar { diff --git a/encfs/Context.cpp b/encfs/Context.cpp index cf4cc06..90a1973 100644 --- a/encfs/Context.cpp +++ b/encfs/Context.cpp @@ -19,11 +19,10 @@ */ #include +#include #include "Context.h" #include "DirNode.h" -#include "FileNode.h" -#include "FileUtils.h" #include "Mutex.h" using namespace rel; diff --git a/encfs/Context.h b/encfs/Context.h index 1f6f9b0..1d74883 100644 --- a/encfs/Context.h +++ b/encfs/Context.h @@ -21,22 +21,20 @@ #ifndef _Context_incl_ #define _Context_incl_ +#include +#include #include -#ifdef USE_HASHMAP -#include -#else -#include -#endif #include +#include #include "encfs.h" #include "shared_ptr.h" +class DirNode; +class FileNode; struct EncFS_Args; struct EncFS_Opts; -class FileNode; -class DirNode; class EncFS_Context { public: @@ -88,12 +86,7 @@ class EncFS_Context { Placeholder(const shared_ptr &ptr) : node(ptr) {} }; -#ifdef USE_HASHMAP - // set of open files, indexed by path - typedef __gnu_cxx::hash_map > FileMap; -#else - typedef std::map > FileMap; -#endif + typedef std::unordered_map > FileMap; mutable pthread_mutex_t contextMutex; FileMap openFiles; diff --git a/encfs/DirNode.cpp b/encfs/DirNode.cpp index 7d08b77..9fec2ae 100644 --- a/encfs/DirNode.cpp +++ b/encfs/DirNode.cpp @@ -18,31 +18,33 @@ * along with this program. If not, see . */ -#include "encfs.h" - -#include "DirNode.h" -#include "FileUtils.h" - +#include #include #include +#include +#include #include #include -#include -#include -#include + +#include "DirNode.h" +#include "FSConfig.h" +#include "FileNode.h" +#include "FileUtils.h" +#include "NameIO.h" #ifdef linux #include #endif +#include +#include #include #include "Context.h" -#include "Cipher.h" #include "Mutex.h" -#include -#include -#include +namespace rlog { +class RLogChannel; +} // namespace rlog using namespace std; using namespace rel; @@ -311,7 +313,8 @@ string DirNode::plainPath(const char *cipherPath_) { prefix = "+"; } if (cipherPath_[0] == mark) { - return prefix + naming->decodeName(cipherPath_ + 1, strlen(cipherPath_ + 1)); + return prefix + + naming->decodeName(cipherPath_ + 1, strlen(cipherPath_ + 1)); } // Default. diff --git a/encfs/DirNode.h b/encfs/DirNode.h index 5ec1dc1..9829dcf 100644 --- a/encfs/DirNode.h +++ b/encfs/DirNode.h @@ -21,24 +21,28 @@ #ifndef _DirNode_incl_ #define _DirNode_incl_ -#include #include +#include +#include +#include #include - -#include #include -#include +#include +#include #include +#include -#include "FileNode.h" -#include "NameIO.h" #include "CipherKey.h" #include "FSConfig.h" +#include "FileNode.h" +#include "NameIO.h" class Cipher; +class EncFS_Context; +class FileNode; +class NameIO; class RenameOp; struct RenameEl; -class EncFS_Context; class DirTraverse { public: @@ -72,17 +76,6 @@ class DirTraverse { }; inline bool DirTraverse::valid() const { return dir.get() != 0; } -#ifdef USE_HASHMAP -namespace __gnu_cxx { -template <> -struct hash { - size_t operator()(const std::string &__s) const { - return __stl_hash_string(__s.c_str()); - } -}; -} -#endif - class DirNode { public: // sourceDir points to where raw files are stored diff --git a/encfs/FSConfig.h b/encfs/FSConfig.h index 5cc8fe7..61000dc 100644 --- a/encfs/FSConfig.h +++ b/encfs/FSConfig.h @@ -122,7 +122,8 @@ struct FSConfig { bool idleTracking; // turn on idle monitoring of filesystem - FSConfig() : forceDecode(false), reverseEncryption(false), idleTracking(false) {} + FSConfig() + : forceDecode(false), reverseEncryption(false), idleTracking(false) {} }; typedef shared_ptr FSConfigPtr; diff --git a/encfs/FileIO.h b/encfs/FileIO.h index 602b02a..3031612 100644 --- a/encfs/FileIO.h +++ b/encfs/FileIO.h @@ -21,11 +21,12 @@ #ifndef _FileIO_incl_ #define _FileIO_incl_ -#include "encfs.h" - #include +#include +#include #include "Interface.h" +#include "encfs.h" struct IORequest { off_t offset; diff --git a/encfs/FileNode.cpp b/encfs/FileNode.cpp index d1abfb9..1fc6f1a 100644 --- a/encfs/FileNode.cpp +++ b/encfs/FileNode.cpp @@ -18,37 +18,30 @@ * along with this program. If not, see . */ -// Include encfs first, because we need to include fuse.h before any inclusion -// of sys/stat.h or other system headers (to be safe) -#include "encfs.h" - #include +#include +#include #include #include -#include #include #ifdef linux #include #endif +#include #include -#include "config.h" - +#include "CipherFileIO.h" +#include "FileIO.h" #include "FileNode.h" #include "FileUtils.h" -#include "Cipher.h" -#include "CipherFileIO.h" -#include "RawFileIO.h" #include "MACFileIO.h" -#include "DirNode.h" - -#include "FileIO.h" -#include "MemoryPool.h" #include "Mutex.h" +#include "RawFileIO.h" -#include -#include +namespace rlog { +class RLogChannel; +} // namespace rlog using namespace std; using namespace rel; diff --git a/encfs/FileNode.h b/encfs/FileNode.h index 4fa5acd..de2bb37 100644 --- a/encfs/FileNode.h +++ b/encfs/FileNode.h @@ -21,17 +21,21 @@ #ifndef _FileNode_incl_ #define _FileNode_incl_ -#include "encfs.h" -#include "CipherKey.h" -#include "FileUtils.h" - #include +#include +#include #include +#include #include +#include "CipherKey.h" +#include "FileUtils.h" +#include "FSConfig.h" +#include "encfs.h" + class Cipher; -class FileIO; class DirNode; +class FileIO; class FileNode { public: diff --git a/encfs/FileUtils.cpp b/encfs/FileUtils.cpp index d8e4b86..8b94d34 100644 --- a/encfs/FileUtils.cpp +++ b/encfs/FileUtils.cpp @@ -24,48 +24,46 @@ #endif #define _BSD_SOURCE // pick up setenv on RH7.3 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - #include #include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "encfs.h" -#include "config.h" - -#include "autosprintf.h" -#include "readpassphrase.h" #include "BlockNameIO.h" #include "Cipher.h" +#include "CipherKey.h" #include "ConfigReader.h" +#include "ConfigVar.h" #include "Context.h" #include "DirNode.h" #include "FSConfig.h" #include "FileUtils.h" -#include "NullNameIO.h" -#include "StreamNameIO.h" - +#include "Interface.h" +#include "NameIO.h" +#include "Range.h" +#include "autosprintf.h" +#include "config.h" #include "i18n.h" - +#include "intl/gettext.h" +#include "readpassphrase.h" // disable rlog section grouping for this file.. seems to cause problems #undef RLOG_SECTION @@ -129,7 +127,7 @@ struct ConfigInfo { {".encfs", Config_Prehistoric, NULL, NULL, NULL, 0, 0}, {NULL, Config_None, NULL, NULL, NULL, 0, 0}}; -#include "boost-versioning.h" +#include "boost-versioning.h" // IWYU pragma: keep // define serialization helpers namespace boost { @@ -296,8 +294,9 @@ bool userAllowMkdir(int promptno, const char *path, mode_t mode) { // their own language but then have to respond 'y' or 'n'. // xgroup(setup) cerr << autosprintf( - _("The directory \"%s\" does not exist. Should it be created? " - "(y,n) "), path); + _("The directory \"%s\" does not exist. Should it be created? " + "(y,n) "), + path); char answer[10]; char *res; @@ -338,8 +337,7 @@ ConfigType readConfig_load(ConfigInfo *nm, const char *path, config->cfgType = nm->type; return nm->type; } - } - catch (rlog::Error &err) { + } catch (rlog::Error &err) { err.log(_RLWarningChannel); } @@ -364,8 +362,10 @@ ConfigType readConfig(const string &rootDir, if (nm->environmentOverride != NULL) { char *envFile = getenv(nm->environmentOverride); if (envFile != NULL) { - if (! fileExists(envFile)) { - rError("fatal: config file specified by environment does not exist: %s", envFile); + if (!fileExists(envFile)) { + rError( + "fatal: config file specified by environment does not exist: %s", + envFile); exit(1); } return readConfig_load(nm, envFile, config); @@ -397,8 +397,7 @@ bool readV6Config(const char *configFile, const shared_ptr &config, ia >> BOOST_SERIALIZATION_NVP(*config); return true; - } - catch (boost::archive::archive_exception &e) { + } catch (boost::archive::archive_exception &e) { rError("Archive exception: %s", e.what()); return false; } @@ -453,8 +452,7 @@ bool readV5Config(const char *configFile, const shared_ptr &config, config->blockMACRandBytes = cfgRdr["blockMACRandBytes"].readInt(0); ok = true; - } - catch (rlog::Error &err) { + } catch (rlog::Error &err) { err.log(_RLWarningChannel); rDebug("Error parsing data in config file %s", configFile); ok = false; @@ -494,8 +492,7 @@ bool readV4Config(const char *configFile, const shared_ptr &config, config->chainedNameIV = false; ok = true; - } - catch (rlog::Error &err) { + } catch (rlog::Error &err) { err.log(_RLWarningChannel); rDebug("Error parsing config file %s", configFile); ok = false; @@ -521,8 +518,7 @@ bool saveConfig(ConfigType type, const string &rootDir, try { ok = (*nm->saveFunc)(path.c_str(), config); - } - catch (rlog::Error &err) { + } catch (rlog::Error &err) { err.log(_RLWarningChannel); ok = false; } @@ -667,7 +663,8 @@ static Cipher::CipherAlgorithm selectCipherAlgorithm() { Cipher::CipherAlgorithm alg = *it; // xgroup(setup) - cout << autosprintf(_("Selected algorithm \"%s\""), alg.name.c_str()) << "\n\n"; + cout << autosprintf(_("Selected algorithm \"%s\""), alg.name.c_str()) + << "\n\n"; return alg; } @@ -707,7 +704,8 @@ static Interface selectNameCoding() { ++it; // xgroup(setup) - cout << autosprintf(_("Selected algorithm \"%s\""), it->name.c_str()) << "\"\n\n"; + cout << autosprintf(_("Selected algorithm \"%s\""), it->name.c_str()) + << "\"\n\n"; return it->iface; } @@ -779,12 +777,12 @@ static int selectBlockSize(const Cipher::CipherAlgorithm &alg) { } cout << autosprintf( - // xgroup(setup) - _("Select a block size in bytes. The cipher you have chosen\n" - "supports sizes from %i to %i bytes in increments of %i.\n" - "Or just hit enter for the default (%i bytes)\n"), - alg.blockSize.min(), alg.blockSize.max(), alg.blockSize.inc(), - DefaultBlockSize); + // xgroup(setup) + _("Select a block size in bytes. The cipher you have chosen\n" + "supports sizes from %i to %i bytes in increments of %i.\n" + "Or just hit enter for the default (%i bytes)\n"), + alg.blockSize.min(), alg.blockSize.max(), alg.blockSize.inc(), + DefaultBlockSize); // xgroup(setup) cout << "\n" << _("filesystem block size: "); @@ -824,7 +822,7 @@ static bool boolDefault(const char *prompt, bool defaultValue) { string response; bool value; - while(true) { + while (true) { cout << yesno; getline(cin, response); @@ -867,7 +865,8 @@ static void selectBlockMAC(int *macBytes, int *macRandBytes, bool forceMac) { "within a block will be caught and will cause a read error.")); } else { cout << "\n\n" << _("You specified --require-macs. " - "Enabling block authentication code headers...") << "\n\n"; + "Enabling block authentication code headers...") + << "\n\n"; addMAC = true; } @@ -877,13 +876,14 @@ static void selectBlockMAC(int *macBytes, int *macRandBytes, bool forceMac) { *macBytes = 0; // xgroup(setup) - cout << _("Add random bytes to each block header?\n" - "This adds a performance penalty, but ensures that blocks\n" - "have different authentication codes. Note that you can\n" - "have the same benefits by enabling per-file initialization\n" - "vectors, which does not come with as great of performance\n" - "penalty. \n" - "Select a number of bytes, from 0 (no random bytes) to 8: "); + cout << _( + "Add random bytes to each block header?\n" + "This adds a performance penalty, but ensures that blocks\n" + "have different authentication codes. Note that you can\n" + "have the same benefits by enabling per-file initialization\n" + "vectors, which does not come with as great of performance\n" + "penalty. \n" + "Select a number of bytes, from 0 (no random bytes) to 8: "); char answer[10]; int randSize = 0; @@ -906,7 +906,8 @@ static bool selectUniqueIV(bool default_answer) { _("Enable per-file initialization vectors?\n" "This adds about 8 bytes per file to the storage requirements.\n" "It should not affect performance except possibly with applications\n" - "which rely on block-aligned file io for performance."), default_answer); + "which rely on block-aligned file io for performance."), + default_answer); } /** @@ -964,11 +965,12 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr &opts) { char answer[10] = {0}; if (configMode == Config_Prompt) { // xgroup(setup) - cout << _("Please choose from one of the following options:\n" - " enter \"x\" for expert configuration mode,\n" - " enter \"p\" for pre-configured paranoia mode,\n" - " anything else, or an empty line will select standard mode.\n" - "?> "); + cout << _( + "Please choose from one of the following options:\n" + " enter \"x\" for expert configuration mode,\n" + " enter \"p\" for pre-configured paranoia mode,\n" + " anything else, or an empty line will select standard mode.\n" + "?> "); if (annotate) cerr << "$PROMPT$ config_option" << endl; @@ -977,17 +979,17 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr &opts) { cout << "\n"; } - // documented in ... - int keySize = 0; // selectKeySize() - int blockSize = 0; // selectBlockSize() - Cipher::CipherAlgorithm alg; // selectCipherAlgorithm() - Interface nameIOIface; // selectNameCoding() - int blockMACBytes = 0; // selectBlockMAC() - int blockMACRandBytes = 0; // selectBlockMAC() - bool uniqueIV = true; // selectUniqueIV() - bool chainedIV = true; // selectChainedIV() - bool externalIV = false; // selectExternalChainedIV() - bool allowHoles = true; // selectZeroBlockPassThrough() + // documented in ... + int keySize = 0; // selectKeySize() + int blockSize = 0; // selectBlockSize() + Cipher::CipherAlgorithm alg; // selectCipherAlgorithm() + Interface nameIOIface; // selectNameCoding() + int blockMACBytes = 0; // selectBlockMAC() + int blockMACRandBytes = 0; // selectBlockMAC() + bool uniqueIV = true; // selectUniqueIV() + bool chainedIV = true; // selectChainedIV() + bool externalIV = false; // selectExternalChainedIV() + bool allowHoles = true; // selectZeroBlockPassThrough() long desiredKDFDuration = NormalKDFDuration; if (reverseEncryption) { @@ -1037,9 +1039,10 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr &opts) { if (answer[0] == 'x' || alg.name.empty()) { if (answer[0] != 'x') { // xgroup(setup) - cout << _("Sorry, unable to locate cipher for predefined " - "configuration...\n" - "Falling through to Manual configuration mode."); + cout << _( + "Sorry, unable to locate cipher for predefined " + "configuration...\n" + "Falling through to Manual configuration mode."); } else { // xgroup(setup) cout << _("Manual configuration mode selected."); @@ -1057,8 +1060,7 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr &opts) { /* Reverse mounts are read-only by default (set in main.cpp). * If uniqueIV is off, writing can be allowed, because there * is no header that could be overwritten */ - if (uniqueIV == false) - opts->readOnly = false; + if (uniqueIV == false) opts->readOnly = false; } else { chainedIV = selectChainedIV(); uniqueIV = selectUniqueIV(true); @@ -1125,10 +1127,11 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr &opts) { } // xgroup(setup) - cout << _("Now you will need to enter a password for your filesystem.\n" - "You will need to remember this password, as there is absolutely\n" - "no recovery mechanism. However, the password can be changed\n" - "later using encfsctl.\n\n"); + cout << _( + "Now you will need to enter a password for your filesystem.\n" + "You will need to remember this password, as there is absolutely\n" + "no recovery mechanism. However, the password can be changed\n" + "later using encfsctl.\n\n"); int encodedKeySize = cipher->encodedKeySize(); unsigned char *encodedKey = new unsigned char[encodedKeySize]; @@ -1196,11 +1199,10 @@ void showFSInfo(const shared_ptr &config) { shared_ptr cipher = Cipher::New(config->cipherIface, -1); { cout << autosprintf( - // xgroup(diag) - _("Filesystem cipher: \"%s\", version %i:%i:%i"), - config->cipherIface.name().c_str(), - config->cipherIface.current(), config->cipherIface.revision(), - config->cipherIface.age()); + // xgroup(diag) + _("Filesystem cipher: \"%s\", version %i:%i:%i"), + config->cipherIface.name().c_str(), config->cipherIface.current(), + config->cipherIface.revision(), config->cipherIface.age()); // check if we support this interface.. if (!cipher) cout << _(" (NOT supported)\n"); @@ -1210,7 +1212,7 @@ void showFSInfo(const shared_ptr &config) { Interface iface = cipher->interface(); // xgroup(diag) cout << autosprintf(_(" (using %i:%i:%i)\n"), iface.current(), - iface.revision(), iface.age()); + iface.revision(), iface.age()); } else cout << "\n"; } @@ -1218,8 +1220,9 @@ void showFSInfo(const shared_ptr &config) { { // xgroup(diag) cout << autosprintf(_("Filename encoding: \"%s\", version %i:%i:%i"), - config->nameIface.name().c_str(), config->nameIface.current(), - config->nameIface.revision(), config->nameIface.age()); + config->nameIface.name().c_str(), + config->nameIface.current(), + config->nameIface.revision(), config->nameIface.age()); // check if we support the filename encoding interface.. shared_ptr nameCoder = @@ -1232,7 +1235,7 @@ void showFSInfo(const shared_ptr &config) { if (config->nameIface != nameCoder->interface()) { Interface iface = nameCoder->interface(); cout << autosprintf(_(" (using %i:%i:%i)\n"), iface.current(), - iface.revision(), iface.age()); + iface.revision(), iface.age()); } else cout << "\n"; } @@ -1248,8 +1251,9 @@ void showFSInfo(const shared_ptr &config) { } if (config->kdfIterations > 0 && config->salt.size() > 0) { cout << autosprintf(_("Using PBKDF2, with %i iterations"), - config->kdfIterations) << "\n"; - cout << autosprintf(_("Salt Size: %i bits"), (int)(8 * config->salt.size())) << "\n"; + config->kdfIterations) << "\n"; + cout << autosprintf(_("Salt Size: %i bits"), (int)(8 * config->salt.size())) + << "\n"; } if (config->blockMACBytes || config->blockMACRandBytes) { if (config->subVersion < 20040813) { @@ -1448,7 +1452,7 @@ CipherKey EncFSConfig::getUserKey(const std::string &passProg, snprintf(tmpBuf, sizeof(tmpBuf) - 1, "%i", stdErrCopy); setenv(ENCFS_ENV_STDERR, tmpBuf, 1); - execvp(argv[0], (char * const *)argv); // returns only on error.. + execvp(argv[0], (char *const *)argv); // returns only on error.. perror(_("Internal error: failed to exec program")); exit(1); @@ -1502,17 +1506,16 @@ RootPtr initFS(EncFS_Context *ctx, const shared_ptr &opts) { if (readConfig(opts->rootDir, config) != Config_None) { if (config->blockMACBytes == 0 && opts->requireMac) { - cout - << _("The configuration disabled MAC, but you passed --require-macs\n"); + cout << _( + "The configuration disabled MAC, but you passed --require-macs\n"); return rootInfo; } if (opts->reverseEncryption) { if (config->blockMACBytes != 0 || config->blockMACRandBytes != 0 || - config->externalIVChaining || - config->chainedNameIV) { - cout - << _("The configuration loaded is not compatible with --reverse\n"); + config->externalIVChaining || config->chainedNameIV) { + cout << _( + "The configuration loaded is not compatible with --reverse\n"); return rootInfo; } } @@ -1566,8 +1569,9 @@ RootPtr initFS(EncFS_Context *ctx, const shared_ptr &opts) { config->nameIface.name().c_str(), config->nameIface.current(), config->nameIface.revision(), config->nameIface.age()); // xgroup(diag) - cout << _("The requested filename coding interface is " - "not available\n"); + cout << _( + "The requested filename coding interface is " + "not available\n"); return rootInfo; } diff --git a/encfs/FileUtils.h b/encfs/FileUtils.h index 2e4f512..ced272f 100644 --- a/encfs/FileUtils.h +++ b/encfs/FileUtils.h @@ -21,10 +21,14 @@ #ifndef _FileUtils_incl_ #define _FileUtils_incl_ -#include "encfs.h" -#include "Interface.h" +#include +#include +#include + #include "CipherKey.h" #include "FSConfig.h" +#include "Interface.h" +#include "encfs.h" // true if the path points to an existing node (of any type) bool fileExists(const char *fileName); @@ -86,9 +90,9 @@ struct EncFS_Opts { * behind the back of EncFS (for example, in reverse mode). * See main.cpp for a longer explaination. */ - bool readOnly; // Mount read-only + bool readOnly; // Mount read-only - bool requireMac; // Throw an error if MAC is disabled + bool requireMac; // Throw an error if MAC is disabled ConfigMode configMode; diff --git a/encfs/Interface.cpp b/encfs/Interface.cpp index 3e78689..46f4dc4 100644 --- a/encfs/Interface.cpp +++ b/encfs/Interface.cpp @@ -20,10 +20,13 @@ #include "Interface.h" +#include + #include "ConfigVar.h" -#include -#include +namespace rlog { +class RLogChannel; +} // namespace rlog using namespace rel; using namespace rlog; diff --git a/encfs/MACFileIO.cpp b/encfs/MACFileIO.cpp index d432a02..a572150 100644 --- a/encfs/MACFileIO.cpp +++ b/encfs/MACFileIO.cpp @@ -20,17 +20,23 @@ #include "MACFileIO.h" -#include "MemoryPool.h" -#include "FileUtils.h" - -#include +#include #include -#include - +#include +#include #include +#include "BlockFileIO.h" +#include "Cipher.h" +#include "FileIO.h" +#include "FileUtils.h" +#include "MemoryPool.h" #include "i18n.h" +namespace rlog { +class RLogChannel; +} // namespace rlog + using namespace rlog; using namespace rel; using namespace std; diff --git a/encfs/MACFileIO.h b/encfs/MACFileIO.h index 1e5666d..94dac83 100644 --- a/encfs/MACFileIO.h +++ b/encfs/MACFileIO.h @@ -21,8 +21,19 @@ #ifndef _MACFileIO_incl_ #define _MACFileIO_incl_ +#include +#include +#include + #include "BlockFileIO.h" #include "Cipher.h" +#include "CipherKey.h" +#include "FSConfig.h" +#include "Interface.h" + +class Cipher; +class FileIO; +struct IORequest; class MACFileIO : public BlockFileIO { public: diff --git a/encfs/MemoryPool.cpp b/encfs/MemoryPool.cpp index e19d5f4..d21bdb0 100644 --- a/encfs/MemoryPool.cpp +++ b/encfs/MemoryPool.cpp @@ -19,13 +19,10 @@ */ #include "MemoryPool.h" -#include -#include -#include - -#include "config.h" +#include #include +#include #ifdef HAVE_VALGRIND_MEMCHECK_H #include @@ -34,9 +31,8 @@ #define VALGRIND_MAKE_MEM_UNDEFINED(a, b) #endif -using namespace rlog; - #include + #define BLOCKDATA(BLOCK) (unsigned char *) BLOCK->data->data struct BlockList { diff --git a/encfs/NameIO.cpp b/encfs/NameIO.cpp index 35ed038..682c089 100644 --- a/encfs/NameIO.cpp +++ b/encfs/NameIO.cpp @@ -19,20 +19,21 @@ */ #include "NameIO.h" -#include "config.h" -#include #include - -#include +#include #include - // for static build. Need to reference the modules which are registered at // run-time, to ensure that the linker doesn't optimize them away. #include +#include +#include + #include "BlockNameIO.h" -#include "StreamNameIO.h" +#include "CipherKey.h" +#include "Interface.h" #include "NullNameIO.h" +#include "StreamNameIO.h" using namespace std; using namespace rel; diff --git a/encfs/NameIO.h b/encfs/NameIO.h index 8c0591e..916c2c2 100644 --- a/encfs/NameIO.h +++ b/encfs/NameIO.h @@ -21,13 +21,15 @@ #ifndef _NameIO_incl_ #define _NameIO_incl_ -#include -#include - #include +#include +#include +#include +#include +#include -#include "Interface.h" #include "CipherKey.h" +#include "Interface.h" class Cipher; diff --git a/encfs/NullCipher.cpp b/encfs/NullCipher.cpp index 93a153f..3423b54 100644 --- a/encfs/NullCipher.cpp +++ b/encfs/NullCipher.cpp @@ -21,11 +21,11 @@ #include "NullCipher.h" #include -#include +#include -#include "Range.h" +#include "Cipher.h" #include "Interface.h" -#include "shared_ptr.h" +#include "Range.h" using namespace std; using namespace rel; diff --git a/encfs/NullCipher.h b/encfs/NullCipher.h index 0e46ea5..3dd63d8 100644 --- a/encfs/NullCipher.h +++ b/encfs/NullCipher.h @@ -21,7 +21,10 @@ #ifndef _NullCipher_incl_ #define _NullCipher_incl_ +#include + #include "Cipher.h" +#include "CipherKey.h" #include "Interface.h" /* diff --git a/encfs/NullNameIO.cpp b/encfs/NullNameIO.cpp index d4b331b..ec18a4f 100644 --- a/encfs/NullNameIO.cpp +++ b/encfs/NullNameIO.cpp @@ -20,10 +20,13 @@ #include "NullNameIO.h" -#include "Cipher.h" -#include "base64.h" - #include +#include + +#include "CipherKey.h" +#include "NameIO.h" + +class Cipher; using namespace rel; diff --git a/encfs/NullNameIO.h b/encfs/NullNameIO.h index 2de8f58..5591e18 100644 --- a/encfs/NullNameIO.h +++ b/encfs/NullNameIO.h @@ -21,6 +21,9 @@ #ifndef _NullNameIO_incl_ #define _NullNameIO_incl_ +#include + +#include "Interface.h" #include "NameIO.h" class NullNameIO : public NameIO { diff --git a/encfs/RawFileIO.cpp b/encfs/RawFileIO.cpp index b567d0b..339a3f9 100644 --- a/encfs/RawFileIO.cpp +++ b/encfs/RawFileIO.cpp @@ -21,18 +21,16 @@ #ifdef linux #define _XOPEN_SOURCE 500 // pick up pread , pwrite #endif -#include - -#include "RawFileIO.h" - -#include - -#include -#include #include +#include +#include +#include +#include +#include #include -#include +#include "FileIO.h" +#include "RawFileIO.h" using namespace std; diff --git a/encfs/RawFileIO.h b/encfs/RawFileIO.h index 90e68ec..12b36d1 100644 --- a/encfs/RawFileIO.h +++ b/encfs/RawFileIO.h @@ -21,10 +21,12 @@ #ifndef _RawFileIO_incl_ #define _RawFileIO_incl_ -#include "FileIO.h" - +#include #include +#include "Interface.h" +#include "FileIO.h" + class RawFileIO : public FileIO { public: RawFileIO(); diff --git a/encfs/SSL_Cipher.cpp b/encfs/SSL_Cipher.cpp index 50f1d95..ebac89d 100644 --- a/encfs/SSL_Cipher.cpp +++ b/encfs/SSL_Cipher.cpp @@ -18,38 +18,37 @@ * along with this program. If not, see . */ -#include "encfs.h" - -#include "config.h" - -#include -#include -#include +#include #include +#include #include - -#include "SSL_Cipher.h" -#include "Range.h" -#include "MemoryPool.h" -#include "Mutex.h" - -#include -#include - +#include +#include +#include +#include +#include #include #include +#include +#include -#include -#include +#include "Cipher.h" +#include "Interface.h" +#include "Mutex.h" +#include "Range.h" +#include "SSL_Cipher.h" +#include "intl/gettext.h" -#include "i18n.h" +namespace rlog { +class RLogChannel; +} // namespace rlog using namespace std; using namespace rel; using namespace rlog; const int MAX_KEYLENGTH = 32; // in bytes (256 bit) -const int MAX_IVLENGTH = 16; // 128 bit (AES block size, Blowfish has 64) +const int MAX_IVLENGTH = 16; // 128 bit (AES block size, Blowfish has 64) const int KEY_CHECKSUM_BYTES = 4; #ifndef MIN @@ -674,21 +673,21 @@ void SSL_Cipher::setIVec_old(unsigned char *ivec, unsigned int seed, ivec[0] ^= (var1 >> 24) & 0xff; ivec[1] ^= (var2 >> 16) & 0xff; ivec[2] ^= (var1 >> 8) & 0xff; - ivec[3] ^= (var2) & 0xff; + ivec[3] ^= (var2)&0xff; ivec[4] ^= (var2 >> 24) & 0xff; ivec[5] ^= (var1 >> 16) & 0xff; ivec[6] ^= (var2 >> 8) & 0xff; - ivec[7] ^= (var1) & 0xff; + ivec[7] ^= (var1)&0xff; if (_ivLength > 8) { - ivec[8 + 0] ^= (var1) & 0xff; + ivec[8 + 0] ^= (var1)&0xff; ivec[8 + 1] ^= (var2 >> 8) & 0xff; ivec[8 + 2] ^= (var1 >> 16) & 0xff; ivec[8 + 3] ^= (var2 >> 24) & 0xff; ivec[8 + 4] ^= (var1 >> 24) & 0xff; ivec[8 + 5] ^= (var2 >> 16) & 0xff; ivec[8 + 6] ^= (var1 >> 8) & 0xff; - ivec[8 + 7] ^= (var2) & 0xff; + ivec[8 + 7] ^= (var2)&0xff; } } diff --git a/encfs/SSL_Cipher.h b/encfs/SSL_Cipher.h index f79f2b5..76badc1 100644 --- a/encfs/SSL_Cipher.h +++ b/encfs/SSL_Cipher.h @@ -21,12 +21,17 @@ #ifndef _SSL_Cipher_incl_ #define _SSL_Cipher_incl_ +#include +#include + #include "Cipher.h" +#include "CipherKey.h" #include "Interface.h" class SSLKey; #ifndef EVP_CIPHER struct evp_cipher_st; + typedef struct evp_cipher_st EVP_CIPHER; #endif diff --git a/encfs/StreamNameIO.cpp b/encfs/StreamNameIO.cpp index 1cd94f9..c111198 100644 --- a/encfs/StreamNameIO.cpp +++ b/encfs/StreamNameIO.cpp @@ -20,15 +20,16 @@ #include "StreamNameIO.h" -#include "Cipher.h" -#include "base64.h" - -#include #include - -#include "i18n.h" +#include #include +#include "Cipher.h" +#include "CipherKey.h" +#include "NameIO.h" +#include "base64.h" +#include "intl/gettext.h" + using namespace rel; using namespace std; @@ -101,12 +102,12 @@ int StreamNameIO::encodeName(const char *plaintextName, int length, if (_interface >= 1) { // current versions store the checksum at the beginning encodedName[0] = (mac >> 8) & 0xff; - encodedName[1] = (mac) & 0xff; + encodedName[1] = (mac)&0xff; encodeBegin = (unsigned char *)encodedName + 2; } else { // encfs 0.x stored checksums at the end. encodedName[length] = (mac >> 8) & 0xff; - encodedName[length + 1] = (mac) & 0xff; + encodedName[length + 1] = (mac)&0xff; encodeBegin = (unsigned char *)encodedName; } diff --git a/encfs/StreamNameIO.h b/encfs/StreamNameIO.h index 3149ce8..723fc6d 100644 --- a/encfs/StreamNameIO.h +++ b/encfs/StreamNameIO.h @@ -21,8 +21,12 @@ #ifndef _StreamNameIO_incl_ #define _StreamNameIO_incl_ -#include "NameIO.h" +#include +#include + #include "CipherKey.h" +#include "Interface.h" +#include "NameIO.h" class Cipher; diff --git a/encfs/autosprintf.cpp b/encfs/autosprintf.cpp index 955b74f..16e8549 100644 --- a/encfs/autosprintf.cpp +++ b/encfs/autosprintf.cpp @@ -28,10 +28,11 @@ #include "autosprintf.h" #include -#include -#include +#include //#include "lib-asprintf.h" #include +#include +#include namespace gnu { diff --git a/encfs/autosprintf.h b/encfs/autosprintf.h index 339e60b..2ebb66b 100644 --- a/encfs/autosprintf.h +++ b/encfs/autosprintf.h @@ -42,7 +42,7 @@ class autosprintf { public: /* Constructor: takes a format string and the printf arguments. */ autosprintf(const char* format, ...) - __attribute__((__format__(__printf__, 2, 3))); + __attribute__((__format__(__printf__, 2, 3))); /* Copy constructor. */ autosprintf(const autosprintf& src); /* Destructor: frees the temporarily allocated string. */ diff --git a/encfs/boost-versioning.h b/encfs/boost-versioning.h index 8d9c00e..7f97ab3 100644 --- a/encfs/boost-versioning.h +++ b/encfs/boost-versioning.h @@ -18,8 +18,6 @@ BOOST_CLASS_VERSION(EncFSConfig, V6SubVersion) // we specify in BOOST_CLASS_VERSION below. Without this, manual editing // of the file is needed before boost will allow us to read it. -// See bug http://code.google.com/p/encfs/issues/detail?id=60 - BOOST_CLASS_VERSION(EncFSConfig, 20) namespace boost { @@ -62,7 +60,7 @@ class iserializer : public basic_iserializer { virtual bool is_polymorphic() const { return boost::is_polymorphic::value; } - virtual ~iserializer() {}; + virtual ~iserializer(){}; }; template diff --git a/encfs/encfs.cpp b/encfs/encfs.cpp index 73b3e18..f128834 100644 --- a/encfs/encfs.cpp +++ b/encfs/encfs.cpp @@ -17,16 +17,20 @@ #include "encfs.h" -#include -#include -#include #include -#include -#include +#include +#include +#include #include #include - -#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef linux #include #endif @@ -37,19 +41,24 @@ #include #endif +#include +#include #include -#include #include #include -#include "DirNode.h" -#include "MemoryPool.h" -#include "FileUtils.h" -#include "Mutex.h" #include "Context.h" +#include "DirNode.h" +#include "FileNode.h" +#include "FileUtils.h" +#include "fuse.h" -#include -#include +namespace rel { +class Lock; +} // namespace rel +namespace rlog { +class RLogChannel; +} // namespace rlog #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) @@ -76,8 +85,7 @@ static EncFS_Context *context() { * if the argument is NULL. */ static bool isReadOnly(EncFS_Context *ctx) { - if (ctx == NULL) - ctx = (EncFS_Context *)fuse_get_context()->private_data; + if (ctx == NULL) ctx = (EncFS_Context *)fuse_get_context()->private_data; return ctx->opts->readOnly; } diff --git a/encfs/encfs.h b/encfs/encfs.h index 684ab1d..6539e50 100644 --- a/encfs/encfs.h +++ b/encfs/encfs.h @@ -21,11 +21,12 @@ #ifndef _encfs_incl_ #define _encfs_incl_ -#include "config.h" #include +#include +#include #include -#include +#include "config.h" #if defined(HAVE_SYS_XATTR_H) | defined(HAVE_ATTR_XATTR_H) #define HAVE_XATTR diff --git a/encfs/encfsctl.cpp b/encfs/encfsctl.cpp index 08782eb..369c35b 100644 --- a/encfs/encfsctl.cpp +++ b/encfs/encfsctl.cpp @@ -15,32 +15,37 @@ * more details. */ -#include "encfs.h" - #include #include -#include -#include -#include -#include #include - -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define NO_DES #include #include "Cipher.h" -#include "Context.h" +#include "CipherKey.h" #include "DirNode.h" +#include "FSConfig.h" #include "FileNode.h" #include "FileUtils.h" +#include "Interface.h" #include "autosprintf.h" #include "config.h" #include "i18n.h" -#include "shared_ptr.h" +#include "intl/gettext.h" #ifndef PATH_MAX #define PATH_MAX 4096 @@ -453,7 +458,7 @@ static int copyContents(const shared_ptr &rootInfo, return EXIT_FAILURE; } if (symlink(rootInfo->root->plainPath(linkContents).c_str(), - targetName) != 0) { + targetName) != 0) { cerr << "unable to create symlink " << targetName << "\n"; return EXIT_FAILURE; } @@ -592,7 +597,8 @@ static int cmd_showcruft(int argc, char **argv) { int filesFound = showcruft(rootInfo, "/"); - // TODO: the singular version should say "Found an invalid file", but all the translations + // TODO: the singular version should say "Found an invalid file", but all the + // translations // depend upon this broken singular form, so it isn't easy to change. cerr << autosprintf(ngettext("Found %i invalid file.", "Found %i invalid files.", filesFound), @@ -701,9 +707,6 @@ int main(int argc, char **argv) { StdioNode *slog = new StdioNode(STDERR_FILENO); slog->subscribeTo(GetGlobalChannel("error")); slog->subscribeTo(GetGlobalChannel("warning")); -#ifndef NO_DEBUG -// slog->subscribeTo( GetGlobalChannel("debug") ); -#endif if (argc < 2) { usage(argv[0]); diff --git a/encfs/main.cpp b/encfs/main.cpp index 4b7a6d9..adcd08b 100644 --- a/encfs/main.cpp +++ b/encfs/main.cpp @@ -16,41 +16,37 @@ * */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include +#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "autosprintf.h" -#include "ConfigReader.h" #include "Context.h" -#include "DirNode.h" #include "FileUtils.h" -#include "Interface.h" #include "MemoryPool.h" +#include "autosprintf.h" #include "config.h" #include "encfs.h" -#include "openssl.h" -#include "shared_ptr.h" - -#include - +#include "fuse.h" #include "i18n.h" +#include "openssl.h" + +class DirNode; // Fuse version >= 26 requires another argument to fuse_unmount, which we // don't have. So use the backward compatible call instead.. @@ -60,7 +56,7 @@ extern "C" void fuse_unmount_compat22(const char *mountpoint); /* Arbitrary identifiers for long options that do * not have a short version */ #define LONG_OPT_ANNOTATE 513 -#define LONG_OPT_NOCACHE 514 +#define LONG_OPT_NOCACHE 514 #define LONG_OPT_REQUIRE_MAC 515 using namespace std; @@ -223,15 +219,16 @@ static bool processArgs(int argc, char *argv[], {"public", 0, 0, 'P'}, // public mode {"extpass", 1, 0, 'p'}, // external password program // {"single-thread", 0, 0, 's'}, // single-threaded mode - {"stdinpass", 0, 0, 'S'}, // read password from stdin - {"annotate", 0, 0, LONG_OPT_ANNOTATE}, // Print annotation lines to stderr - {"nocache", 0, 0, LONG_OPT_NOCACHE}, // disable caching - {"verbose", 0, 0, 'v'}, // verbose mode - {"version", 0, 0, 'V'}, // version - {"reverse", 0, 0, 'r'}, // reverse encryption - {"standard", 0, 0, '1'}, // standard configuration - {"paranoia", 0, 0, '2'}, // standard configuration - {"require-macs", 0, 0, LONG_OPT_REQUIRE_MAC}, // require MACs + {"stdinpass", 0, 0, 'S'}, // read password from stdin + {"annotate", 0, 0, + LONG_OPT_ANNOTATE}, // Print annotation lines to stderr + {"nocache", 0, 0, LONG_OPT_NOCACHE}, // disable caching + {"verbose", 0, 0, 'v'}, // verbose mode + {"version", 0, 0, 'V'}, // version + {"reverse", 0, 0, 'r'}, // reverse encryption + {"standard", 0, 0, '1'}, // standard configuration + {"paranoia", 0, 0, '2'}, // standard configuration + {"require-macs", 0, 0, LONG_OPT_REQUIRE_MAC}, // require MACs {0, 0, 0, 0}}; while (1) { @@ -309,7 +306,7 @@ static bool processArgs(int argc, char *argv[], * However, disabling the caches causes a factor 3 * slowdown. If you are concerned about inconsistencies, * please use --nocache. */ - break; + break; case LONG_OPT_NOCACHE: /* Disable EncFS block cache * Causes reverse grow tests to fail because short reads @@ -404,8 +401,8 @@ static bool processArgs(int argc, char *argv[], // "default_permissions" comes with a performance cost. Only enable // it if makes sense. - for(int i=0; i < out->fuseArgc; i++) { - if ( out->fuseArgv[i] == NULL ) { + for (int i = 0; i < out->fuseArgc; i++) { + if (out->fuseArgv[i] == NULL) { continue; } else if (strcmp(out->fuseArgv[i], "allow_other") == 0) { PUSHARG("-o"); @@ -415,7 +412,8 @@ static bool processArgs(int argc, char *argv[], } #if defined(__APPLE__) - // With OSXFuse, the 'local' flag selects a local filesystem mount icon in Finder. + // With OSXFuse, the 'local' flag selects a local filesystem mount icon in + // Finder. PUSHARG("-o"); PUSHARG("local"); #endif @@ -612,18 +610,6 @@ int main(int argc, char *argv[]) { encfs_oper.utimens = encfs_utimens; // encfs_oper.bmap = encfs_bmap; -#if (__FreeBSD__ >= 10) || defined(__APPLE__) -// encfs_oper.setvolname -// encfs_oper.exchange -// encfs_oper.getxtimes -// encfs_oper.setbkuptime -// encfs_oper.setchgtime -// encfs_oper.setcrtime -// encfs_oper.chflags -// encfs_oper.setattr_x -// encfs_oper.fsetattr_x -#endif - openssl_init(encfsArgs->isThreaded); // context is not a smart pointer because it will live for the life of @@ -700,7 +686,8 @@ int main(int argc, char *argv[]) { // xgroup(usage) fputs(_("fuse failed. Common problems:\n" " - fuse kernel module not installed (modprobe fuse)\n" - " - invalid options -- see usage message\n"), out); + " - invalid options -- see usage message\n"), + out); fclose(out); } } catch (std::exception &ex) { diff --git a/encfs/makeKey.cpp b/encfs/makeKey.cpp index f4e2195..35471cc 100644 --- a/encfs/makeKey.cpp +++ b/encfs/makeKey.cpp @@ -18,17 +18,16 @@ * this program. If not, see . */ -#include "encfs.h" +#include +#include +#include +#include +#include #include "Cipher.h" #include "CipherKey.h" #include "openssl.h" -#include - -#include -#include - using namespace std; void genKey(const shared_ptr &cipher) { diff --git a/encfs/openssl.cpp b/encfs/openssl.cpp index db7ff03..6128294 100644 --- a/encfs/openssl.cpp +++ b/encfs/openssl.cpp @@ -20,13 +20,14 @@ #include "openssl.h" +#include #include - #include +#include #define NO_DES -#include #include +#include #ifndef OPENSSL_NO_ENGINE #include #endif diff --git a/encfs/readpassphrase.cpp b/encfs/readpassphrase.cpp index a354f97..a400b01 100644 --- a/encfs/readpassphrase.cpp +++ b/encfs/readpassphrase.cpp @@ -37,18 +37,17 @@ static const char rcsid[] = #ifndef HAVE_READPASSPHRASE +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include #include -#include -#include #include "readpassphrase.h" #ifdef TCSASOFT diff --git a/encfs/readpassphrase.h b/encfs/readpassphrase.h index e17db34..1c4f993 100644 --- a/encfs/readpassphrase.h +++ b/encfs/readpassphrase.h @@ -1,4 +1,5 @@ -/* $OpenBSD: readpassphrase.h,v 1.1 2000/11/21 00:48:38 millert Exp $ */ +/* $OpenBSD: readpassphrase.h,v 1.1 2000/11/21 00:48:38 millert Exp $ + */ /* * Copyright (c) 2000 Todd C. Miller @@ -35,17 +36,18 @@ #ifndef HAVE_READPASSPHRASE -#define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */ -#define RPP_ECHO_ON 0x01 /* Leave echo on. */ -#define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */ -#define RPP_FORCELOWER 0x04 /* Force input to lower case. */ -#define RPP_FORCEUPPER 0x08 /* Force input to upper case. */ -#define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */ +#define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */ +#define RPP_ECHO_ON 0x01 /* Leave echo on. */ +#define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */ +#define RPP_FORCELOWER 0x04 /* Force input to lower case. */ +#define RPP_FORCEUPPER 0x08 /* Force input to upper case. */ +#define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */ #ifdef __cplusplus extern "C" #endif -char *readpassphrase(const char *prompt, char *buf, size_t bufSize, int flags); + char * + readpassphrase(const char *prompt, char *buf, size_t bufSize, int flags); #endif /* HAVE_READPASSPHRASE */ diff --git a/encfs/test.cpp b/encfs/test.cpp index 22d7242..6bd8f70 100644 --- a/encfs/test.cpp +++ b/encfs/test.cpp @@ -16,28 +16,30 @@ * */ -#include "encfs.h" - -#include "config.h" - -#include - -#include -#include - -#include "Cipher.h" -#include "DirNode.h" -#include "MemoryPool.h" -#include "Interface.h" -#include "FileUtils.h" -#include "StreamNameIO.h" -#include "BlockNameIO.h" -#include "NullNameIO.h" - -#include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "BlockNameIO.h" +#include "Cipher.h" +#include "CipherKey.h" +#include "DirNode.h" +#include "FSConfig.h" +#include "FileUtils.h" +#include "Interface.h" +#include "MemoryPool.h" +#include "NameIO.h" +#include "Range.h" +#include "StreamNameIO.h" #define NO_DES #include @@ -363,7 +365,8 @@ bool runTests(const shared_ptr &cipher, bool verbose) { static bool testCipherSize(const string &name, int keySize, int blockSize, bool verbose) { - cerr << name << ", key length " << keySize << ", block size " << blockSize << ": "; + cerr << name << ", key length " << keySize << ", block size " << blockSize + << ": "; shared_ptr cipher = Cipher::New(name, keySize); if (!cipher) { @@ -429,8 +432,8 @@ int main(int argc, char *argv[]) { if (!testCipherSize(it->name, keySize, blockSize, false)) { // Run again in verbose mode, then exit with error. if (testCipherSize(it->name, keySize, blockSize, true)) { - cerr << "Inconsistent test results!\n"; - } + cerr << "Inconsistent test results!\n"; + } return 1; } }