diff --git a/encfs/BlockNameIO.cpp b/encfs/BlockNameIO.cpp index 577546a..821329c 100644 --- a/encfs/BlockNameIO.cpp +++ b/encfs/BlockNameIO.cpp @@ -32,7 +32,6 @@ using namespace rlog; using namespace rel; -using namespace boost; static RLogChannel * Info = DEF_CHANNEL( "info/nameio", Log_Info ); diff --git a/encfs/BlockNameIO.h b/encfs/BlockNameIO.h index 890a2f9..fb77661 100644 --- a/encfs/BlockNameIO.h +++ b/encfs/BlockNameIO.h @@ -23,8 +23,7 @@ #include "NameIO.h" #include "CipherKey.h" - -#include +#include "shared_ptr.h" class Cipher; @@ -39,7 +38,7 @@ public: static rel::Interface CurrentInterface(bool caseSensitive = false); BlockNameIO( const rel::Interface &iface, - const boost::shared_ptr &cipher, + const shared_ptr &cipher, const CipherKey &key, int blockSize, bool caseSensitiveEncoding = false ); virtual ~BlockNameIO(); @@ -60,7 +59,7 @@ protected: private: int _interface; int _bs; - boost::shared_ptr _cipher; + shared_ptr _cipher; CipherKey _key; bool _caseSensitive; }; diff --git a/encfs/Cipher.cpp b/encfs/Cipher.cpp index 592e842..fe312b0 100644 --- a/encfs/Cipher.cpp +++ b/encfs/Cipher.cpp @@ -37,7 +37,6 @@ using namespace std; using namespace rel; -using boost::shared_ptr; #define REF_MODULE(TYPE) \ if( !TYPE::Enabled() ) \ diff --git a/encfs/Cipher.h b/encfs/Cipher.h index 95473e6..92391b9 100644 --- a/encfs/Cipher.h +++ b/encfs/Cipher.h @@ -31,8 +31,6 @@ #include #include -using boost::shared_ptr; - /* Mostly pure virtual interface defining operations on a cipher. @@ -44,8 +42,8 @@ class Cipher public: // if no key length was indicated when cipher was registered, then keyLen // <= 0 will be used. - typedef boost::shared_ptr (*CipherConstructor)( const rel::Interface &iface, - int keyLenBits ); + typedef shared_ptr (*CipherConstructor)( const rel::Interface &iface, + int keyLenBits ); struct CipherAlgorithm { @@ -61,9 +59,9 @@ public: static AlgorithmList GetAlgorithmList( bool includeHidden = false ); - static boost::shared_ptr New( const rel::Interface &iface, + static shared_ptr New( const rel::Interface &iface, int keyLen = -1); - static boost::shared_ptr New( const std::string &cipherName, + static shared_ptr New( const std::string &cipherName, int keyLen = -1 ); diff --git a/encfs/CipherFileIO.cpp b/encfs/CipherFileIO.cpp index 2cb6eb6..957d28c 100644 --- a/encfs/CipherFileIO.cpp +++ b/encfs/CipherFileIO.cpp @@ -29,8 +29,6 @@ #include #include -using boost::shared_ptr; - /* - Version 2:0 adds support for a per-file initialization vector with a fixed 8 byte header. The headers are enabled globally within a diff --git a/encfs/CipherFileIO.h b/encfs/CipherFileIO.h index 8771b99..5fb6d6a 100644 --- a/encfs/CipherFileIO.h +++ b/encfs/CipherFileIO.h @@ -37,7 +37,7 @@ class Cipher; class CipherFileIO : public BlockFileIO { public: - CipherFileIO( const boost::shared_ptr &base, + CipherFileIO( const shared_ptr &base, const FSConfigPtr &cfg); virtual ~CipherFileIO(); @@ -71,7 +71,7 @@ private: bool streamWrite( unsigned char *buf, int size, uint64_t iv64 ) const; - boost::shared_ptr base; + shared_ptr base; FSConfigPtr fsConfig; @@ -82,7 +82,7 @@ private: uint64_t fileIV; int lastFlags; - boost::shared_ptr cipher; + shared_ptr cipher; CipherKey key; }; diff --git a/encfs/CipherKey.h b/encfs/CipherKey.h index c693a85..b8cf639 100644 --- a/encfs/CipherKey.h +++ b/encfs/CipherKey.h @@ -21,7 +21,7 @@ #ifndef _CipherKey_incl_ #define _CipherKey_incl_ -#include +#include "shared_ptr.h" class AbstractCipherKey { @@ -30,7 +30,7 @@ public: virtual ~AbstractCipherKey(); }; -typedef boost::shared_ptr CipherKey; +typedef shared_ptr CipherKey; #endif diff --git a/encfs/ConfigVar.h b/encfs/ConfigVar.h index 88b4967..4a51304 100644 --- a/encfs/ConfigVar.h +++ b/encfs/ConfigVar.h @@ -22,9 +22,7 @@ #define _ConfigVar_incl_ #include -#include - -using boost::shared_ptr; +#include "shared_ptr.h" class ConfigVar { diff --git a/encfs/Context.cpp b/encfs/Context.cpp index a56ebaf..3eba9e5 100644 --- a/encfs/Context.cpp +++ b/encfs/Context.cpp @@ -140,7 +140,7 @@ shared_ptr EncFS_Context::getNode(void *pl) } void *EncFS_Context::putNode(const char *path, - const boost::shared_ptr &node) + const shared_ptr &node) { Lock lock( contextMutex ); Placeholder *pl = new Placeholder( node ); diff --git a/encfs/Context.h b/encfs/Context.h index 772367f..be5ea5b 100644 --- a/encfs/Context.h +++ b/encfs/Context.h @@ -21,8 +21,6 @@ #ifndef _Context_incl_ #define _Context_incl_ -#include "encfs.h" -#include #include #ifdef USE_HASHMAP @@ -31,7 +29,9 @@ #include #endif -using boost::shared_ptr; +#include "encfs.h" +#include "shared_ptr.h" + struct EncFS_Args; struct EncFS_Opts; class FileNode; diff --git a/encfs/DirNode.cpp b/encfs/DirNode.cpp index eb2a4a0..cc49925 100644 --- a/encfs/DirNode.cpp +++ b/encfs/DirNode.cpp @@ -101,7 +101,7 @@ bool _nextName(struct dirent *&de, const shared_ptr &dir, { if(fileType) { -#if defined(_DIRENT_HAVE_D_TYPE) || defined(__FreeBSD__) +#if defined(_DIRENT_HAVE_D_TYPE) || defined(__FreeBSD__) || defined(__APPLE__) *fileType = de->d_type; #else #warning "struct dirent.d_type not supported" diff --git a/encfs/DirNode.h b/encfs/DirNode.h index 6c3fae8..caf51f5 100644 --- a/encfs/DirNode.h +++ b/encfs/DirNode.h @@ -35,8 +35,6 @@ #include "CipherKey.h" #include "FSConfig.h" -using boost::shared_ptr; - class Cipher; class RenameOp; struct RenameEl; @@ -73,7 +71,7 @@ private: uint64_t iv; shared_ptr naming; }; -inline bool DirTraverse::valid() const { return dir != 0; } +inline bool DirTraverse::valid() const { return dir.get() != 0; } #ifdef USE_HASHMAP namespace __gnu_cxx diff --git a/encfs/FSConfig.h b/encfs/FSConfig.h index c1a443b..b8517bd 100644 --- a/encfs/FSConfig.h +++ b/encfs/FSConfig.h @@ -21,12 +21,12 @@ #ifndef _FSConfig_incl_ #define _FSConfig_incl_ +#include + #include "encfs.h" #include "Interface.h" #include "CipherKey.h" - -#include -#include +#include "shared_ptr.h" enum ConfigType { @@ -93,7 +93,7 @@ struct EncFSConfig const std::string &rootDir); CipherKey getNewUserKey(); - boost::shared_ptr getCipher() const; + shared_ptr getCipher() const; // deprecated void assignKeyData(const std::string &in); @@ -113,12 +113,12 @@ std::istream &operator >> (std::istream &os, EncFSConfig &cfg); struct FSConfig { - boost::shared_ptr config; - boost::shared_ptr opts; + shared_ptr config; + shared_ptr opts; - boost::shared_ptr cipher; + shared_ptr cipher; CipherKey key; - boost::shared_ptr nameCoding; + shared_ptr nameCoding; bool forceDecode; // force decode on MAC block failures bool reverseEncryption; // reverse encryption operation @@ -126,7 +126,7 @@ struct FSConfig bool idleTracking; // turn on idle monitoring of filesystem }; -typedef boost::shared_ptr FSConfigPtr; +typedef shared_ptr FSConfigPtr; #endif diff --git a/encfs/FileNode.cpp b/encfs/FileNode.cpp index 0fababd..4d898ef 100644 --- a/encfs/FileNode.cpp +++ b/encfs/FileNode.cpp @@ -53,7 +53,6 @@ using namespace std; using namespace rel; using namespace rlog; -using boost::dynamic_pointer_cast; /* TODO: locking at the FileNode level is inefficient, since this precludes diff --git a/encfs/FileNode.h b/encfs/FileNode.h index f838ad5..0037643 100644 --- a/encfs/FileNode.h +++ b/encfs/FileNode.h @@ -32,7 +32,6 @@ class Cipher; class FileIO; class DirNode; -using boost::shared_ptr; class FileNode { diff --git a/encfs/FileUtils.cpp b/encfs/FileUtils.cpp index ac9fb8a..74580f5 100644 --- a/encfs/FileUtils.cpp +++ b/encfs/FileUtils.cpp @@ -110,10 +110,10 @@ struct ConfigInfo ConfigType type; const char *environmentOverride; bool (*loadFunc)(const char *fileName, - const boost::shared_ptr &config, + const shared_ptr &config, ConfigInfo *cfg); bool (*saveFunc)(const char *fileName, - const boost::shared_ptr &config); + const shared_ptr &config); int currentSubVersion; int defaultSubVersion; } ConfigFileMapping[] = { @@ -362,7 +362,7 @@ bool userAllowMkdir(int promptno, const char *path, mode_t mode ) } ConfigType readConfig_load( ConfigInfo *nm, const char *path, - const boost::shared_ptr &config ) + const shared_ptr &config ) { if( nm->loadFunc ) { @@ -389,7 +389,7 @@ ConfigType readConfig_load( ConfigInfo *nm, const char *path, } ConfigType readConfig( const string &rootDir, - const boost::shared_ptr &config ) + const shared_ptr &config ) { ConfigInfo *nm = ConfigFileMapping; while(nm->fileName) @@ -413,7 +413,7 @@ ConfigType readConfig( const string &rootDir, } bool readV6Config( const char *configFile, - const boost::shared_ptr &config, + const shared_ptr &config, ConfigInfo *info) { (void)info; @@ -440,7 +440,7 @@ bool readV6Config( const char *configFile, } bool readV5Config( const char *configFile, - const boost::shared_ptr &config, + const shared_ptr &config, ConfigInfo *info) { bool ok = false; @@ -498,7 +498,7 @@ bool readV5Config( const char *configFile, } bool readV4Config( const char *configFile, - const boost::shared_ptr &config, + const shared_ptr &config, ConfigInfo *info) { bool ok = false; @@ -539,7 +539,7 @@ bool readV4Config( const char *configFile, } bool saveConfig( ConfigType type, const string &rootDir, - const boost::shared_ptr &config ) + const shared_ptr &config ) { bool ok = false; @@ -574,7 +574,7 @@ bool saveConfig( ConfigType type, const string &rootDir, } bool writeV6Config( const char *configFile, - const boost::shared_ptr &config ) + const shared_ptr &config ) { fs::ofstream st( configFile ); if(!st.is_open()) @@ -601,7 +601,7 @@ std::istream &operator >> (std::istream &st, EncFSConfig &cfg) } bool writeV5Config( const char *configFile, - const boost::shared_ptr &config ) + const shared_ptr &config ) { ConfigReader cfg; @@ -624,7 +624,7 @@ bool writeV5Config( const char *configFile, } bool writeV4Config( const char *configFile, - const boost::shared_ptr &config ) + const shared_ptr &config ) { ConfigReader cfg; @@ -1262,7 +1262,7 @@ RootPtr createV6Config( EncFS_Context *ctx, return rootInfo; } -void showFSInfo( const boost::shared_ptr &config ) +void showFSInfo( const shared_ptr &config ) { shared_ptr cipher = Cipher::New( config->cipherIface, -1 ); { @@ -1615,7 +1615,7 @@ CipherKey EncFSConfig::getNewUserKey() RootPtr initFS( EncFS_Context *ctx, const shared_ptr &opts ) { RootPtr rootInfo; - boost::shared_ptr config(new EncFSConfig); + shared_ptr config(new EncFSConfig); if(readConfig( opts->rootDir, config ) != Config_None) { diff --git a/encfs/FileUtils.h b/encfs/FileUtils.h index 87224d6..a97d2dc 100644 --- a/encfs/FileUtils.h +++ b/encfs/FileUtils.h @@ -47,15 +47,15 @@ class DirNode; struct EncFS_Root { - boost::shared_ptr cipher; + shared_ptr cipher; CipherKey volumeKey; - boost::shared_ptr root; + shared_ptr root; EncFS_Root(); ~EncFS_Root(); }; -typedef boost::shared_ptr RootPtr; +typedef shared_ptr RootPtr; enum ConfigMode { @@ -105,40 +105,40 @@ struct EncFS_Opts Read existing config file. Looks for any supported configuration version. */ ConfigType readConfig( const std::string &rootDir, - const boost::shared_ptr &config ); + const shared_ptr &config ); /* Save the configuration. Saves back as the same configuration type as was read from. */ bool saveConfig( ConfigType type, const std::string &rootdir, - const boost::shared_ptr &config ); + const shared_ptr &config ); class EncFS_Context; -RootPtr initFS( EncFS_Context *ctx, const boost::shared_ptr &opts ); +RootPtr initFS( EncFS_Context *ctx, const shared_ptr &opts ); RootPtr createV6Config( EncFS_Context *ctx, - const boost::shared_ptr &opts ); + const shared_ptr &opts ); -void showFSInfo( const boost::shared_ptr &config ); +void showFSInfo( const shared_ptr &config ); bool readV4Config( const char *configFile, - const boost::shared_ptr &config, + const shared_ptr &config, struct ConfigInfo *); bool writeV4Config( const char *configFile, - const boost::shared_ptr &config); + const shared_ptr &config); bool readV5Config( const char *configFile, - const boost::shared_ptr &config, + const shared_ptr &config, struct ConfigInfo *); bool writeV5Config( const char *configFile, - const boost::shared_ptr &config); + const shared_ptr &config); bool readV6Config( const char *configFile, - const boost::shared_ptr &config, + const shared_ptr &config, struct ConfigInfo *); bool writeV6Config( const char *configFile, - const boost::shared_ptr &config); + const shared_ptr &config); #endif diff --git a/encfs/MACFileIO.cpp b/encfs/MACFileIO.cpp index 8903c22..1c30f13 100644 --- a/encfs/MACFileIO.cpp +++ b/encfs/MACFileIO.cpp @@ -34,8 +34,6 @@ using namespace rlog; using namespace rel; using namespace std; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; static RLogChannel *Info = DEF_CHANNEL("info/MACFileIO", Log_Info); // diff --git a/encfs/MACFileIO.h b/encfs/MACFileIO.h index 72f5694..26921ec 100644 --- a/encfs/MACFileIO.h +++ b/encfs/MACFileIO.h @@ -24,8 +24,6 @@ #include "BlockFileIO.h" #include "Cipher.h" -using boost::shared_ptr; - class MACFileIO : public BlockFileIO { public: diff --git a/encfs/Makefile.am b/encfs/Makefile.am index 81461c9..778df1f 100644 --- a/encfs/Makefile.am +++ b/encfs/Makefile.am @@ -5,14 +5,7 @@ ALL_INCLUDES = @RLOG_CFLAGS@ @OPENSSL_CFLAGS@ @BOOST_CPPFLAGS@ ALL_LDFLAGS = @RLOG_LIBS@ @OPENSSL_LIBS@ @BOOST_LDFLAGS@ ALL_LDFLAGS += @BOOST_SERIALIZATION_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_SYSTEM_LIB@ -INCLUDES = $(all_includes) -I../intl - -AM_CXXFLAGS = -DRLOG_COMPONENT="encfs" $(ALL_INCLUDES) - -if DARWIN -# needed to select correct API in fuse.h -AM_CXXFLAGS += -D__FreeBSD__=10 -endif +AM_CXXFLAGS = -DRLOG_COMPONENT="encfs" $(ALL_INCLUDES) -I../intl if BUILD_NLS # define a C macro LOCALEDIR indicating where catalogs will be installed diff --git a/encfs/NameIO.h b/encfs/NameIO.h index 95f3aa6..ebef70f 100644 --- a/encfs/NameIO.h +++ b/encfs/NameIO.h @@ -29,7 +29,6 @@ #include "Interface.h" #include "CipherKey.h" -using boost::shared_ptr; class Cipher; class NameIO diff --git a/encfs/NullCipher.cpp b/encfs/NullCipher.cpp index 0fe3f34..d8d7fad 100644 --- a/encfs/NullCipher.cpp +++ b/encfs/NullCipher.cpp @@ -18,22 +18,19 @@ * along with this program. If not, see . */ + #include "NullCipher.h" +#include +#include + #include "Range.h" #include "Interface.h" - -#include -#include - -#include +#include "shared_ptr.h" using namespace std; using namespace rel; using namespace rlog; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; - static Interface NullInterface( "nullCipher", 1, 0, 0 ); static Range NullKeyRange(0); diff --git a/encfs/NullNameIO.cpp b/encfs/NullNameIO.cpp index e1da080..7c5e3c8 100644 --- a/encfs/NullNameIO.cpp +++ b/encfs/NullNameIO.cpp @@ -26,7 +26,6 @@ #include using namespace rel; -using boost::shared_ptr; static shared_ptr NewNNIO( const Interface &, const shared_ptr &, const CipherKey & ) diff --git a/encfs/RawFileIO.cpp b/encfs/RawFileIO.cpp index 39144d8..b78933e 100644 --- a/encfs/RawFileIO.cpp +++ b/encfs/RawFileIO.cpp @@ -296,7 +296,7 @@ int RawFileIO::truncate( off_t size ) if(fd >= 0 && canWrite) { res = ::ftruncate( fd, size ); -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__APPLE__) ::fdatasync( fd ); #endif } else diff --git a/encfs/SSL_Cipher.cpp b/encfs/SSL_Cipher.cpp index da5243e..a425490 100644 --- a/encfs/SSL_Cipher.cpp +++ b/encfs/SSL_Cipher.cpp @@ -48,9 +48,6 @@ using namespace std; using namespace rel; using namespace rlog; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; - const int MAX_KEYLENGTH = 32; // in bytes (256 bit) const int MAX_IVLENGTH = 16; const int KEY_CHECKSUM_BYTES = 4; diff --git a/encfs/SSL_Cipher.h b/encfs/SSL_Cipher.h index 9c776fa..efadde7 100644 --- a/encfs/SSL_Cipher.h +++ b/encfs/SSL_Cipher.h @@ -30,8 +30,6 @@ struct evp_cipher_st; typedef struct evp_cipher_st EVP_CIPHER; #endif -using boost::shared_ptr; - /* Implements Cipher interface for OpenSSL's ciphers. diff --git a/encfs/StreamNameIO.h b/encfs/StreamNameIO.h index 166f4d3..3d83c19 100644 --- a/encfs/StreamNameIO.h +++ b/encfs/StreamNameIO.h @@ -25,7 +25,6 @@ #include "CipherKey.h" class Cipher; -using boost::shared_ptr; class StreamNameIO : public NameIO { diff --git a/encfs/encfs.cpp b/encfs/encfs.cpp index dac15bd..fcade38 100644 --- a/encfs/encfs.cpp +++ b/encfs/encfs.cpp @@ -130,7 +130,7 @@ static int withFileNode( const char *opName, else fnode = FSRoot->lookupNode( path, opName ); - rAssert(fnode != NULL); + rAssert(fnode.get() != NULL); rLog(Info, "%s %s", opName, fnode->cipherName()); res = op( fnode.get(), data ); diff --git a/encfs/encfsctl.cpp b/encfs/encfsctl.cpp index 30e6995..ec0ff05 100644 --- a/encfs/encfsctl.cpp +++ b/encfs/encfsctl.cpp @@ -26,6 +26,7 @@ #include "Context.h" #include "FileNode.h" #include "DirNode.h" +#include "shared_ptr.h" #include #include @@ -51,8 +52,8 @@ using namespace rlog; using namespace std; -using namespace boost; using boost::format; +using boost::scoped_array; static int showInfo( int argc, char **argv ); static int showVersion( int argc, char **argv ); @@ -172,7 +173,7 @@ static int showInfo( int argc, char **argv ) if( !checkDir( rootDir )) return EXIT_FAILURE; - boost::shared_ptr config(new EncFSConfig); + shared_ptr config(new EncFSConfig); ConfigType type = readConfig( rootDir, config ); // show information stored in config.. @@ -698,7 +699,7 @@ static int do_chpasswd( bool useStdin, bool annotate, int argc, char **argv ) if( !checkDir( rootDir )) return EXIT_FAILURE; - boost::shared_ptr config(new EncFSConfig); + shared_ptr config(new EncFSConfig); ConfigType cfgType = readConfig( rootDir, config ); if(cfgType == Config_None) diff --git a/encfs/main.cpp b/encfs/main.cpp index 21dffc3..5492027 100644 --- a/encfs/main.cpp +++ b/encfs/main.cpp @@ -16,9 +16,6 @@ * */ -#include "encfs.h" -#include "config.h" - #include #include #include @@ -34,7 +31,6 @@ #include #include -#include #include #include @@ -43,13 +39,15 @@ #include #include "ConfigReader.h" +#include "Context.h" +#include "DirNode.h" +#include "FileUtils.h" #include "Interface.h" #include "MemoryPool.h" -#include "FileUtils.h" -#include "DirNode.h" -#include "Context.h" - +#include "config.h" +#include "encfs.h" #include "openssl.h" +#include "shared_ptr.h" #include @@ -71,7 +69,6 @@ using namespace std; using namespace rlog; using namespace rel; using boost::format; -using boost::shared_ptr; using boost::scoped_ptr; // Maximum number of arguments that we're going to pass on to fuse. Doesn't @@ -592,7 +589,7 @@ int main(int argc, char *argv[]) encfs_oper.utimens = encfs_utimens; //encfs_oper.bmap = encfs_bmap; -#if (__FreeBSD__ >= 10) +#if (__FreeBSD__ >= 10) || defined(__APPLE__) // encfs_oper.setvolname // encfs_oper.exchange // encfs_oper.getxtimes diff --git a/encfs/shared_ptr.h b/encfs/shared_ptr.h new file mode 100644 index 0000000..c9db750 --- /dev/null +++ b/encfs/shared_ptr.h @@ -0,0 +1,37 @@ + +/***************************************************************************** + * Author: Valient Gough + * + ***************************************************************************** + * Copyright (c) 2012 Valient Gough + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef _SHARED_PTR_incl_ +#define _SHARED_PTR_incl_ + +#include "config.h" + +#ifdef HAVE_STD_SHARED_PTR +#include +using std::shared_ptr; +using std::dynamic_pointer_cast; +#else +#include +using boost::shared_ptr; +using boost::dynamic_pointer_cast; +#endif + +#endif diff --git a/encfs/test.cpp b/encfs/test.cpp index 95517c4..bea0d44 100644 --- a/encfs/test.cpp +++ b/encfs/test.cpp @@ -52,8 +52,6 @@ using namespace std; using namespace rel; using namespace rlog; -using boost::shared_ptr; - const int FSBlockSize = 256; static