Merge pull request #89 from vgough/cleanup

Cleanup formatting and includes.
This commit is contained in:
Valient Gough 2015-06-17 23:37:40 -07:00
commit 6700a76c0d
51 changed files with 534 additions and 479 deletions

View File

@ -3,8 +3,9 @@ project(EncFS C CXX)
set (ENCFS_MAJOR 1) set (ENCFS_MAJOR 1)
set (ENCFS_MINOR 9) set (ENCFS_MINOR 9)
set (ENCFS_VERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}") set (ENCFS_PATCH 0)
set (ENCFS_SOVERSION 7) set (ENCFS_VERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}.${ENCFS_PATCH}")
set (ENCFS_SOVERSION "1.9")
set (ENCFS_NAME "Encrypted Filesystem") set (ENCFS_NAME "Encrypted Filesystem")
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}

View File

@ -20,14 +20,16 @@
#include "BlockFileIO.h" #include "BlockFileIO.h"
#include "MemoryPool.h" #include <inttypes.h>
#include <cstring>
#include <rlog/rlog.h> #include <rlog/rlog.h>
#include <cstring>
#include <memory>
#include "i18n.h" #include "FSConfig.h"
#include "FileIO.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "MemoryPool.h"
#include "i18n.h"
template <typename Type> template <typename Type>
inline Type min(Type A, Type B) { inline Type min(Type A, Type B) {
@ -67,7 +69,7 @@ ssize_t BlockFileIO::cacheReadOneBlock(const IORequest &req) const {
* in the last block of a file, which may be smaller than the blocksize. * 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 * For reverse encryption, the cache must not be used at all, because
* the lower file may have changed behind our back. */ * the lower file may have changed behind our back. */
if ( (_noCache == false) && (req.offset == _cache.offset) && if ((_noCache == false) && (req.offset == _cache.offset) &&
(_cache.dataLen != 0)) { (_cache.dataLen != 0)) {
// satisfy request from cache // satisfy request from cache
int len = req.dataLen; int len = req.dataLen;

View File

@ -21,8 +21,10 @@
#ifndef _BlockFileIO_incl_ #ifndef _BlockFileIO_incl_
#define _BlockFileIO_incl_ #define _BlockFileIO_incl_
#include "FileIO.h" #include <sys/types.h>
#include "FSConfig.h" #include "FSConfig.h"
#include "FileIO.h"
/* /*
Implements block scatter / gather interface. Requires derived classes to Implements block scatter / gather interface. Requires derived classes to

View File

@ -20,15 +20,19 @@
#include "BlockNameIO.h" #include "BlockNameIO.h"
#include "Cipher.h"
#include "base64.h"
#include <cstring>
#include <rlog/rlog.h>
#include <rlog/Error.h> #include <rlog/Error.h>
#include <rlog/RLogChannel.h> #include <rlog/rlog.h>
#include <cstring>
#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 rlog;
using namespace rel; using namespace rel;
@ -151,7 +155,7 @@ int BlockNameIO::encodeName(const char *plaintextName, int length, uint64_t *iv,
// add checksum bytes // add checksum bytes
encodedName[0] = (mac >> 8) & 0xff; encodedName[0] = (mac >> 8) & 0xff;
encodedName[1] = (mac) & 0xff; encodedName[1] = (mac)&0xff;
_cipher->blockEncode((unsigned char *)encodedName + 2, length + padding, _cipher->blockEncode((unsigned char *)encodedName + 2, length + padding,
(uint64_t)mac ^ tmpIV, _key); (uint64_t)mac ^ tmpIV, _key);
@ -184,8 +188,7 @@ int BlockNameIO::decodeName(const char *encodedName, int length, uint64_t *iv,
int decodedStreamLen = decLen256 - 2; int decodedStreamLen = decLen256 - 2;
// don't bother trying to decode files which are too small // don't bother trying to decode files which are too small
if (decodedStreamLen < _bs) if (decodedStreamLen < _bs) {
{
rDebug("Rejecting filename '%s'", encodedName); rDebug("Rejecting filename '%s'", encodedName);
throw ERROR("Filename too small to decode"); throw ERROR("Filename too small to decode");
} }

View File

@ -21,8 +21,12 @@
#ifndef _BlockNameIO_incl_ #ifndef _BlockNameIO_incl_
#define _BlockNameIO_incl_ #define _BlockNameIO_incl_
#include "NameIO.h" #include <stdint.h>
#include <memory>
#include "CipherKey.h" #include "CipherKey.h"
#include "Interface.h"
#include "NameIO.h"
#include "shared_ptr.h" #include "shared_ptr.h"
class Cipher; class Cipher;

View File

@ -18,22 +18,22 @@
* 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 "config.h" #include <stddef.h>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <utility>
#include "Cipher.h" #include "Cipher.h"
#include "CipherKey.h"
#include "Interface.h" #include "Interface.h"
#include "Range.h"
#include "base64.h"
#include <map>
#include <list>
#include <string>
#include <iostream>
// for static build. Need to reference the modules which are registered at // for static build. Need to reference the modules which are registered at
// run-time, to ensure that the linker doesn't optimize them away. // run-time, to ensure that the linker doesn't optimize them away.
#include "NullCipher.h" #include "NullCipher.h"
#include "Range.h"
#include "SSL_Cipher.h" #include "SSL_Cipher.h"
#include "base64.h"
using namespace std; using namespace std;
using namespace rel; using namespace rel;

View File

@ -21,15 +21,16 @@
#ifndef _Cipher_incl_ #ifndef _Cipher_incl_
#define _Cipher_incl_ #define _Cipher_incl_
#include "encfs.h"
#include "Range.h"
#include "Interface.h"
#include "CipherKey.h"
#include <string>
#include <list>
#include <inttypes.h> #include <inttypes.h>
#include <stdint.h>
#include <list>
#include <memory>
#include <string>
#include "CipherKey.h"
#include "Interface.h"
#include "Range.h"
#include "encfs.h"
/* /*
Mostly pure virtual interface defining operations on a cipher. Mostly pure virtual interface defining operations on a cipher.

View File

@ -20,17 +20,19 @@
#include "CipherFileIO.h" #include "CipherFileIO.h"
#include "Cipher.h"
#include "MemoryPool.h"
#include <rlog/rlog.h>
#include <rlog/Error.h>
#include <fcntl.h> #include <fcntl.h>
#include <cerrno> #include <inttypes.h>
#include <string.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <rlog/Error.h>
#include <rlog/rlog.h>
#include <string.h>
#include <sys/stat.h>
#include <cerrno>
#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 - 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 // adjust size if we have a file header
if ((res == 0) && haveHeader && S_ISREG(stbuf->st_mode) && if ((res == 0) && haveHeader && S_ISREG(stbuf->st_mode) &&
(stbuf->st_size > 0)) { (stbuf->st_size > 0)) {
if(!fsConfig->reverseEncryption) if (!fsConfig->reverseEncryption) {
{
/* In normal mode, the upper file (plaintext) is smaller /* In normal mode, the upper file (plaintext) is smaller
* than the backing ciphertext file */ * than the backing ciphertext file */
rAssert(stbuf->st_size >= HEADER_SIZE); rAssert(stbuf->st_size >= HEADER_SIZE);
stbuf->st_size -= HEADER_SIZE; stbuf->st_size -= HEADER_SIZE;
} } else {
else
{
/* In reverse mode, the upper file (ciphertext) is larger than /* In reverse mode, the upper file (ciphertext) is larger than
* the backing plaintext file */ * the backing plaintext file */
stbuf->st_size += HEADER_SIZE; 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 // No check on S_ISREG here -- don't call getSize over getAttr unless this
// is a normal file! // is a normal file!
if (haveHeader && size > 0) { if (haveHeader && size > 0) {
if(!fsConfig->reverseEncryption) if (!fsConfig->reverseEncryption) {
{
rAssert(size >= HEADER_SIZE); rAssert(size >= HEADER_SIZE);
size -= HEADER_SIZE; size -= HEADER_SIZE;
} } else {
else
{
size += HEADER_SIZE; size += HEADER_SIZE;
} }
} }
@ -278,13 +274,13 @@ bool CipherFileIO::writeHeader() {
* the IV. This guarantees unpredictability and prevents watermarking * the IV. This guarantees unpredictability and prevents watermarking
* attacks. * attacks.
*/ */
void CipherFileIO::generateReverseHeader(unsigned char* headerBuf) { void CipherFileIO::generateReverseHeader(unsigned char *headerBuf) {
struct stat stbuf; struct stat stbuf;
int res = getAttr(&stbuf); int res = getAttr(&stbuf);
rAssert( res == 0 ); rAssert(res == 0);
ino_t ino = stbuf.st_ino; ino_t ino = stbuf.st_ino;
rAssert( ino != 0 ); rAssert(ino != 0);
rDebug("generating reverse file IV header from ino=%lu", (unsigned long)ino); 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) */ * may lead to duplicate IVs (see readOneBlock) */
unsigned char md[20]; unsigned char md[20];
SHA1(inoBuf, sizeof(ino), md); SHA1(inoBuf, sizeof(ino), md);
rAssert( HEADER_SIZE <= 20 ); rAssert(HEADER_SIZE <= 20);
memcpy(headerBuf, md, HEADER_SIZE); memcpy(headerBuf, md, HEADER_SIZE);
// Save the IV in fileIV for internal use // Save the IV in fileIV for internal use
@ -464,12 +460,14 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const {
/* if reverse mode is not active with uniqueIV, /* if reverse mode is not active with uniqueIV,
* the read request is handled by the base class */ * the read request is handled by the base class */
if ( !(fsConfig->reverseEncryption && haveHeader) ) { if (!(fsConfig->reverseEncryption && haveHeader)) {
rDebug("relaying request to base class: offset=%d, dataLen=%d", origReq.offset, origReq.dataLen); rDebug("relaying request to base class: offset=%d, dataLen=%d",
origReq.offset, origReq.dataLen);
return BlockFileIO::read(origReq); 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 // generate the file IV header
// this is needed in any case - without IV the file cannot be decoded // this is needed in any case - without IV the file cannot be decoded
@ -489,7 +487,7 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const {
* to the data. */ * to the data. */
if (req.offset < 0) { if (req.offset < 0) {
headerBytes = -req.offset; headerBytes = -req.offset;
if ( req.dataLen < headerBytes ) if (req.dataLen < headerBytes)
headerBytes = req.dataLen; // only up to the number of bytes requested headerBytes = req.dataLen; // only up to the number of bytes requested
rDebug("Adding %d header bytes", headerBytes); rDebug("Adding %d header bytes", headerBytes);
@ -498,14 +496,13 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const {
memcpy(req.data, &headerBuf[headerOffset], headerBytes); memcpy(req.data, &headerBuf[headerOffset], headerBytes);
// the read does not want data beyond the header // the read does not want data beyond the header
if ( headerBytes == req.dataLen) if (headerBytes == req.dataLen) return headerBytes;
return headerBytes;
/* The rest of the request will be read from the backing file. /* The rest of the request will be read from the backing file.
* As we have already generated n=headerBytes bytes, the request is * As we have already generated n=headerBytes bytes, the request is
* shifted by headerBytes */ * shifted by headerBytes */
req.offset += headerBytes; req.offset += headerBytes;
rAssert( req.offset == 0 ); rAssert(req.offset == 0);
req.data += headerBytes; req.data += headerBytes;
req.dataLen -= headerBytes; req.dataLen -= headerBytes;
} }
@ -513,10 +510,9 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const {
// read the payload // read the payload
ssize_t readBytes = BlockFileIO::read(req); ssize_t readBytes = BlockFileIO::read(req);
rDebug("read %ld bytes from backing file", (long)readBytes); rDebug("read %ld bytes from backing file", (long)readBytes);
if ( readBytes < 0) if (readBytes < 0)
return readBytes; // Return error code return readBytes; // Return error code
else else {
{
ssize_t sum = headerBytes + readBytes; ssize_t sum = headerBytes + readBytes;
rDebug("returning sum=%ld", (long)sum); rDebug("returning sum=%ld", (long)sum);
return sum; return sum;

View File

@ -21,13 +21,20 @@
#ifndef _CipherFileIO_incl_ #ifndef _CipherFileIO_incl_
#define _CipherFileIO_incl_ #define _CipherFileIO_incl_
#include <inttypes.h>
#include <stdint.h>
#include <sys/types.h>
#include <memory>
#include "BlockFileIO.h" #include "BlockFileIO.h"
#include "CipherKey.h" #include "CipherKey.h"
#include "FSConfig.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "Interface.h"
#include <inttypes.h>
class Cipher; class Cipher;
class FileIO;
struct IORequest;
/* /*
Implement the FileIO interface encrypting data in blocks. Implement the FileIO interface encrypting data in blocks.
@ -57,7 +64,7 @@ class CipherFileIO : public BlockFileIO {
private: private:
virtual ssize_t readOneBlock(const IORequest &req) const; virtual ssize_t readOneBlock(const IORequest &req) const;
virtual bool writeOneBlock(const IORequest &req); virtual bool writeOneBlock(const IORequest &req);
virtual void generateReverseHeader(unsigned char* data); virtual void generateReverseHeader(unsigned char *data);
void initHeader(); void initHeader();
bool writeHeader(); bool writeHeader();

View File

@ -21,6 +21,8 @@
#ifndef _CipherKey_incl_ #ifndef _CipherKey_incl_
#define _CipherKey_incl_ #define _CipherKey_incl_
#include <memory>
#include "shared_ptr.h" #include "shared_ptr.h"
class AbstractCipherKey { class AbstractCipherKey {

View File

@ -20,13 +20,14 @@
#include "ConfigReader.h" #include "ConfigReader.h"
#include <rlog/rlog.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <rlog/rlog.h>
#include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <cstring> #include <cstring>
#include <utility>
#include "ConfigVar.h"
using namespace std; using namespace std;
using namespace rlog; using namespace rlog;

View File

@ -19,8 +19,8 @@
*/ */
#include "ConfigVar.h" #include "ConfigVar.h"
#include <rlog/rlog.h>
#include <rlog/rlog.h>
#include <cstring> #include <cstring>
using namespace rlog; using namespace rlog;

View File

@ -21,7 +21,9 @@
#ifndef _ConfigVar_incl_ #ifndef _ConfigVar_incl_
#define _ConfigVar_incl_ #define _ConfigVar_incl_
#include <memory>
#include <string> #include <string>
#include "shared_ptr.h" #include "shared_ptr.h"
class ConfigVar { class ConfigVar {

View File

@ -19,11 +19,10 @@
*/ */
#include <rlog/rlog.h> #include <rlog/rlog.h>
#include <utility>
#include "Context.h" #include "Context.h"
#include "DirNode.h" #include "DirNode.h"
#include "FileNode.h"
#include "FileUtils.h"
#include "Mutex.h" #include "Mutex.h"
using namespace rel; using namespace rel;

View File

@ -21,22 +21,20 @@
#ifndef _Context_incl_ #ifndef _Context_incl_
#define _Context_incl_ #define _Context_incl_
#include <pthread.h>
#include <memory>
#include <set> #include <set>
#ifdef USE_HASHMAP
#include <ext/hash_map>
#else
#include <map>
#endif
#include <string> #include <string>
#include <unordered_map>
#include "encfs.h" #include "encfs.h"
#include "shared_ptr.h" #include "shared_ptr.h"
class DirNode;
class FileNode;
struct EncFS_Args; struct EncFS_Args;
struct EncFS_Opts; struct EncFS_Opts;
class FileNode;
class DirNode;
class EncFS_Context { class EncFS_Context {
public: public:
@ -88,12 +86,7 @@ class EncFS_Context {
Placeholder(const shared_ptr<FileNode> &ptr) : node(ptr) {} Placeholder(const shared_ptr<FileNode> &ptr) : node(ptr) {}
}; };
#ifdef USE_HASHMAP typedef std::unordered_map<std::string, std::set<Placeholder *> > FileMap;
// set of open files, indexed by path
typedef __gnu_cxx::hash_map<std::string, std::set<Placeholder *> > FileMap;
#else
typedef std::map<std::string, std::set<Placeholder *> > FileMap;
#endif
mutable pthread_mutex_t contextMutex; mutable pthread_mutex_t contextMutex;
FileMap openFiles; FileMap openFiles;

View File

@ -18,31 +18,33 @@
* 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 "encfs.h" #include <pthread.h>
#include "DirNode.h"
#include "FileUtils.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h>
#include <utime.h>
#include <cerrno> #include <cerrno>
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <pthread.h> #include "DirNode.h"
#include <unistd.h> #include "FSConfig.h"
#include "FileNode.h"
#include "FileUtils.h"
#include "NameIO.h"
#ifdef linux #ifdef linux
#include <sys/fsuid.h> #include <sys/fsuid.h>
#endif #endif
#include <rlog/Error.h>
#include <rlog/rlog.h>
#include <cstring> #include <cstring>
#include "Context.h" #include "Context.h"
#include "Cipher.h"
#include "Mutex.h" #include "Mutex.h"
#include <rlog/rlog.h>
#include <rlog/Error.h>
#include <iostream> namespace rlog {
class RLogChannel;
} // namespace rlog
using namespace std; using namespace std;
using namespace rel; using namespace rel;
@ -311,7 +313,8 @@ string DirNode::plainPath(const char *cipherPath_) {
prefix = "+"; prefix = "+";
} }
if (cipherPath_[0] == mark) { if (cipherPath_[0] == mark) {
return prefix + naming->decodeName(cipherPath_ + 1, strlen(cipherPath_ + 1)); return prefix +
naming->decodeName(cipherPath_ + 1, strlen(cipherPath_ + 1));
} }
// Default. // Default.

View File

@ -21,24 +21,28 @@
#ifndef _DirNode_incl_ #ifndef _DirNode_incl_
#define _DirNode_incl_ #define _DirNode_incl_
#include <inttypes.h>
#include <dirent.h> #include <dirent.h>
#include <inttypes.h>
#include <pthread.h>
#include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <map>
#include <list> #include <list>
#include <vector> #include <map>
#include <memory>
#include <string> #include <string>
#include <vector>
#include "FileNode.h"
#include "NameIO.h"
#include "CipherKey.h" #include "CipherKey.h"
#include "FSConfig.h" #include "FSConfig.h"
#include "FileNode.h"
#include "NameIO.h"
class Cipher; class Cipher;
class EncFS_Context;
class FileNode;
class NameIO;
class RenameOp; class RenameOp;
struct RenameEl; struct RenameEl;
class EncFS_Context;
class DirTraverse { class DirTraverse {
public: public:
@ -72,17 +76,6 @@ class DirTraverse {
}; };
inline bool DirTraverse::valid() const { return dir.get() != 0; } inline bool DirTraverse::valid() const { return dir.get() != 0; }
#ifdef USE_HASHMAP
namespace __gnu_cxx {
template <>
struct hash<std::string> {
size_t operator()(const std::string &__s) const {
return __stl_hash_string(__s.c_str());
}
};
}
#endif
class DirNode { class DirNode {
public: public:
// sourceDir points to where raw files are stored // sourceDir points to where raw files are stored

View File

@ -122,7 +122,8 @@ struct FSConfig {
bool idleTracking; // turn on idle monitoring of filesystem 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<FSConfig> FSConfigPtr; typedef shared_ptr<FSConfig> FSConfigPtr;

View File

@ -21,11 +21,12 @@
#ifndef _FileIO_incl_ #ifndef _FileIO_incl_
#define _FileIO_incl_ #define _FileIO_incl_
#include "encfs.h"
#include <inttypes.h> #include <inttypes.h>
#include <stdint.h>
#include <sys/types.h>
#include "Interface.h" #include "Interface.h"
#include "encfs.h"
struct IORequest { struct IORequest {
off_t offset; off_t offset;

View File

@ -18,37 +18,30 @@
* 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 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 <errno.h> #include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#ifdef linux #ifdef linux
#include <sys/fsuid.h> #include <sys/fsuid.h>
#endif #endif
#include <rlog/rlog.h>
#include <cstring> #include <cstring>
#include "config.h" #include "CipherFileIO.h"
#include "FileIO.h"
#include "FileNode.h" #include "FileNode.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "Cipher.h"
#include "CipherFileIO.h"
#include "RawFileIO.h"
#include "MACFileIO.h" #include "MACFileIO.h"
#include "DirNode.h"
#include "FileIO.h"
#include "MemoryPool.h"
#include "Mutex.h" #include "Mutex.h"
#include "RawFileIO.h"
#include <rlog/rlog.h> namespace rlog {
#include <rlog/Error.h> class RLogChannel;
} // namespace rlog
using namespace std; using namespace std;
using namespace rel; using namespace rel;

View File

@ -21,17 +21,21 @@
#ifndef _FileNode_incl_ #ifndef _FileNode_incl_
#define _FileNode_incl_ #define _FileNode_incl_
#include "encfs.h"
#include "CipherKey.h"
#include "FileUtils.h"
#include <inttypes.h> #include <inttypes.h>
#include <pthread.h>
#include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <memory>
#include <string> #include <string>
#include "CipherKey.h"
#include "FileUtils.h"
#include "FSConfig.h"
#include "encfs.h"
class Cipher; class Cipher;
class FileIO;
class DirNode; class DirNode;
class FileIO;
class FileNode { class FileNode {
public: public:

View File

@ -24,48 +24,46 @@
#endif #endif
#define _BSD_SOURCE // pick up setenv on RH7.3 #define _BSD_SOURCE // pick up setenv on RH7.3
#include <rlog/rlog.h>
#include <rlog/Error.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cerrno>
#include <cstring>
#include <iostream>
#include <fstream>
#include <sstream>
#include <boost/version.hpp> #include <boost/version.hpp>
#include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp> #include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/binary_object.hpp> #include <boost/serialization/binary_object.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_free.hpp>
#include <fcntl.h>
#include <rlog/Error.h>
#include <rlog/rlog.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <cctype>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <fstream>
#include <list>
#include <vector>
#include "encfs.h"
#include "config.h"
#include "autosprintf.h"
#include "readpassphrase.h"
#include "BlockNameIO.h" #include "BlockNameIO.h"
#include "Cipher.h" #include "Cipher.h"
#include "CipherKey.h"
#include "ConfigReader.h" #include "ConfigReader.h"
#include "ConfigVar.h"
#include "Context.h" #include "Context.h"
#include "DirNode.h" #include "DirNode.h"
#include "FSConfig.h" #include "FSConfig.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "NullNameIO.h" #include "Interface.h"
#include "StreamNameIO.h" #include "NameIO.h"
#include "Range.h"
#include "autosprintf.h"
#include "config.h"
#include "i18n.h" #include "i18n.h"
#include "intl/gettext.h"
#include "readpassphrase.h"
// disable rlog section grouping for this file.. seems to cause problems // disable rlog section grouping for this file.. seems to cause problems
#undef RLOG_SECTION #undef RLOG_SECTION
@ -129,7 +127,7 @@ struct ConfigInfo {
{".encfs", Config_Prehistoric, NULL, NULL, NULL, 0, 0}, {".encfs", Config_Prehistoric, NULL, NULL, NULL, 0, 0},
{NULL, Config_None, 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 // define serialization helpers
namespace boost { namespace boost {
@ -297,7 +295,8 @@ bool userAllowMkdir(int promptno, const char *path, mode_t mode) {
// xgroup(setup) // xgroup(setup)
cerr << autosprintf( cerr << autosprintf(
_("The directory \"%s\" does not exist. Should it be created? " _("The directory \"%s\" does not exist. Should it be created? "
"(y,n) "), path); "(y,n) "),
path);
char answer[10]; char answer[10];
char *res; char *res;
@ -338,8 +337,7 @@ ConfigType readConfig_load(ConfigInfo *nm, const char *path,
config->cfgType = nm->type; config->cfgType = nm->type;
return nm->type; return nm->type;
} }
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -364,8 +362,10 @@ ConfigType readConfig(const string &rootDir,
if (nm->environmentOverride != NULL) { if (nm->environmentOverride != NULL) {
char *envFile = getenv(nm->environmentOverride); char *envFile = getenv(nm->environmentOverride);
if (envFile != NULL) { if (envFile != NULL) {
if (! fileExists(envFile)) { if (!fileExists(envFile)) {
rError("fatal: config file specified by environment does not exist: %s", envFile); rError(
"fatal: config file specified by environment does not exist: %s",
envFile);
exit(1); exit(1);
} }
return readConfig_load(nm, envFile, config); return readConfig_load(nm, envFile, config);
@ -397,8 +397,7 @@ bool readV6Config(const char *configFile, const shared_ptr<EncFSConfig> &config,
ia >> BOOST_SERIALIZATION_NVP(*config); ia >> BOOST_SERIALIZATION_NVP(*config);
return true; return true;
} } catch (boost::archive::archive_exception &e) {
catch (boost::archive::archive_exception &e) {
rError("Archive exception: %s", e.what()); rError("Archive exception: %s", e.what());
return false; return false;
} }
@ -453,8 +452,7 @@ bool readV5Config(const char *configFile, const shared_ptr<EncFSConfig> &config,
config->blockMACRandBytes = cfgRdr["blockMACRandBytes"].readInt(0); config->blockMACRandBytes = cfgRdr["blockMACRandBytes"].readInt(0);
ok = true; ok = true;
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
rDebug("Error parsing data in config file %s", configFile); rDebug("Error parsing data in config file %s", configFile);
ok = false; ok = false;
@ -494,8 +492,7 @@ bool readV4Config(const char *configFile, const shared_ptr<EncFSConfig> &config,
config->chainedNameIV = false; config->chainedNameIV = false;
ok = true; ok = true;
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
rDebug("Error parsing config file %s", configFile); rDebug("Error parsing config file %s", configFile);
ok = false; ok = false;
@ -521,8 +518,7 @@ bool saveConfig(ConfigType type, const string &rootDir,
try { try {
ok = (*nm->saveFunc)(path.c_str(), config); ok = (*nm->saveFunc)(path.c_str(), config);
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
ok = false; ok = false;
} }
@ -667,7 +663,8 @@ static Cipher::CipherAlgorithm selectCipherAlgorithm() {
Cipher::CipherAlgorithm alg = *it; Cipher::CipherAlgorithm alg = *it;
// xgroup(setup) // 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; return alg;
} }
@ -707,7 +704,8 @@ static Interface selectNameCoding() {
++it; ++it;
// xgroup(setup) // 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; return it->iface;
} }
@ -824,7 +822,7 @@ static bool boolDefault(const char *prompt, bool defaultValue) {
string response; string response;
bool value; bool value;
while(true) { while (true) {
cout << yesno; cout << yesno;
getline(cin, response); 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.")); "within a block will be caught and will cause a read error."));
} else { } else {
cout << "\n\n" << _("You specified --require-macs. " cout << "\n\n" << _("You specified --require-macs. "
"Enabling block authentication code headers...") << "\n\n"; "Enabling block authentication code headers...")
<< "\n\n";
addMAC = true; addMAC = true;
} }
@ -877,7 +876,8 @@ static void selectBlockMAC(int *macBytes, int *macRandBytes, bool forceMac) {
*macBytes = 0; *macBytes = 0;
// xgroup(setup) // xgroup(setup)
cout << _("Add random bytes to each block header?\n" cout << _(
"Add random bytes to each block header?\n"
"This adds a performance penalty, but ensures that blocks\n" "This adds a performance penalty, but ensures that blocks\n"
"have different authentication codes. Note that you can\n" "have different authentication codes. Note that you can\n"
"have the same benefits by enabling per-file initialization\n" "have the same benefits by enabling per-file initialization\n"
@ -906,7 +906,8 @@ static bool selectUniqueIV(bool default_answer) {
_("Enable per-file initialization vectors?\n" _("Enable per-file initialization vectors?\n"
"This adds about 8 bytes per file to the storage requirements.\n" "This adds about 8 bytes per file to the storage requirements.\n"
"It should not affect performance except possibly with applications\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,7 +965,8 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
char answer[10] = {0}; char answer[10] = {0};
if (configMode == Config_Prompt) { if (configMode == Config_Prompt) {
// xgroup(setup) // xgroup(setup)
cout << _("Please choose from one of the following options:\n" cout << _(
"Please choose from one of the following options:\n"
" enter \"x\" for expert configuration mode,\n" " enter \"x\" for expert configuration mode,\n"
" enter \"p\" for pre-configured paranoia mode,\n" " enter \"p\" for pre-configured paranoia mode,\n"
" anything else, or an empty line will select standard mode.\n" " anything else, or an empty line will select standard mode.\n"
@ -1037,7 +1039,8 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
if (answer[0] == 'x' || alg.name.empty()) { if (answer[0] == 'x' || alg.name.empty()) {
if (answer[0] != 'x') { if (answer[0] != 'x') {
// xgroup(setup) // xgroup(setup)
cout << _("Sorry, unable to locate cipher for predefined " cout << _(
"Sorry, unable to locate cipher for predefined "
"configuration...\n" "configuration...\n"
"Falling through to Manual configuration mode."); "Falling through to Manual configuration mode.");
} else { } else {
@ -1057,8 +1060,7 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
/* Reverse mounts are read-only by default (set in main.cpp). /* Reverse mounts are read-only by default (set in main.cpp).
* If uniqueIV is off, writing can be allowed, because there * If uniqueIV is off, writing can be allowed, because there
* is no header that could be overwritten */ * is no header that could be overwritten */
if (uniqueIV == false) if (uniqueIV == false) opts->readOnly = false;
opts->readOnly = false;
} else { } else {
chainedIV = selectChainedIV(); chainedIV = selectChainedIV();
uniqueIV = selectUniqueIV(true); uniqueIV = selectUniqueIV(true);
@ -1125,7 +1127,8 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
} }
// xgroup(setup) // xgroup(setup)
cout << _("Now you will need to enter a password for your filesystem.\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" "You will need to remember this password, as there is absolutely\n"
"no recovery mechanism. However, the password can be changed\n" "no recovery mechanism. However, the password can be changed\n"
"later using encfsctl.\n\n"); "later using encfsctl.\n\n");
@ -1198,9 +1201,8 @@ void showFSInfo(const shared_ptr<EncFSConfig> &config) {
cout << autosprintf( cout << autosprintf(
// xgroup(diag) // xgroup(diag)
_("Filesystem cipher: \"%s\", version %i:%i:%i"), _("Filesystem cipher: \"%s\", version %i:%i:%i"),
config->cipherIface.name().c_str(), config->cipherIface.name().c_str(), config->cipherIface.current(),
config->cipherIface.current(), config->cipherIface.revision(), config->cipherIface.revision(), config->cipherIface.age());
config->cipherIface.age());
// check if we support this interface.. // check if we support this interface..
if (!cipher) if (!cipher)
cout << _(" (NOT supported)\n"); cout << _(" (NOT supported)\n");
@ -1218,7 +1220,8 @@ void showFSInfo(const shared_ptr<EncFSConfig> &config) {
{ {
// xgroup(diag) // xgroup(diag)
cout << autosprintf(_("Filename encoding: \"%s\", version %i:%i:%i"), cout << autosprintf(_("Filename encoding: \"%s\", version %i:%i:%i"),
config->nameIface.name().c_str(), config->nameIface.current(), config->nameIface.name().c_str(),
config->nameIface.current(),
config->nameIface.revision(), config->nameIface.age()); config->nameIface.revision(), config->nameIface.age());
// check if we support the filename encoding interface.. // check if we support the filename encoding interface..
@ -1249,7 +1252,8 @@ void showFSInfo(const shared_ptr<EncFSConfig> &config) {
if (config->kdfIterations > 0 && config->salt.size() > 0) { if (config->kdfIterations > 0 && config->salt.size() > 0) {
cout << autosprintf(_("Using PBKDF2, with %i iterations"), cout << autosprintf(_("Using PBKDF2, with %i iterations"),
config->kdfIterations) << "\n"; config->kdfIterations) << "\n";
cout << autosprintf(_("Salt Size: %i bits"), (int)(8 * config->salt.size())) << "\n"; cout << autosprintf(_("Salt Size: %i bits"), (int)(8 * config->salt.size()))
<< "\n";
} }
if (config->blockMACBytes || config->blockMACRandBytes) { if (config->blockMACBytes || config->blockMACRandBytes) {
if (config->subVersion < 20040813) { if (config->subVersion < 20040813) {
@ -1448,7 +1452,7 @@ CipherKey EncFSConfig::getUserKey(const std::string &passProg,
snprintf(tmpBuf, sizeof(tmpBuf) - 1, "%i", stdErrCopy); snprintf(tmpBuf, sizeof(tmpBuf) - 1, "%i", stdErrCopy);
setenv(ENCFS_ENV_STDERR, tmpBuf, 1); 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")); perror(_("Internal error: failed to exec program"));
exit(1); exit(1);
@ -1502,17 +1506,16 @@ RootPtr initFS(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
if (readConfig(opts->rootDir, config) != Config_None) { if (readConfig(opts->rootDir, config) != Config_None) {
if (config->blockMACBytes == 0 && opts->requireMac) { if (config->blockMACBytes == 0 && opts->requireMac) {
cout cout << _(
<< _("The configuration disabled MAC, but you passed --require-macs\n"); "The configuration disabled MAC, but you passed --require-macs\n");
return rootInfo; return rootInfo;
} }
if (opts->reverseEncryption) { if (opts->reverseEncryption) {
if (config->blockMACBytes != 0 || config->blockMACRandBytes != 0 || if (config->blockMACBytes != 0 || config->blockMACRandBytes != 0 ||
config->externalIVChaining || config->externalIVChaining || config->chainedNameIV) {
config->chainedNameIV) { cout << _(
cout "The configuration loaded is not compatible with --reverse\n");
<< _("The configuration loaded is not compatible with --reverse\n");
return rootInfo; return rootInfo;
} }
} }
@ -1566,7 +1569,8 @@ RootPtr initFS(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
config->nameIface.name().c_str(), config->nameIface.current(), config->nameIface.name().c_str(), config->nameIface.current(),
config->nameIface.revision(), config->nameIface.age()); config->nameIface.revision(), config->nameIface.age());
// xgroup(diag) // xgroup(diag)
cout << _("The requested filename coding interface is " cout << _(
"The requested filename coding interface is "
"not available\n"); "not available\n");
return rootInfo; return rootInfo;
} }

View File

@ -21,10 +21,14 @@
#ifndef _FileUtils_incl_ #ifndef _FileUtils_incl_
#define _FileUtils_incl_ #define _FileUtils_incl_
#include "encfs.h" #include <sys/types.h>
#include "Interface.h" #include <memory>
#include <string>
#include "CipherKey.h" #include "CipherKey.h"
#include "FSConfig.h" #include "FSConfig.h"
#include "Interface.h"
#include "encfs.h"
// true if the path points to an existing node (of any type) // true if the path points to an existing node (of any type)
bool fileExists(const char *fileName); bool fileExists(const char *fileName);

View File

@ -20,10 +20,13 @@
#include "Interface.h" #include "Interface.h"
#include <rlog/rlog.h>
#include "ConfigVar.h" #include "ConfigVar.h"
#include <rlog/rlog.h> namespace rlog {
#include <rlog/RLogChannel.h> class RLogChannel;
} // namespace rlog
using namespace rel; using namespace rel;
using namespace rlog; using namespace rlog;

View File

@ -20,17 +20,23 @@
#include "MACFileIO.h" #include "MACFileIO.h"
#include "MemoryPool.h" #include <inttypes.h>
#include "FileUtils.h"
#include <rlog/rlog.h>
#include <rlog/Error.h> #include <rlog/Error.h>
#include <rlog/RLogChannel.h> #include <rlog/rlog.h>
#include <sys/stat.h>
#include <cstring> #include <cstring>
#include "BlockFileIO.h"
#include "Cipher.h"
#include "FileIO.h"
#include "FileUtils.h"
#include "MemoryPool.h"
#include "i18n.h" #include "i18n.h"
namespace rlog {
class RLogChannel;
} // namespace rlog
using namespace rlog; using namespace rlog;
using namespace rel; using namespace rel;
using namespace std; using namespace std;

View File

@ -21,8 +21,19 @@
#ifndef _MACFileIO_incl_ #ifndef _MACFileIO_incl_
#define _MACFileIO_incl_ #define _MACFileIO_incl_
#include <stdint.h>
#include <sys/types.h>
#include <memory>
#include "BlockFileIO.h" #include "BlockFileIO.h"
#include "Cipher.h" #include "Cipher.h"
#include "CipherKey.h"
#include "FSConfig.h"
#include "Interface.h"
class Cipher;
class FileIO;
struct IORequest;
class MACFileIO : public BlockFileIO { class MACFileIO : public BlockFileIO {
public: public:

View File

@ -19,13 +19,10 @@
*/ */
#include "MemoryPool.h" #include "MemoryPool.h"
#include <rlog/rlog.h>
#include <cstdlib> #include <openssl/ossl_typ.h>
#include <cstring>
#include "config.h"
#include <pthread.h> #include <pthread.h>
#include <cstring>
#ifdef HAVE_VALGRIND_MEMCHECK_H #ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h> #include <valgrind/memcheck.h>
@ -34,9 +31,8 @@
#define VALGRIND_MAKE_MEM_UNDEFINED(a, b) #define VALGRIND_MAKE_MEM_UNDEFINED(a, b)
#endif #endif
using namespace rlog;
#include <openssl/buffer.h> #include <openssl/buffer.h>
#define BLOCKDATA(BLOCK) (unsigned char *) BLOCK->data->data #define BLOCKDATA(BLOCK) (unsigned char *) BLOCK->data->data
struct BlockList { struct BlockList {

View File

@ -19,20 +19,21 @@
*/ */
#include "NameIO.h" #include "NameIO.h"
#include "config.h"
#include <rlog/rlog.h>
#include <rlog/Error.h> #include <rlog/Error.h>
#include <rlog/rlog.h>
#include <map>
#include <cstring> #include <cstring>
// for static build. Need to reference the modules which are registered at // for static build. Need to reference the modules which are registered at
// run-time, to ensure that the linker doesn't optimize them away. // run-time, to ensure that the linker doesn't optimize them away.
#include <iostream> #include <iostream>
#include <map>
#include <utility>
#include "BlockNameIO.h" #include "BlockNameIO.h"
#include "StreamNameIO.h" #include "CipherKey.h"
#include "Interface.h"
#include "NullNameIO.h" #include "NullNameIO.h"
#include "StreamNameIO.h"
using namespace std; using namespace std;
using namespace rel; using namespace rel;

View File

@ -21,13 +21,15 @@
#ifndef _NameIO_incl_ #ifndef _NameIO_incl_
#define _NameIO_incl_ #define _NameIO_incl_
#include <string>
#include <list>
#include <inttypes.h> #include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <list>
#include <memory>
#include <string>
#include "Interface.h"
#include "CipherKey.h" #include "CipherKey.h"
#include "Interface.h"
class Cipher; class Cipher;

View File

@ -21,11 +21,11 @@
#include "NullCipher.h" #include "NullCipher.h"
#include <cstring> #include <cstring>
#include <rlog/rlog.h> #include <memory>
#include "Range.h" #include "Cipher.h"
#include "Interface.h" #include "Interface.h"
#include "shared_ptr.h" #include "Range.h"
using namespace std; using namespace std;
using namespace rel; using namespace rel;

View File

@ -21,7 +21,10 @@
#ifndef _NullCipher_incl_ #ifndef _NullCipher_incl_
#define _NullCipher_incl_ #define _NullCipher_incl_
#include <stdint.h>
#include "Cipher.h" #include "Cipher.h"
#include "CipherKey.h"
#include "Interface.h" #include "Interface.h"
/* /*

View File

@ -20,10 +20,13 @@
#include "NullNameIO.h" #include "NullNameIO.h"
#include "Cipher.h"
#include "base64.h"
#include <cstring> #include <cstring>
#include <memory>
#include "CipherKey.h"
#include "NameIO.h"
class Cipher;
using namespace rel; using namespace rel;

View File

@ -21,6 +21,9 @@
#ifndef _NullNameIO_incl_ #ifndef _NullNameIO_incl_
#define _NullNameIO_incl_ #define _NullNameIO_incl_
#include <stdint.h>
#include "Interface.h"
#include "NameIO.h" #include "NameIO.h"
class NullNameIO : public NameIO { class NullNameIO : public NameIO {

View File

@ -21,18 +21,16 @@
#ifdef linux #ifdef linux
#define _XOPEN_SOURCE 500 // pick up pread , pwrite #define _XOPEN_SOURCE 500 // pick up pread , pwrite
#endif #endif
#include <unistd.h>
#include "RawFileIO.h"
#include <rlog/rlog.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h>
#include <rlog/rlog.h>
#include <sys/stat.h>
#include <unistd.h>
#include <cerrno>
#include <cstring> #include <cstring>
#include <cerrno> #include "FileIO.h"
#include "RawFileIO.h"
using namespace std; using namespace std;

View File

@ -21,10 +21,12 @@
#ifndef _RawFileIO_incl_ #ifndef _RawFileIO_incl_
#define _RawFileIO_incl_ #define _RawFileIO_incl_
#include "FileIO.h" #include <sys/types.h>
#include <string> #include <string>
#include "Interface.h"
#include "FileIO.h"
class RawFileIO : public FileIO { class RawFileIO : public FileIO {
public: public:
RawFileIO(); RawFileIO();

View File

@ -18,31 +18,30 @@
* 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 "encfs.h" #include <openssl/crypto.h>
#include "config.h"
#include <openssl/blowfish.h>
#include <openssl/sha.h>
#include <openssl/rand.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/hmac.h> #include <openssl/hmac.h>
#include <openssl/ossl_typ.h>
#include "SSL_Cipher.h" #include <openssl/rand.h>
#include "Range.h" #include <pthread.h>
#include "MemoryPool.h" #include <rlog/Error.h>
#include "Mutex.h" #include <rlog/rlog.h>
#include <cstring>
#include <ctime>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/time.h> #include <sys/time.h>
#include <cstring>
#include <string>
#include <rlog/rlog.h> #include "Cipher.h"
#include <rlog/Error.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 std;
using namespace rel; using namespace rel;
@ -674,21 +673,21 @@ void SSL_Cipher::setIVec_old(unsigned char *ivec, unsigned int seed,
ivec[0] ^= (var1 >> 24) & 0xff; ivec[0] ^= (var1 >> 24) & 0xff;
ivec[1] ^= (var2 >> 16) & 0xff; ivec[1] ^= (var2 >> 16) & 0xff;
ivec[2] ^= (var1 >> 8) & 0xff; ivec[2] ^= (var1 >> 8) & 0xff;
ivec[3] ^= (var2) & 0xff; ivec[3] ^= (var2)&0xff;
ivec[4] ^= (var2 >> 24) & 0xff; ivec[4] ^= (var2 >> 24) & 0xff;
ivec[5] ^= (var1 >> 16) & 0xff; ivec[5] ^= (var1 >> 16) & 0xff;
ivec[6] ^= (var2 >> 8) & 0xff; ivec[6] ^= (var2 >> 8) & 0xff;
ivec[7] ^= (var1) & 0xff; ivec[7] ^= (var1)&0xff;
if (_ivLength > 8) { if (_ivLength > 8) {
ivec[8 + 0] ^= (var1) & 0xff; ivec[8 + 0] ^= (var1)&0xff;
ivec[8 + 1] ^= (var2 >> 8) & 0xff; ivec[8 + 1] ^= (var2 >> 8) & 0xff;
ivec[8 + 2] ^= (var1 >> 16) & 0xff; ivec[8 + 2] ^= (var1 >> 16) & 0xff;
ivec[8 + 3] ^= (var2 >> 24) & 0xff; ivec[8 + 3] ^= (var2 >> 24) & 0xff;
ivec[8 + 4] ^= (var1 >> 24) & 0xff; ivec[8 + 4] ^= (var1 >> 24) & 0xff;
ivec[8 + 5] ^= (var2 >> 16) & 0xff; ivec[8 + 5] ^= (var2 >> 16) & 0xff;
ivec[8 + 6] ^= (var1 >> 8) & 0xff; ivec[8 + 6] ^= (var1 >> 8) & 0xff;
ivec[8 + 7] ^= (var2) & 0xff; ivec[8 + 7] ^= (var2)&0xff;
} }
} }

View File

@ -21,12 +21,17 @@
#ifndef _SSL_Cipher_incl_ #ifndef _SSL_Cipher_incl_
#define _SSL_Cipher_incl_ #define _SSL_Cipher_incl_
#include <stdint.h>
#include <memory>
#include "Cipher.h" #include "Cipher.h"
#include "CipherKey.h"
#include "Interface.h" #include "Interface.h"
class SSLKey; class SSLKey;
#ifndef EVP_CIPHER #ifndef EVP_CIPHER
struct evp_cipher_st; struct evp_cipher_st;
typedef struct evp_cipher_st EVP_CIPHER; typedef struct evp_cipher_st EVP_CIPHER;
#endif #endif

View File

@ -20,15 +20,16 @@
#include "StreamNameIO.h" #include "StreamNameIO.h"
#include "Cipher.h"
#include "base64.h"
#include <rlog/rlog.h>
#include <rlog/Error.h> #include <rlog/Error.h>
#include <rlog/rlog.h>
#include "i18n.h"
#include <cstring> #include <cstring>
#include "Cipher.h"
#include "CipherKey.h"
#include "NameIO.h"
#include "base64.h"
#include "intl/gettext.h"
using namespace rel; using namespace rel;
using namespace std; using namespace std;
@ -101,12 +102,12 @@ int StreamNameIO::encodeName(const char *plaintextName, int length,
if (_interface >= 1) { if (_interface >= 1) {
// current versions store the checksum at the beginning // current versions store the checksum at the beginning
encodedName[0] = (mac >> 8) & 0xff; encodedName[0] = (mac >> 8) & 0xff;
encodedName[1] = (mac) & 0xff; encodedName[1] = (mac)&0xff;
encodeBegin = (unsigned char *)encodedName + 2; encodeBegin = (unsigned char *)encodedName + 2;
} else { } else {
// encfs 0.x stored checksums at the end. // encfs 0.x stored checksums at the end.
encodedName[length] = (mac >> 8) & 0xff; encodedName[length] = (mac >> 8) & 0xff;
encodedName[length + 1] = (mac) & 0xff; encodedName[length + 1] = (mac)&0xff;
encodeBegin = (unsigned char *)encodedName; encodeBegin = (unsigned char *)encodedName;
} }

View File

@ -21,8 +21,12 @@
#ifndef _StreamNameIO_incl_ #ifndef _StreamNameIO_incl_
#define _StreamNameIO_incl_ #define _StreamNameIO_incl_
#include "NameIO.h" #include <stdint.h>
#include <memory>
#include "CipherKey.h" #include "CipherKey.h"
#include "Interface.h"
#include "NameIO.h"
class Cipher; class Cipher;

View File

@ -28,10 +28,11 @@
#include "autosprintf.h" #include "autosprintf.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdarg.h>
#include <string.h>
//#include "lib-asprintf.h" //#include "lib-asprintf.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
namespace gnu { namespace gnu {

View File

@ -18,8 +18,6 @@ BOOST_CLASS_VERSION(EncFSConfig, V6SubVersion)
// we specify in BOOST_CLASS_VERSION below. Without this, manual editing // we specify in BOOST_CLASS_VERSION below. Without this, manual editing
// of the file is needed before boost will allow us to read it. // 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) BOOST_CLASS_VERSION(EncFSConfig, 20)
namespace boost { namespace boost {
@ -62,7 +60,7 @@ class iserializer<Archive, EncFSConfig> : public basic_iserializer {
virtual bool is_polymorphic() const { virtual bool is_polymorphic() const {
return boost::is_polymorphic<EncFSConfig>::value; return boost::is_polymorphic<EncFSConfig>::value;
} }
virtual ~iserializer() {}; virtual ~iserializer(){};
}; };
template <class Archive> template <class Archive>

View File

@ -17,16 +17,20 @@
#include "encfs.h" #include "encfs.h"
#include <cstdio>
#include <cstring>
#include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h> #include <inttypes.h>
#include <cerrno> #include <stdint.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 <sys/types.h> #include <unistd.h>
#include <utime.h>
#include <cerrno>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <memory>
#ifdef linux #ifdef linux
#include <sys/fsuid.h> #include <sys/fsuid.h>
#endif #endif
@ -37,19 +41,24 @@
#include <attr/xattr.h> #include <attr/xattr.h>
#endif #endif
#include <rlog/Error.h>
#include <rlog/rlog.h>
#include <functional> #include <functional>
#include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "DirNode.h"
#include "MemoryPool.h"
#include "FileUtils.h"
#include "Mutex.h"
#include "Context.h" #include "Context.h"
#include "DirNode.h"
#include "FileNode.h"
#include "FileUtils.h"
#include "fuse.h"
#include <rlog/rlog.h> namespace rel {
#include <rlog/Error.h> class Lock;
} // namespace rel
namespace rlog {
class RLogChannel;
} // namespace rlog
#ifndef MIN #ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b))
@ -76,8 +85,7 @@ static EncFS_Context *context() {
* if the argument is NULL. * if the argument is NULL.
*/ */
static bool isReadOnly(EncFS_Context *ctx) { static bool isReadOnly(EncFS_Context *ctx) {
if (ctx == NULL) if (ctx == NULL) ctx = (EncFS_Context *)fuse_get_context()->private_data;
ctx = (EncFS_Context *)fuse_get_context()->private_data;
return ctx->opts->readOnly; return ctx->opts->readOnly;
} }

View File

@ -21,11 +21,12 @@
#ifndef _encfs_incl_ #ifndef _encfs_incl_
#define _encfs_incl_ #define _encfs_incl_
#include "config.h"
#include <fuse.h> #include <fuse.h>
#include <rlog/rlog.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <rlog/rlog.h> #include "config.h"
#if defined(HAVE_SYS_XATTR_H) | defined(HAVE_ATTR_XATTR_H) #if defined(HAVE_SYS_XATTR_H) | defined(HAVE_ATTR_XATTR_H)
#define HAVE_XATTR #define HAVE_XATTR

View File

@ -15,32 +15,37 @@
* more details. * more details.
*/ */
#include "encfs.h"
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>
#include <iostream>
#include <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <limits.h> #include <limits.h>
#include <rlog/rlog.h>
#include <rlog/StdioNode.h>
#include <rlog/RLogChannel.h> #include <rlog/RLogChannel.h>
#include <rlog/StdioNode.h>
#include <rlog/rlog.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#define NO_DES #define NO_DES
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include "Cipher.h" #include "Cipher.h"
#include "Context.h" #include "CipherKey.h"
#include "DirNode.h" #include "DirNode.h"
#include "FSConfig.h"
#include "FileNode.h" #include "FileNode.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "Interface.h"
#include "autosprintf.h" #include "autosprintf.h"
#include "config.h" #include "config.h"
#include "i18n.h" #include "i18n.h"
#include "shared_ptr.h" #include "intl/gettext.h"
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 4096 #define PATH_MAX 4096
@ -592,7 +597,8 @@ static int cmd_showcruft(int argc, char **argv) {
int filesFound = showcruft(rootInfo, "/"); 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. // depend upon this broken singular form, so it isn't easy to change.
cerr << autosprintf(ngettext("Found %i invalid file.", cerr << autosprintf(ngettext("Found %i invalid file.",
"Found %i invalid files.", filesFound), "Found %i invalid files.", filesFound),
@ -701,9 +707,6 @@ int main(int argc, char **argv) {
StdioNode *slog = new StdioNode(STDERR_FILENO); StdioNode *slog = new StdioNode(STDERR_FILENO);
slog->subscribeTo(GetGlobalChannel("error")); slog->subscribeTo(GetGlobalChannel("error"));
slog->subscribeTo(GetGlobalChannel("warning")); slog->subscribeTo(GetGlobalChannel("warning"));
#ifndef NO_DEBUG
// slog->subscribeTo( GetGlobalChannel("debug") );
#endif
if (argc < 2) { if (argc < 2) {
usage(argv[0]); usage(argv[0]);

View File

@ -16,41 +16,37 @@
* *
*/ */
#include <getopt.h>
#include <pthread.h>
#include <rlog/RLogChannel.h>
#include <rlog/StdioNode.h>
#include <rlog/SyslogNode.h>
#include <rlog/rlog.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <exception>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <cassert>
#include <cstdio>
#include <unistd.h>
#include <sys/time.h>
#include <cerrno>
#include <cstring>
#include <getopt.h>
#include <rlog/rlog.h>
#include <rlog/Error.h>
#include <rlog/RLogChannel.h>
#include <rlog/SyslogNode.h>
#include <rlog/StdioNode.h>
#include "autosprintf.h"
#include "ConfigReader.h"
#include "Context.h" #include "Context.h"
#include "DirNode.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "Interface.h"
#include "MemoryPool.h" #include "MemoryPool.h"
#include "autosprintf.h"
#include "config.h" #include "config.h"
#include "encfs.h" #include "encfs.h"
#include "openssl.h" #include "fuse.h"
#include "shared_ptr.h"
#include <locale.h>
#include "i18n.h" #include "i18n.h"
#include "openssl.h"
class DirNode;
// Fuse version >= 26 requires another argument to fuse_unmount, which we // Fuse version >= 26 requires another argument to fuse_unmount, which we
// don't have. So use the backward compatible call instead.. // don't have. So use the backward compatible call instead..
@ -224,7 +220,8 @@ static bool processArgs(int argc, char *argv[],
{"extpass", 1, 0, 'p'}, // external password program {"extpass", 1, 0, 'p'}, // external password program
// {"single-thread", 0, 0, 's'}, // single-threaded mode // {"single-thread", 0, 0, 's'}, // single-threaded mode
{"stdinpass", 0, 0, 'S'}, // read password from stdin {"stdinpass", 0, 0, 'S'}, // read password from stdin
{"annotate", 0, 0, LONG_OPT_ANNOTATE}, // Print annotation lines to stderr {"annotate", 0, 0,
LONG_OPT_ANNOTATE}, // Print annotation lines to stderr
{"nocache", 0, 0, LONG_OPT_NOCACHE}, // disable caching {"nocache", 0, 0, LONG_OPT_NOCACHE}, // disable caching
{"verbose", 0, 0, 'v'}, // verbose mode {"verbose", 0, 0, 'v'}, // verbose mode
{"version", 0, 0, 'V'}, // version {"version", 0, 0, 'V'}, // version
@ -404,8 +401,8 @@ static bool processArgs(int argc, char *argv[],
// "default_permissions" comes with a performance cost. Only enable // "default_permissions" comes with a performance cost. Only enable
// it if makes sense. // it if makes sense.
for(int i=0; i < out->fuseArgc; i++) { for (int i = 0; i < out->fuseArgc; i++) {
if ( out->fuseArgv[i] == NULL ) { if (out->fuseArgv[i] == NULL) {
continue; continue;
} else if (strcmp(out->fuseArgv[i], "allow_other") == 0) { } else if (strcmp(out->fuseArgv[i], "allow_other") == 0) {
PUSHARG("-o"); PUSHARG("-o");
@ -415,7 +412,8 @@ static bool processArgs(int argc, char *argv[],
} }
#if defined(__APPLE__) #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("-o");
PUSHARG("local"); PUSHARG("local");
#endif #endif
@ -612,18 +610,6 @@ int main(int argc, char *argv[]) {
encfs_oper.utimens = encfs_utimens; encfs_oper.utimens = encfs_utimens;
// encfs_oper.bmap = encfs_bmap; // 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); openssl_init(encfsArgs->isThreaded);
// 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
@ -700,7 +686,8 @@ int main(int argc, char *argv[]) {
// xgroup(usage) // xgroup(usage)
fputs(_("fuse failed. Common problems:\n" fputs(_("fuse failed. Common problems:\n"
" - fuse kernel module not installed (modprobe fuse)\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); fclose(out);
} }
} catch (std::exception &ex) { } catch (std::exception &ex) {

View File

@ -18,17 +18,16 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "encfs.h" #include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <memory>
#include <string>
#include "Cipher.h" #include "Cipher.h"
#include "CipherKey.h" #include "CipherKey.h"
#include "openssl.h" #include "openssl.h"
#include <iostream>
#include <sys/types.h>
#include <unistd.h>
using namespace std; using namespace std;
void genKey(const shared_ptr<Cipher> &cipher) { void genKey(const shared_ptr<Cipher> &cipher) {

View File

@ -20,13 +20,14 @@
#include "openssl.h" #include "openssl.h"
#include <openssl/crypto.h>
#include <pthread.h> #include <pthread.h>
#include <rlog/rlog.h> #include <rlog/rlog.h>
#include <stdlib.h>
#define NO_DES #define NO_DES
#include <openssl/ssl.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/ssl.h>
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h> #include <openssl/engine.h>
#endif #endif

View File

@ -37,18 +37,17 @@ static const char rcsid[] =
#ifndef HAVE_READPASSPHRASE #ifndef HAVE_READPASSPHRASE
#include <fcntl.h>
#include <paths.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <cctype>
#include <cerrno>
#include <csignal> #include <csignal>
#include <cstdio> #include <cstdio>
#include <cerrno>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <paths.h>
#include <cstring> #include <cstring>
#include <cctype>
#include <termios.h>
#include "readpassphrase.h" #include "readpassphrase.h"
#ifdef TCSASOFT #ifdef TCSASOFT

View File

@ -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 <Todd.Miller@courtesan.com> * Copyright (c) 2000 Todd C. Miller <Todd.Miller@courtesan.com>
@ -45,7 +46,8 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #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 */ #endif /* HAVE_READPASSPHRASE */

View File

@ -16,28 +16,30 @@
* *
*/ */
#include "encfs.h"
#include "config.h"
#include <iostream>
#include <cstdlib>
#include <sstream>
#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 <rlog/rlog.h>
#include <rlog/Error.h> #include <rlog/Error.h>
#include <rlog/StdioNode.h>
#include <rlog/RLogChannel.h> #include <rlog/RLogChannel.h>
#include <rlog/StdioNode.h>
#include <rlog/rlog.h>
#include <time.h>
#include <unistd.h>
#include <cstdlib>
#include <iostream>
#include <list>
#include <memory>
#include <sstream>
#include <string>
#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 #define NO_DES
#include <openssl/ssl.h> #include <openssl/ssl.h>
@ -363,7 +365,8 @@ bool runTests(const shared_ptr<Cipher> &cipher, bool verbose) {
static bool testCipherSize(const string &name, int keySize, int blockSize, static bool testCipherSize(const string &name, int keySize, int blockSize,
bool verbose) { bool verbose) {
cerr << name << ", key length " << keySize << ", block size " << blockSize << ": "; cerr << name << ", key length " << keySize << ", block size " << blockSize
<< ": ";
shared_ptr<Cipher> cipher = Cipher::New(name, keySize); shared_ptr<Cipher> cipher = Cipher::New(name, keySize);
if (!cipher) { if (!cipher) {