mirror of
https://github.com/vgough/encfs.git
synced 2025-02-23 13:11:40 +01:00
reduce boost dependencies
enables c++11 mode on GCC also fix soft links to root paths in reverse mode
This commit is contained in:
parent
73ea32c2c2
commit
19aba9fa77
19
configure.ac
19
configure.ac
@ -46,23 +46,7 @@ AC_PROG_LIBTOOL
|
||||
AX_PTHREAD
|
||||
|
||||
AX_BOOST_BASE([1.34])
|
||||
AX_BOOST_SYSTEM
|
||||
AX_BOOST_SERIALIZATION
|
||||
AX_BOOST_FILESYSTEM
|
||||
|
||||
AC_MSG_CHECKING([for std::shared_ptr])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||
[[#include <memory>]]
|
||||
[[std::shared_ptr<int> have_shared_ptr;]])
|
||||
], [
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE_UNQUOTED([HAVE_STD_SHARED_PTR], 1,
|
||||
[Define to 1 if you have the 'std::shared_ptr' class.])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
AC_DEFINE_UNQUOTED([HAVE_STD_SHARED_PTR], 0,
|
||||
[Define to 1 if you have the 'std::shared_ptr' class.])
|
||||
])
|
||||
|
||||
dnl Need to include any user specified flags in the tests below, as they might
|
||||
dnl specify required include directories..
|
||||
@ -84,7 +68,10 @@ AX_EXT_HAVE_LIB(/usr/lib /usr/local/lib /opt/lib /opt/local/lib, osxfuse,
|
||||
|
||||
if test "$GXX" = "yes"; then
|
||||
CXXFLAGS="-W -Wall -Wpointer-arith -Wwrite-strings $CXXFLAGS"
|
||||
CXXFLAGS="-std=c++11 $CXXFLAGS"
|
||||
dnl CXXFLAGS="$CXXFLAGS -Wformat=2 -Wconversion"
|
||||
elif test -z "${DARWIN_TRUE}"; then
|
||||
CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS"
|
||||
fi
|
||||
|
||||
if test -z "${DARWIN_TRUE}"; then
|
||||
|
@ -18,14 +18,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "FileNode.h"
|
||||
#include "Context.h"
|
||||
#include "Mutex.h"
|
||||
#include "FileUtils.h"
|
||||
#include "DirNode.h"
|
||||
|
||||
#include <rlog/rlog.h>
|
||||
|
||||
#include "Context.h"
|
||||
#include "DirNode.h"
|
||||
#include "FileNode.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
using namespace rel;
|
||||
using namespace rlog;
|
||||
|
||||
@ -74,7 +74,7 @@ void EncFS_Context::setRoot(const shared_ptr<DirNode> &r) {
|
||||
if (r) rootCipherDir = r->rootDirectory();
|
||||
}
|
||||
|
||||
bool EncFS_Context::isMounted() { return root; }
|
||||
bool EncFS_Context::isMounted() { return root.get() != nullptr; }
|
||||
|
||||
int EncFS_Context::getAndResetUsageCounter() {
|
||||
Lock lock(contextMutex);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#else
|
||||
#include <map>
|
||||
#endif
|
||||
#include <string>
|
||||
|
||||
#include "encfs.h"
|
||||
#include "shared_ptr.h"
|
||||
|
@ -103,8 +103,7 @@ std::string DirTraverse::nextPlaintextName(int *fileType, ino_t *inode) {
|
||||
try {
|
||||
uint64_t localIv = iv;
|
||||
return naming->decodePath(de->d_name, &localIv);
|
||||
}
|
||||
catch (rlog::Error &ex) {
|
||||
} catch (rlog::Error &ex) {
|
||||
// .. .problem decoding, ignore it and continue on to next name..
|
||||
rDebug("error decoding filename: %s", de->d_name);
|
||||
}
|
||||
@ -121,8 +120,7 @@ std::string DirTraverse::nextInvalid() {
|
||||
uint64_t localIv = iv;
|
||||
naming->decodePath(de->d_name, &localIv);
|
||||
continue;
|
||||
}
|
||||
catch (rlog::Error &ex) {
|
||||
} catch (rlog::Error &ex) {
|
||||
return string(de->d_name);
|
||||
}
|
||||
}
|
||||
@ -159,7 +157,7 @@ class RenameOp {
|
||||
|
||||
~RenameOp();
|
||||
|
||||
operator bool() const { return renameList; }
|
||||
operator bool() const { return renameList.get() != nullptr; }
|
||||
|
||||
bool apply();
|
||||
void undo();
|
||||
@ -209,8 +207,7 @@ bool RenameOp::apply() {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
err.log(_RLWarningChannel);
|
||||
return false;
|
||||
}
|
||||
@ -238,8 +235,7 @@ void RenameOp::undo() {
|
||||
::rename(it->newCName.c_str(), it->oldCName.c_str());
|
||||
try {
|
||||
dn->renameNode(it->newPName.c_str(), it->oldPName.c_str(), false);
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
err.log(_RLWarningChannel);
|
||||
// continue on anyway...
|
||||
}
|
||||
@ -291,17 +287,18 @@ string DirNode::plainPath(const char *cipherPath_) {
|
||||
try {
|
||||
if (!strncmp(cipherPath_, rootDir.c_str(), rootDir.length())) {
|
||||
return naming->decodePath(cipherPath_ + rootDir.length());
|
||||
} else {
|
||||
if (cipherPath_[0] == '+') {
|
||||
// decode as fully qualified path
|
||||
return string("/") +
|
||||
}
|
||||
|
||||
// Handle special absolute path encodings.
|
||||
char mark = fsConfig->reverseEncryption ? '/' : '+';
|
||||
if (cipherPath_[0] == mark) {
|
||||
return string(fsConfig->reverseEncryption ? "+" : "/") +
|
||||
naming->decodeName(cipherPath_ + 1, strlen(cipherPath_ + 1));
|
||||
} else {
|
||||
}
|
||||
|
||||
// Default.
|
||||
return naming->decodePath(cipherPath_);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("decode err: %s", err.message());
|
||||
err.log(_RLWarningChannel);
|
||||
|
||||
@ -311,15 +308,15 @@ string DirNode::plainPath(const char *cipherPath_) {
|
||||
|
||||
string DirNode::relativeCipherPath(const char *plaintextPath) {
|
||||
try {
|
||||
if (plaintextPath[0] == '/') {
|
||||
// mark with '+' to indicate special decoding..
|
||||
return string("+") +
|
||||
// use '+' prefix to indicate special decoding.
|
||||
char mark = fsConfig->reverseEncryption ? '+' : '/';
|
||||
if (plaintextPath[0] == mark) {
|
||||
return string(fsConfig->reverseEncryption ? "/" : "+") +
|
||||
naming->encodeName(plaintextPath + 1, strlen(plaintextPath + 1));
|
||||
} else {
|
||||
}
|
||||
|
||||
return naming->encodePath(plaintextPath);
|
||||
}
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("encode err: %s", err.message());
|
||||
err.log(_RLWarningChannel);
|
||||
|
||||
@ -343,8 +340,7 @@ DirTraverse DirNode::openDir(const char *plaintextPath) {
|
||||
// directory level..
|
||||
try {
|
||||
if (naming->getChainedNameIV()) naming->encodePath(plaintextPath, &iv);
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("encode err: %s", err.message());
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -387,8 +383,7 @@ bool DirNode::genRenameList(list<RenameEl> &renameList, const char *fromP,
|
||||
|
||||
try {
|
||||
plainName = naming->decodePath(de->d_name, &localIV);
|
||||
}
|
||||
catch (rlog::Error &ex) {
|
||||
} catch (rlog::Error &ex) {
|
||||
// if filename can't be decoded, then ignore it..
|
||||
continue;
|
||||
}
|
||||
@ -433,8 +428,7 @@ bool DirNode::genRenameList(list<RenameEl> &renameList, const char *fromP,
|
||||
rDebug("adding file %s to rename list", oldFull.c_str());
|
||||
|
||||
renameList.push_back(ren);
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
// We can't convert this name, because we don't have a valid IV for
|
||||
// it (or perhaps a valid key).. It will be inaccessible..
|
||||
rWarning("Aborting rename: error on file: %s",
|
||||
@ -544,8 +538,7 @@ int DirNode::rename(const char *fromPlaintext, const char *toPlaintext) {
|
||||
ut.modtime = st.st_mtime;
|
||||
::utime(toCName.c_str(), &ut);
|
||||
}
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
// exception from renameNode, just show the error and continue..
|
||||
err.log(_RLWarningChannel);
|
||||
res = -EIO;
|
||||
|
@ -24,22 +24,6 @@
|
||||
#endif
|
||||
#define _BSD_SOURCE // pick up setenv on RH7.3
|
||||
|
||||
#include "encfs.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "readpassphrase.h"
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include "ConfigReader.h"
|
||||
#include "FSConfig.h"
|
||||
|
||||
#include "DirNode.h"
|
||||
#include "Cipher.h"
|
||||
#include "StreamNameIO.h"
|
||||
#include "BlockNameIO.h"
|
||||
#include "NullNameIO.h"
|
||||
#include "Context.h"
|
||||
|
||||
#include <rlog/rlog.h>
|
||||
#include <rlog/Error.h>
|
||||
|
||||
@ -56,18 +40,33 @@
|
||||
#include <cstring>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/binary_object.hpp>
|
||||
|
||||
#include "encfs.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "autosprintf.h"
|
||||
#include "readpassphrase.h"
|
||||
#include "BlockNameIO.h"
|
||||
#include "Cipher.h"
|
||||
#include "ConfigReader.h"
|
||||
#include "Context.h"
|
||||
#include "DirNode.h"
|
||||
#include "FSConfig.h"
|
||||
#include "FileUtils.h"
|
||||
#include "NullNameIO.h"
|
||||
#include "StreamNameIO.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
|
||||
// disable rlog section grouping for this file.. seems to cause problems
|
||||
#undef RLOG_SECTION
|
||||
#define RLOG_SECTION
|
||||
@ -75,9 +74,8 @@
|
||||
using namespace rel;
|
||||
using namespace rlog;
|
||||
using namespace std;
|
||||
namespace fs = boost::filesystem;
|
||||
using gnu::autosprintf;
|
||||
namespace serial = boost::serialization;
|
||||
using boost::format;
|
||||
|
||||
static const int DefaultBlockSize = 1024;
|
||||
// The maximum length of text passwords. If longer are needed,
|
||||
@ -291,10 +289,9 @@ bool userAllowMkdir(int promptno, const char *path, mode_t mode) {
|
||||
// TODO: can we internationalize the y/n names? Seems strange to prompt in
|
||||
// their own language but then have to respond 'y' or 'n'.
|
||||
// xgroup(setup)
|
||||
cerr << format(
|
||||
cerr << autosprintf(
|
||||
_("The directory \"%s\" does not exist. Should it be created? "
|
||||
"(y,n) ")) %
|
||||
path;
|
||||
"(y,n) "), path);
|
||||
char answer[10];
|
||||
char *res;
|
||||
|
||||
@ -370,7 +367,7 @@ bool readV6Config(const char *configFile, const shared_ptr<EncFSConfig> &config,
|
||||
ConfigInfo *info) {
|
||||
(void)info;
|
||||
|
||||
fs::ifstream st(configFile);
|
||||
ifstream st(configFile);
|
||||
if (st.is_open()) {
|
||||
try {
|
||||
boost::archive::xml_iarchive ia(st);
|
||||
@ -508,7 +505,7 @@ bool saveConfig(ConfigType type, const string &rootDir,
|
||||
|
||||
bool writeV6Config(const char *configFile,
|
||||
const shared_ptr<EncFSConfig> &config) {
|
||||
fs::ofstream st(configFile);
|
||||
ofstream st(configFile);
|
||||
if (!st.is_open()) return false;
|
||||
|
||||
st << *config;
|
||||
@ -593,28 +590,27 @@ static Cipher::CipherAlgorithm selectCipherAlgorithm() {
|
||||
if (it->keyLength.min() == it->keyLength.max()) {
|
||||
// shown after algorithm name and description.
|
||||
// xgroup(setup)
|
||||
cout << format(_(" -- key length %i bits")) % it->keyLength.min()
|
||||
cout << autosprintf(_(" -- key length %i bits"), it->keyLength.min())
|
||||
<< "\n";
|
||||
} else {
|
||||
cout << format(
|
||||
cout << autosprintf(
|
||||
// shown after algorithm name and description.
|
||||
// xgroup(setup)
|
||||
_(" -- Supports key lengths of %i to %i bits")) %
|
||||
it->keyLength.min() % it->keyLength.max() << "\n";
|
||||
_(" -- Supports key lengths of %i to %i bits"),
|
||||
it->keyLength.min(), it->keyLength.max()) << "\n";
|
||||
}
|
||||
|
||||
if (it->blockSize.min() == it->blockSize.max()) {
|
||||
cout << format(
|
||||
cout << autosprintf(
|
||||
// shown after algorithm name and description.
|
||||
// xgroup(setup)
|
||||
_(" -- block size %i bytes")) %
|
||||
it->blockSize.min() << "\n";
|
||||
_(" -- block size %i bytes"), it->blockSize.min()) << "\n";
|
||||
} else {
|
||||
cout << format(
|
||||
cout << autosprintf(
|
||||
// shown after algorithm name and description.
|
||||
// xgroup(setup)
|
||||
_(" -- Supports block sizes of %i to %i bytes")) %
|
||||
it->blockSize.min() % it->blockSize.max() << "\n";
|
||||
_(" -- Supports block sizes of %i to %i bytes"),
|
||||
it->blockSize.min(), it->blockSize.max()) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -637,7 +633,7 @@ static Cipher::CipherAlgorithm selectCipherAlgorithm() {
|
||||
Cipher::CipherAlgorithm alg = *it;
|
||||
|
||||
// xgroup(setup)
|
||||
cout << format(_("Selected algorithm \"%s\"")) % alg.name << "\n\n";
|
||||
cout << autosprintf(_("Selected algorithm \"%s\""), alg.name.c_str()) << "\n\n";
|
||||
|
||||
return alg;
|
||||
}
|
||||
@ -674,7 +670,7 @@ static Interface selectNameCoding() {
|
||||
++it;
|
||||
|
||||
// xgroup(setup)
|
||||
cout << format(_("Selected algorithm \"%s\"")) % it->name << "\"\n\n";
|
||||
cout << autosprintf(_("Selected algorithm \"%s\""), it->name.c_str()) << "\"\n\n";
|
||||
|
||||
return it->iface;
|
||||
}
|
||||
@ -682,18 +678,18 @@ static Interface selectNameCoding() {
|
||||
|
||||
static int selectKeySize(const Cipher::CipherAlgorithm &alg) {
|
||||
if (alg.keyLength.min() == alg.keyLength.max()) {
|
||||
cout << format(_("Using key size of %i bits")) % alg.keyLength.min()
|
||||
cout << autosprintf(_("Using key size of %i bits"), alg.keyLength.min())
|
||||
<< "\n";
|
||||
return alg.keyLength.min();
|
||||
}
|
||||
|
||||
cout
|
||||
<< format(
|
||||
<< autosprintf(
|
||||
// xgroup(setup)
|
||||
_("Please select a key size in bits. The cipher you have chosen\n"
|
||||
"supports sizes from %i to %i bits in increments of %i bits.\n"
|
||||
"For example: ")) %
|
||||
alg.keyLength.min() % alg.keyLength.max() % alg.keyLength.inc()
|
||||
"For example: "),
|
||||
alg.keyLength.min(), alg.keyLength.max(), alg.keyLength.inc())
|
||||
<< "\n";
|
||||
|
||||
int numAvail =
|
||||
@ -725,27 +721,27 @@ static int selectKeySize(const Cipher::CipherAlgorithm &alg) {
|
||||
keySize = alg.keyLength.closest(keySize);
|
||||
|
||||
// xgroup(setup)
|
||||
cout << format(_("Using key size of %i bits")) % keySize << "\n\n";
|
||||
cout << autosprintf(_("Using key size of %i bits"), keySize) << "\n\n";
|
||||
|
||||
return keySize;
|
||||
}
|
||||
|
||||
static int selectBlockSize(const Cipher::CipherAlgorithm &alg) {
|
||||
if (alg.blockSize.min() == alg.blockSize.max()) {
|
||||
cout << format(
|
||||
cout << autosprintf(
|
||||
// xgroup(setup)
|
||||
_("Using filesystem block size of %i bytes")) %
|
||||
alg.blockSize.min() << "\n";
|
||||
_("Using filesystem block size of %i bytes"),
|
||||
alg.blockSize.min()) << "\n";
|
||||
return alg.blockSize.min();
|
||||
}
|
||||
|
||||
cout << format(
|
||||
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;
|
||||
"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: ");
|
||||
@ -760,7 +756,7 @@ static int selectBlockSize(const Cipher::CipherAlgorithm &alg) {
|
||||
blockSize = alg.blockSize.closest(blockSize);
|
||||
|
||||
// xgroup(setup)
|
||||
cout << format(_("Using filesystem block size of %i bytes")) % blockSize
|
||||
cout << autosprintf(_("Using filesystem block size of %i bytes"), blockSize)
|
||||
<< "\n\n";
|
||||
|
||||
return blockSize;
|
||||
@ -1117,12 +1113,12 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
|
||||
void showFSInfo(const shared_ptr<EncFSConfig> &config) {
|
||||
shared_ptr<Cipher> cipher = Cipher::New(config->cipherIface, -1);
|
||||
{
|
||||
cout << format(
|
||||
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();
|
||||
_("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");
|
||||
@ -1131,17 +1127,17 @@ void showFSInfo(const shared_ptr<EncFSConfig> &config) {
|
||||
if (config->cipherIface != cipher->interface()) {
|
||||
Interface iface = cipher->interface();
|
||||
// xgroup(diag)
|
||||
cout << format(_(" (using %i:%i:%i)\n")) % iface.current() %
|
||||
iface.revision() % iface.age();
|
||||
cout << autosprintf(_(" (using %i:%i:%i)\n"), iface.current(),
|
||||
iface.revision(), iface.age());
|
||||
} else
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
{
|
||||
// xgroup(diag)
|
||||
cout << format(_("Filename encoding: \"%s\", version %i:%i:%i")) %
|
||||
config->nameIface.name().c_str() % config->nameIface.current() %
|
||||
config->nameIface.revision() % config->nameIface.age();
|
||||
cout << autosprintf(_("Filename encoding: \"%s\", version %i:%i:%i"),
|
||||
config->nameIface.name().c_str(), config->nameIface.current(),
|
||||
config->nameIface.revision(), config->nameIface.age());
|
||||
|
||||
// check if we support the filename encoding interface..
|
||||
shared_ptr<NameIO> nameCoder =
|
||||
@ -1153,14 +1149,14 @@ void showFSInfo(const shared_ptr<EncFSConfig> &config) {
|
||||
// if we're using a newer interface, show the version number
|
||||
if (config->nameIface != nameCoder->interface()) {
|
||||
Interface iface = nameCoder->interface();
|
||||
cout << format(_(" (using %i:%i:%i)\n")) % iface.current() %
|
||||
iface.revision() % iface.age();
|
||||
cout << autosprintf(_(" (using %i:%i:%i)\n"), iface.current(),
|
||||
iface.revision(), iface.age());
|
||||
} else
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
{
|
||||
cout << format(_("Key Size: %i bits")) % config->keySize;
|
||||
cout << autosprintf(_("Key Size: %i bits"), config->keySize);
|
||||
cipher = config->getCipher();
|
||||
if (!cipher) {
|
||||
// xgroup(diag)
|
||||
@ -1169,28 +1165,28 @@ void showFSInfo(const shared_ptr<EncFSConfig> &config) {
|
||||
cout << "\n";
|
||||
}
|
||||
if (config->kdfIterations > 0 && config->salt.size() > 0) {
|
||||
cout << format(_("Using PBKDF2, with %i iterations")) %
|
||||
config->kdfIterations << "\n";
|
||||
cout << format(_("Salt Size: %i bits")) % (8 * config->salt.size()) << "\n";
|
||||
cout << autosprintf(_("Using PBKDF2, with %i iterations"),
|
||||
config->kdfIterations) << "\n";
|
||||
cout << autosprintf(_("Salt Size: %i bits"), 8 * config->salt.size()) << "\n";
|
||||
}
|
||||
if (config->blockMACBytes || config->blockMACRandBytes) {
|
||||
if (config->subVersion < 20040813) {
|
||||
cout << format(
|
||||
cout << autosprintf(
|
||||
// xgroup(diag)
|
||||
_("Block Size: %i bytes + %i byte MAC header")) %
|
||||
config->blockSize %
|
||||
(config->blockMACBytes + config->blockMACRandBytes) << endl;
|
||||
_("Block Size: %i bytes + %i byte MAC header"),
|
||||
config->blockSize,
|
||||
config->blockMACBytes + config->blockMACRandBytes) << endl;
|
||||
} else {
|
||||
// new version stores the header as part of that block size..
|
||||
cout << format(
|
||||
cout << autosprintf(
|
||||
// xgroup(diag)
|
||||
_("Block Size: %i bytes, including %i byte MAC header")) %
|
||||
config->blockSize %
|
||||
(config->blockMACBytes + config->blockMACRandBytes) << endl;
|
||||
_("Block Size: %i bytes, including %i byte MAC header"),
|
||||
config->blockSize,
|
||||
config->blockMACBytes + config->blockMACRandBytes) << endl;
|
||||
}
|
||||
} else {
|
||||
// xgroup(diag)
|
||||
cout << format(_("Block Size: %i bytes")) % config->blockSize;
|
||||
cout << autosprintf(_("Block Size: %i bytes"), config->blockSize);
|
||||
cout << "\n";
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ include $(top_srcdir)/Makefile.common
|
||||
|
||||
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@
|
||||
ALL_LDFLAGS += @BOOST_SERIALIZATION_LIB@
|
||||
|
||||
AM_CXXFLAGS = -DRLOG_COMPONENT="encfs" $(ALL_INCLUDES) -I../intl
|
||||
|
||||
@ -43,7 +43,7 @@ endif
|
||||
libencfs_la_LDFLAGS = -version-info 6:2:0
|
||||
libencfs_la_LIBADD = @RLOG_LIBS@ \
|
||||
@OPENSSL_LIBS@ \
|
||||
@BOOST_SERIALIZATION_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_SYSTEM_LIB@
|
||||
@BOOST_SERIALIZATION_LIB@
|
||||
|
||||
EXTRASRC =
|
||||
if BUILD_OPENSSL
|
||||
@ -53,6 +53,7 @@ endif
|
||||
endif
|
||||
|
||||
libencfs_la_SOURCES = \
|
||||
autosprintf.cpp \
|
||||
readpassphrase.cpp \
|
||||
base64.cpp \
|
||||
ConfigReader.cpp \
|
||||
|
67
encfs/autosprintf.cpp
Normal file
67
encfs/autosprintf.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
/* Class autosprintf - formatted output to an ostream.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2002.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
/* Tell glibc's <stdio.h> to provide a prototype for vasprintf().
|
||||
This must come before <config.h> because <config.h> may include
|
||||
<features.h>, and once <features.h> has been included, it's too late. */
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
/* Specification. */
|
||||
#include "autosprintf.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include "lib-asprintf.h"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace gnu {
|
||||
|
||||
/* Constructor: takes a format string and the printf arguments. */
|
||||
autosprintf::autosprintf(const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
if (vasprintf(&str, format, args) < 0) str = NULL;
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/* Copy constructor. Necessary because the destructor is nontrivial. */
|
||||
autosprintf::autosprintf(const autosprintf &src) {
|
||||
str = (src.str != NULL ? strdup(src.str) : NULL);
|
||||
}
|
||||
|
||||
/* Destructor: frees the temporarily allocated string. */
|
||||
autosprintf::~autosprintf() { free(str); }
|
||||
|
||||
/* Conversion to string. */
|
||||
autosprintf::operator char *() const {
|
||||
if (str != NULL) {
|
||||
size_t length = strlen(str) + 1;
|
||||
char *copy = new char[length];
|
||||
memcpy(copy, str, length);
|
||||
return copy;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
autosprintf::operator std::string() const {
|
||||
return std::string(str ? str : "(error in autosprintf)");
|
||||
}
|
||||
}
|
65
encfs/autosprintf.h
Normal file
65
encfs/autosprintf.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* Class autosprintf - formatted output to an ostream.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _AUTOSPRINTF_H
|
||||
#define _AUTOSPRINTF_H
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
|
||||
#define __attribute__(Spec) /* empty */
|
||||
#endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
#define __format__ format
|
||||
#define __printf__ printf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
namespace gnu {
|
||||
/* A temporary object, usually allocated on the stack, representing
|
||||
the result of an asprintf() call. */
|
||||
class autosprintf {
|
||||
public:
|
||||
/* Constructor: takes a format string and the printf arguments. */
|
||||
autosprintf(const char* format, ...)
|
||||
__attribute__((__format__(__printf__, 2, 3)));
|
||||
/* Copy constructor. */
|
||||
autosprintf(const autosprintf& src);
|
||||
/* Destructor: frees the temporarily allocated string. */
|
||||
~autosprintf();
|
||||
/* Conversion to string. */
|
||||
operator char*() const;
|
||||
operator std::string() const;
|
||||
/* Output to an ostream. */
|
||||
friend inline std::ostream& operator<<(std::ostream& stream,
|
||||
const autosprintf& tmp) {
|
||||
stream << (tmp.str ? tmp.str : "(error in autosprintf)");
|
||||
return stream;
|
||||
}
|
||||
|
||||
private:
|
||||
char* str;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _AUTOSPRINTF_H */
|
189
encfs/encfs.cpp
189
encfs/encfs.cpp
@ -37,11 +37,10 @@
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/scoped_array.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "DirNode.h"
|
||||
#include "MemoryPool.h"
|
||||
@ -59,11 +58,11 @@
|
||||
#define ESUCCESS 0
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace rlog;
|
||||
using rel::Lock;
|
||||
using namespace boost;
|
||||
|
||||
#define GET_FN(ctx, finfo) ctx->getNode((void *)(uintptr_t)finfo->fh)
|
||||
#define GET_FN(ctx, finfo) ctx->getNode((void *)(uintptr_t) finfo->fh)
|
||||
|
||||
static RLogChannel *Info = DEF_CHANNEL("info", Log_Info);
|
||||
|
||||
@ -72,11 +71,9 @@ static EncFS_Context *context() {
|
||||
}
|
||||
|
||||
// helper function -- apply a functor to a cipher path, given the plain path
|
||||
template <typename T>
|
||||
static int withCipherPath(const char *opName, const char *path,
|
||||
int (*op)(EncFS_Context *, const string &name,
|
||||
T data),
|
||||
T data, bool passReturnCode = false) {
|
||||
function<int(EncFS_Context *, const string &)> op,
|
||||
bool passReturnCode = false) {
|
||||
EncFS_Context *ctx = context();
|
||||
|
||||
int res = -EIO;
|
||||
@ -87,7 +84,7 @@ static int withCipherPath(const char *opName, const char *path,
|
||||
string cyName = FSRoot->cipherPath(path);
|
||||
rLog(Info, "%s %s", opName, cyName.c_str());
|
||||
|
||||
res = op(ctx, cyName, data);
|
||||
res = op(ctx, cyName);
|
||||
|
||||
if (res == -1) {
|
||||
int eno = errno;
|
||||
@ -95,8 +92,7 @@ static int withCipherPath(const char *opName, const char *path,
|
||||
res = -eno;
|
||||
} else if (!passReturnCode)
|
||||
res = ESUCCESS;
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in %s", opName);
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -104,10 +100,9 @@ static int withCipherPath(const char *opName, const char *path,
|
||||
}
|
||||
|
||||
// helper function -- apply a functor to a node
|
||||
template <typename T>
|
||||
static int withFileNode(const char *opName, const char *path,
|
||||
struct fuse_file_info *fi,
|
||||
int (*op)(FileNode *, T data), T data) {
|
||||
function<int(FileNode *)> op) {
|
||||
EncFS_Context *ctx = context();
|
||||
|
||||
int res = -EIO;
|
||||
@ -124,11 +119,10 @@ static int withFileNode(const char *opName, const char *path,
|
||||
|
||||
rAssert(fnode.get() != NULL);
|
||||
rLog(Info, "%s %s", opName, fnode->cipherName());
|
||||
res = op(fnode.get(), data);
|
||||
res = op(fnode.get());
|
||||
|
||||
if (res < 0) rInfo("%s error: %s", opName, strerror(-res));
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in %s", opName);
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -153,15 +147,15 @@ int _do_getattr(FileNode *fnode, struct stat *stbuf) {
|
||||
shared_ptr<DirNode> FSRoot = ctx->getRoot(&res);
|
||||
if (FSRoot) {
|
||||
// determine plaintext link size.. Easiest to read and decrypt..
|
||||
scoped_array<char> buf(new char[stbuf->st_size + 1]);
|
||||
std::vector<char> buf(stbuf->st_size + 1, '\0');
|
||||
|
||||
res = ::readlink(fnode->cipherName(), buf.get(), stbuf->st_size);
|
||||
res = ::readlink(fnode->cipherName(), buf.data(), stbuf->st_size);
|
||||
if (res >= 0) {
|
||||
// other functions expect c-strings to be null-terminated, which
|
||||
// readlink doesn't provide
|
||||
buf[res] = '\0';
|
||||
|
||||
stbuf->st_size = FSRoot->plainPath(buf.get()).length();
|
||||
stbuf->st_size = FSRoot->plainPath(buf.data()).length();
|
||||
|
||||
res = ESUCCESS;
|
||||
} else
|
||||
@ -173,12 +167,12 @@ int _do_getattr(FileNode *fnode, struct stat *stbuf) {
|
||||
}
|
||||
|
||||
int encfs_getattr(const char *path, struct stat *stbuf) {
|
||||
return withFileNode("getattr", path, NULL, _do_getattr, stbuf);
|
||||
return withFileNode("getattr", path, NULL, bind(_do_getattr, _1, stbuf));
|
||||
}
|
||||
|
||||
int encfs_fgetattr(const char *path, struct stat *stbuf,
|
||||
struct fuse_file_info *fi) {
|
||||
return withFileNode("fgetattr", path, fi, _do_getattr, stbuf);
|
||||
return withFileNode("fgetattr", path, fi, bind(_do_getattr, _1, stbuf));
|
||||
}
|
||||
|
||||
int encfs_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler) {
|
||||
@ -211,8 +205,7 @@ int encfs_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler) {
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("Error caught in getdir");
|
||||
err.log(_RLWarningChannel);
|
||||
return -EIO;
|
||||
@ -251,8 +244,7 @@ int encfs_mknod(const char *path, mode_t mode, dev_t rdev) {
|
||||
if (dnode->getAttr(&st) == 0)
|
||||
res = fnode->mknod(mode, rdev, uid, st.st_gid);
|
||||
}
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in mknod");
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -285,8 +277,7 @@ int encfs_mkdir(const char *path, mode_t mode) {
|
||||
if (dnode->getAttr(&st) == 0)
|
||||
res = FSRoot->mkdir(path, mode, uid, st.st_gid);
|
||||
}
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in mkdir");
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -304,27 +295,23 @@ int encfs_unlink(const char *path) {
|
||||
// let DirNode handle it atomically so that it can handle race
|
||||
// conditions
|
||||
res = FSRoot->unlink(path);
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in unlink");
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int _do_rmdir(EncFS_Context *, const string &cipherPath, int) {
|
||||
int _do_rmdir(EncFS_Context *, const string &cipherPath) {
|
||||
return rmdir(cipherPath.c_str());
|
||||
}
|
||||
|
||||
int encfs_rmdir(const char *path) {
|
||||
return withCipherPath("rmdir", path, _do_rmdir, 0);
|
||||
return withCipherPath("rmdir", path, bind(_do_rmdir, _1, _2));
|
||||
}
|
||||
|
||||
int _do_readlink(EncFS_Context *ctx, const string &cyName,
|
||||
tuple<char *, size_t> data) {
|
||||
char *buf = data.get<0>();
|
||||
size_t size = data.get<1>();
|
||||
|
||||
int _do_readlink(EncFS_Context *ctx, const string &cyName, char *buf,
|
||||
size_t size) {
|
||||
int res = ESUCCESS;
|
||||
shared_ptr<DirNode> FSRoot = ctx->getRoot(&res);
|
||||
if (!FSRoot) return res;
|
||||
@ -337,8 +324,7 @@ int _do_readlink(EncFS_Context *ctx, const string &cyName,
|
||||
string decodedName;
|
||||
try {
|
||||
decodedName = FSRoot->plainPath(buf);
|
||||
}
|
||||
catch (...) {
|
||||
} catch (...) {
|
||||
}
|
||||
|
||||
if (!decodedName.empty()) {
|
||||
@ -353,7 +339,8 @@ int _do_readlink(EncFS_Context *ctx, const string &cyName,
|
||||
}
|
||||
|
||||
int encfs_readlink(const char *path, char *buf, size_t size) {
|
||||
return withCipherPath("readlink", path, _do_readlink, make_tuple(buf, size));
|
||||
return withCipherPath("readlink", path,
|
||||
bind(_do_readlink, _1, _2, buf, size));
|
||||
}
|
||||
|
||||
int encfs_symlink(const char *from, const char *to) {
|
||||
@ -387,8 +374,7 @@ int encfs_symlink(const char *from, const char *to) {
|
||||
res = -errno;
|
||||
else
|
||||
res = ESUCCESS;
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in symlink");
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -404,8 +390,7 @@ int encfs_link(const char *from, const char *to) {
|
||||
|
||||
try {
|
||||
res = FSRoot->link(from, to);
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in link");
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -421,8 +406,7 @@ int encfs_rename(const char *from, const char *to) {
|
||||
|
||||
try {
|
||||
res = FSRoot->rename(from, to);
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in rename");
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -434,26 +418,26 @@ int _do_chmod(EncFS_Context *, const string &cipherPath, mode_t mode) {
|
||||
}
|
||||
|
||||
int encfs_chmod(const char *path, mode_t mode) {
|
||||
return withCipherPath("chmod", path, _do_chmod, mode);
|
||||
return withCipherPath("chmod", path, bind(_do_chmod, _1, _2, mode));
|
||||
}
|
||||
|
||||
int _do_chown(EncFS_Context *, const string &cyName, tuple<uid_t, gid_t> data) {
|
||||
int res = lchown(cyName.c_str(), data.get<0>(), data.get<1>());
|
||||
int _do_chown(EncFS_Context *, const string &cyName, uid_t u, gid_t g) {
|
||||
int res = lchown(cyName.c_str(), u, g);
|
||||
return (res == -1) ? -errno : ESUCCESS;
|
||||
}
|
||||
|
||||
int encfs_chown(const char *path, uid_t uid, gid_t gid) {
|
||||
return withCipherPath("chown", path, _do_chown, make_tuple(uid, gid));
|
||||
return withCipherPath("chown", path, bind(_do_chown, _1, _2, uid, gid));
|
||||
}
|
||||
|
||||
int _do_truncate(FileNode *fnode, off_t size) { return fnode->truncate(size); }
|
||||
|
||||
int encfs_truncate(const char *path, off_t size) {
|
||||
return withFileNode("truncate", path, NULL, _do_truncate, size);
|
||||
return withFileNode("truncate", path, NULL, bind(_do_truncate, _1, size));
|
||||
}
|
||||
|
||||
int encfs_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) {
|
||||
return withFileNode("ftruncate", path, fi, _do_truncate, size);
|
||||
return withFileNode("ftruncate", path, fi, bind(_do_truncate, _1, size));
|
||||
}
|
||||
|
||||
int _do_utime(EncFS_Context *, const string &cyName, struct utimbuf *buf) {
|
||||
@ -462,7 +446,7 @@ int _do_utime(EncFS_Context *, const string &cyName, struct utimbuf *buf) {
|
||||
}
|
||||
|
||||
int encfs_utime(const char *path, struct utimbuf *buf) {
|
||||
return withCipherPath("utime", path, _do_utime, buf);
|
||||
return withCipherPath("utime", path, bind(_do_utime, _1, _2, buf));
|
||||
}
|
||||
|
||||
int _do_utimens(EncFS_Context *, const string &cyName,
|
||||
@ -478,7 +462,7 @@ int _do_utimens(EncFS_Context *, const string &cyName,
|
||||
}
|
||||
|
||||
int encfs_utimens(const char *path, const struct timespec ts[2]) {
|
||||
return withCipherPath("utimens", path, _do_utimens, ts);
|
||||
return withCipherPath("utimens", path, bind(_do_utimens, _1, _2, ts));
|
||||
}
|
||||
|
||||
int encfs_open(const char *path, struct fuse_file_info *file) {
|
||||
@ -501,8 +485,7 @@ int encfs_open(const char *path, struct fuse_file_info *file) {
|
||||
res = ESUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in open");
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -510,7 +493,7 @@ int encfs_open(const char *path, struct fuse_file_info *file) {
|
||||
return res;
|
||||
}
|
||||
|
||||
int _do_flush(FileNode *fnode, int) {
|
||||
int _do_flush(FileNode *fnode) {
|
||||
/* Flush can be called multiple times for an open file, so it doesn't
|
||||
close the file. However it is important to call close() for some
|
||||
underlying filesystems (like NFS).
|
||||
@ -526,7 +509,7 @@ int _do_flush(FileNode *fnode, int) {
|
||||
}
|
||||
|
||||
int encfs_flush(const char *path, struct fuse_file_info *fi) {
|
||||
return withFileNode("flush", path, fi, _do_flush, 0);
|
||||
return withFileNode("flush", path, fi, bind(_do_flush, _1));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -538,24 +521,23 @@ int encfs_release(const char *path, struct fuse_file_info *finfo) {
|
||||
EncFS_Context *ctx = context();
|
||||
|
||||
try {
|
||||
ctx->eraseNode(path, (void *)(uintptr_t)finfo->fh);
|
||||
ctx->eraseNode(path, (void *)(uintptr_t) finfo->fh);
|
||||
return ESUCCESS;
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in release");
|
||||
err.log(_RLWarningChannel);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
int _do_read(FileNode *fnode, tuple<unsigned char *, size_t, off_t> data) {
|
||||
return fnode->read(data.get<2>(), data.get<0>(), data.get<1>());
|
||||
int _do_read(FileNode *fnode, unsigned char *ptr, size_t size, off_t off) {
|
||||
return fnode->read(off, ptr, size);
|
||||
}
|
||||
|
||||
int encfs_read(const char *path, char *buf, size_t size, off_t offset,
|
||||
struct fuse_file_info *file) {
|
||||
return withFileNode("read", path, file, _do_read,
|
||||
make_tuple((unsigned char *)buf, size, offset));
|
||||
return withFileNode("read", path, file,
|
||||
bind(_do_read, _1, (unsigned char *)buf, size, offset));
|
||||
}
|
||||
|
||||
int _do_fsync(FileNode *fnode, int dataSync) {
|
||||
@ -563,12 +545,11 @@ int _do_fsync(FileNode *fnode, int dataSync) {
|
||||
}
|
||||
|
||||
int encfs_fsync(const char *path, int dataSync, struct fuse_file_info *file) {
|
||||
return withFileNode("fsync", path, file, _do_fsync, dataSync);
|
||||
return withFileNode("fsync", path, file, bind(_do_fsync, _1, dataSync));
|
||||
}
|
||||
|
||||
int _do_write(FileNode *fnode, tuple<const char *, size_t, off_t> data) {
|
||||
size_t size = data.get<1>();
|
||||
if (fnode->write(data.get<2>(), (unsigned char *)data.get<0>(), size))
|
||||
int _do_write(FileNode *fnode, unsigned char *ptr, size_t size, off_t offset) {
|
||||
if (fnode->write(offset, ptr, size))
|
||||
return size;
|
||||
else
|
||||
return -EIO;
|
||||
@ -576,8 +557,8 @@ int _do_write(FileNode *fnode, tuple<const char *, size_t, off_t> data) {
|
||||
|
||||
int encfs_write(const char *path, const char *buf, size_t size, off_t offset,
|
||||
struct fuse_file_info *file) {
|
||||
return withFileNode("write", path, file, _do_write,
|
||||
make_tuple(buf, size, offset));
|
||||
return withFileNode("write", path, file,
|
||||
bind(_do_write, _1, (unsigned char *)buf, size, offset));
|
||||
}
|
||||
|
||||
// statfs works even if encfs is detached..
|
||||
@ -597,8 +578,7 @@ int encfs_statfs(const char *path, struct statvfs *st) {
|
||||
st->f_namemax = 6 * (st->f_namemax - 2) / 8; // approx..
|
||||
}
|
||||
if (res == -1) res = -errno;
|
||||
}
|
||||
catch (rlog::Error &err) {
|
||||
} catch (rlog::Error &err) {
|
||||
rError("error caught in statfs");
|
||||
err.log(_RLWarningChannel);
|
||||
}
|
||||
@ -608,70 +588,68 @@ int encfs_statfs(const char *path, struct statvfs *st) {
|
||||
#ifdef HAVE_XATTR
|
||||
|
||||
#ifdef XATTR_ADD_OPT
|
||||
int _do_setxattr(EncFS_Context *, const string &cyName,
|
||||
tuple<const char *, const char *, size_t, uint32_t> data) {
|
||||
int _do_setxattr(EncFS_Context *, const string &cyName, const char *name,
|
||||
const char *value, size_t size, uint32_t pos) {
|
||||
int options = 0;
|
||||
return ::setxattr(cyName.c_str(), data.get<0>(), data.get<1>(), data.get<2>(),
|
||||
data.get<3>(), options);
|
||||
return ::setxattr(cyName.c_str(), name, value, size, pos, options);
|
||||
}
|
||||
int encfs_setxattr(const char *path, const char *name, const char *value,
|
||||
size_t size, int flags, uint32_t position) {
|
||||
(void)flags;
|
||||
return withCipherPath("setxattr", path, _do_setxattr,
|
||||
make_tuple(name, value, size, position));
|
||||
return withCipherPath("setxattr", path, bind(_do_setxattr, _1, _2, name,
|
||||
value, size, position));
|
||||
}
|
||||
#else
|
||||
int _do_setxattr(EncFS_Context *, const string &cyName,
|
||||
tuple<const char *, const char *, size_t, int> data) {
|
||||
return ::setxattr(cyName.c_str(), data.get<0>(), data.get<1>(), data.get<2>(),
|
||||
data.get<3>());
|
||||
int _do_setxattr(EncFS_Context *, const string &cyName, const char *name,
|
||||
const char *value, size_t size, int flags) {
|
||||
return ::setxattr(cyName.c_str(), name, value, size, flags);
|
||||
}
|
||||
int encfs_setxattr(const char *path, const char *name, const char *value,
|
||||
size_t size, int flags) {
|
||||
return withCipherPath("setxattr", path, _do_setxattr,
|
||||
make_tuple(name, value, size, flags));
|
||||
return withCipherPath("setxattr", path,
|
||||
bind(_do_setxattr, _1, _2, name, value, size, flags));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XATTR_ADD_OPT
|
||||
int _do_getxattr(EncFS_Context *, const string &cyName,
|
||||
tuple<const char *, void *, size_t, uint32_t> data) {
|
||||
int _do_getxattr(EncFS_Context *, const string &cyName, const char *name,
|
||||
void *value, size_t size, uint32_t pos) {
|
||||
int options = 0;
|
||||
return ::getxattr(cyName.c_str(), data.get<0>(), data.get<1>(), data.get<2>(),
|
||||
data.get<3>(), options);
|
||||
return ::getxattr(cyName.c_str(), name, value, size, pos, options);
|
||||
}
|
||||
int encfs_getxattr(const char *path, const char *name, char *value, size_t size,
|
||||
uint32_t position) {
|
||||
return withCipherPath("getxattr", path, _do_getxattr,
|
||||
make_tuple(name, (void *)value, size, position), true);
|
||||
return withCipherPath(
|
||||
"getxattr", path,
|
||||
bind(_do_getxattr, _1, _2, name, (void *)value, size, position), true);
|
||||
}
|
||||
#else
|
||||
int _do_getxattr(EncFS_Context *, const string &cyName,
|
||||
tuple<const char *, void *, size_t> data) {
|
||||
return ::getxattr(cyName.c_str(), data.get<0>(), data.get<1>(),
|
||||
data.get<2>());
|
||||
int _do_getxattr(EncFS_Context *, const string &cyName, const char *name,
|
||||
void *value, size_t size) {
|
||||
return ::getxattr(cyName.c_str(), name, value, size);
|
||||
}
|
||||
int encfs_getxattr(const char *path, const char *name, char *value,
|
||||
size_t size) {
|
||||
return withCipherPath("getxattr", path, _do_getxattr,
|
||||
make_tuple(name, (void *)value, size), true);
|
||||
return withCipherPath("getxattr", path,
|
||||
bind(_do_getxattr, _1, _2, name, (void *)value, size),
|
||||
true);
|
||||
}
|
||||
#endif
|
||||
|
||||
int _do_listxattr(EncFS_Context *, const string &cyName,
|
||||
tuple<char *, size_t> data) {
|
||||
int _do_listxattr(EncFS_Context *, const string &cyName, char *list,
|
||||
size_t size) {
|
||||
#ifdef XATTR_ADD_OPT
|
||||
int options = 0;
|
||||
int res = ::listxattr(cyName.c_str(), data.get<0>(), data.get<1>(), options);
|
||||
int res = ::listxattr(cyName.c_str(), list, size, options);
|
||||
#else
|
||||
int res = ::listxattr(cyName.c_str(), data.get<0>(), data.get<1>());
|
||||
int res = ::listxattr(cyName.c_str(), list, size);
|
||||
#endif
|
||||
return (res == -1) ? -errno : res;
|
||||
}
|
||||
|
||||
int encfs_listxattr(const char *path, char *list, size_t size) {
|
||||
return withCipherPath("listxattr", path, _do_listxattr,
|
||||
make_tuple(list, size), true);
|
||||
return withCipherPath("listxattr", path,
|
||||
bind(_do_listxattr, _1, _2, list, size), true);
|
||||
}
|
||||
|
||||
int _do_removexattr(EncFS_Context *, const string &cyName, const char *name) {
|
||||
@ -685,7 +663,8 @@ int _do_removexattr(EncFS_Context *, const string &cyName, const char *name) {
|
||||
}
|
||||
|
||||
int encfs_removexattr(const char *path, const char *name) {
|
||||
return withCipherPath("removexattr", path, _do_removexattr, name);
|
||||
return withCipherPath("removexattr", path,
|
||||
bind(_do_removexattr, _1, _2, name));
|
||||
}
|
||||
|
||||
#endif // HAVE_XATTR
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <fuse.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <rlog/rlog.h>
|
||||
|
||||
#if defined(HAVE_SYS_XATTR_H) | defined(HAVE_ATTR_XATTR_H)
|
||||
#define HAVE_XATTR
|
||||
#endif
|
||||
@ -35,9 +37,10 @@
|
||||
static __inline int setfsuid(uid_t uid) {
|
||||
uid_t olduid = geteuid();
|
||||
|
||||
seteuid(uid);
|
||||
|
||||
if (errno != EINVAL) errno = 0;
|
||||
if (seteuid(uid) != 0) {
|
||||
// ignore error.
|
||||
rDebug("seteuid error: %i", errno);
|
||||
}
|
||||
|
||||
return olduid;
|
||||
}
|
||||
@ -45,9 +48,10 @@ static __inline int setfsuid(uid_t uid) {
|
||||
static __inline int setfsgid(gid_t gid) {
|
||||
gid_t oldgid = getegid();
|
||||
|
||||
setegid(gid);
|
||||
|
||||
if (errno != EINVAL) errno = 0;
|
||||
if (setegid(gid) != 0) {
|
||||
// ignore error.
|
||||
rDebug("setfsgid error: %i", errno);
|
||||
}
|
||||
|
||||
return oldgid;
|
||||
}
|
||||
|
@ -17,42 +17,35 @@
|
||||
|
||||
#include "encfs.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include "Cipher.h"
|
||||
|
||||
#include "Context.h"
|
||||
#include "FileNode.h"
|
||||
#include "DirNode.h"
|
||||
#include "shared_ptr.h"
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <rlog/rlog.h>
|
||||
#include <rlog/StdioNode.h>
|
||||
#include <rlog/RLogChannel.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
#ifdef HAVE_SSL
|
||||
#define NO_DES
|
||||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
#include "Cipher.h"
|
||||
#include "Context.h"
|
||||
#include "DirNode.h"
|
||||
#include "FileNode.h"
|
||||
#include "FileUtils.h"
|
||||
#include "autosprintf.h"
|
||||
#include "config.h"
|
||||
#include "i18n.h"
|
||||
#include "shared_ptr.h"
|
||||
|
||||
using namespace rlog;
|
||||
using namespace std;
|
||||
using boost::format;
|
||||
using boost::scoped_array;
|
||||
using gnu::autosprintf;
|
||||
|
||||
static int showInfo(int argc, char **argv);
|
||||
static int showVersion(int argc, char **argv);
|
||||
@ -112,13 +105,14 @@ struct CommandOpts {
|
||||
{0, 0, 0, 0, 0, 0}};
|
||||
|
||||
static void usage(const char *name) {
|
||||
cerr << format(_("encfsctl version %s")) % VERSION << "\n" << _("Usage:\n")
|
||||
cerr << autosprintf(_("encfsctl version %s"), VERSION) << "\n"
|
||||
<< _("Usage:\n")
|
||||
// displays usage commands, eg "./encfs (root dir) ..."
|
||||
// xgroup(usage)
|
||||
<< format(
|
||||
<< autosprintf(
|
||||
_("%s (root dir)\n"
|
||||
" -- displays information about the filesystem, or \n")) %
|
||||
name;
|
||||
" -- displays information about the filesystem, or \n"),
|
||||
name);
|
||||
|
||||
int offset = 0;
|
||||
while (commands[offset].name != 0) {
|
||||
@ -132,12 +126,12 @@ static void usage(const char *name) {
|
||||
|
||||
cerr << "\n"
|
||||
// xgroup(usage)
|
||||
<< format(_("Example: \n%s info ~/.crypt\n")) % name << "\n";
|
||||
<< autosprintf(_("Example: \n%s info ~/.crypt\n"), name) << "\n";
|
||||
}
|
||||
|
||||
static bool checkDir(string &rootDir) {
|
||||
if (!isDirectory(rootDir.c_str())) {
|
||||
cerr << format(_("directory %s does not exist.\n")) % rootDir.c_str();
|
||||
cerr << autosprintf(_("directory %s does not exist.\n"), rootDir.c_str());
|
||||
return false;
|
||||
}
|
||||
if (rootDir[rootDir.length() - 1] != '/') rootDir.append("/");
|
||||
@ -149,7 +143,7 @@ static int showVersion(int argc, char **argv) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
// xgroup(usage)
|
||||
cerr << format(_("encfsctl version %s")) % VERSION << "\n";
|
||||
cerr << autosprintf(_("encfsctl version %s"), VERSION) << "\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -170,36 +164,33 @@ static int showInfo(int argc, char **argv) {
|
||||
return EXIT_FAILURE;
|
||||
case Config_Prehistoric:
|
||||
// xgroup(diag)
|
||||
cout << _("A really old EncFS filesystem was found. \n"
|
||||
cout << _(
|
||||
"A really old EncFS filesystem was found. \n"
|
||||
"It is not supported in this EncFS build.\n");
|
||||
return EXIT_FAILURE;
|
||||
case Config_V3:
|
||||
// xgroup(diag)
|
||||
cout << "\n" << format(
|
||||
_("Version 3 configuration; "
|
||||
"created by %s\n")) %
|
||||
config->creator.c_str();
|
||||
cout << "\n" << autosprintf(_("Version 3 configuration; "
|
||||
"created by %s\n"),
|
||||
config->creator.c_str());
|
||||
break;
|
||||
case Config_V4:
|
||||
// xgroup(diag)
|
||||
cout << "\n" << format(
|
||||
_("Version 4 configuration; "
|
||||
"created by %s\n")) %
|
||||
config->creator.c_str();
|
||||
cout << "\n" << autosprintf(_("Version 4 configuration; "
|
||||
"created by %s\n"),
|
||||
config->creator.c_str());
|
||||
break;
|
||||
case Config_V5:
|
||||
// xgroup(diag)
|
||||
cout << "\n" << format(
|
||||
_("Version 5 configuration; "
|
||||
"created by %s (revision %i)\n")) %
|
||||
config->creator % config->subVersion;
|
||||
cout << "\n" << autosprintf(_("Version 5 configuration; "
|
||||
"created by %s (revision %i)\n"),
|
||||
config->creator.c_str(), config->subVersion);
|
||||
break;
|
||||
case Config_V6:
|
||||
// xgroup(diag)
|
||||
cout << "\n" << format(
|
||||
_("Version 6 configuration; "
|
||||
"created by %s (revision %i)\n")) %
|
||||
config->creator % config->subVersion;
|
||||
cout << "\n" << autosprintf(_("Version 6 configuration; "
|
||||
"created by %s (revision %i)\n"),
|
||||
config->creator.c_str(), config->subVersion);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -419,15 +410,15 @@ static int cmd_cat(int argc, char **argv) {
|
||||
static int copyLink(const struct stat &stBuf,
|
||||
const shared_ptr<EncFS_Root> &rootInfo, const string &cpath,
|
||||
const string &destName) {
|
||||
scoped_array<char> buf(new char[stBuf.st_size + 1]);
|
||||
int res = ::readlink(cpath.c_str(), buf.get(), stBuf.st_size);
|
||||
std::vector<char> buf(stBuf.st_size + 1, '\0');
|
||||
int res = ::readlink(cpath.c_str(), buf.data(), stBuf.st_size);
|
||||
if (res == -1) {
|
||||
cerr << "unable to readlink of " << cpath << "\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
buf[res] = '\0';
|
||||
string decodedLink = rootInfo->root->plainPath(buf.get());
|
||||
string decodedLink = rootInfo->root->plainPath(buf.data());
|
||||
|
||||
res = ::symlink(decodedLink.c_str(), destName.c_str());
|
||||
if (res == -1) {
|
||||
@ -458,7 +449,11 @@ static int copyContents(const shared_ptr<EncFS_Root> &rootInfo,
|
||||
cerr << "unable to read link " << encfsName << "\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
symlink(rootInfo->root->plainPath(linkContents).c_str(), targetName);
|
||||
if (symlink(rootInfo->root->plainPath(linkContents).c_str(),
|
||||
targetName) != 0) {
|
||||
cerr << "unable to create symlink " << targetName << "\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
int outfd = creat(targetName, st.st_mode);
|
||||
|
||||
@ -552,7 +547,7 @@ int showcruft(const shared_ptr<EncFS_Root> &rootInfo, const char *dirName) {
|
||||
|
||||
if (!showedDir) {
|
||||
// just before showing a list of files in a directory
|
||||
cout << format(_("In directory %s: \n")) % dirName;
|
||||
cout << autosprintf(_("In directory %s: \n"), dirName);
|
||||
showedDir = true;
|
||||
}
|
||||
++found;
|
||||
@ -594,9 +589,9 @@ static int cmd_showcruft(int argc, char **argv) {
|
||||
|
||||
int filesFound = showcruft(rootInfo, "/");
|
||||
|
||||
cerr << format(ngettext("Found %i invalid file.", "Found %i invalid files.",
|
||||
filesFound)) %
|
||||
filesFound << "\n";
|
||||
cerr << autosprintf(ngettext("Found %i invalid file.",
|
||||
"Found %i invalid files.", filesFound),
|
||||
filesFound) << "\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -617,8 +612,8 @@ static int do_chpasswd(bool useStdin, bool annotate, int argc, char **argv) {
|
||||
// instanciate proper cipher
|
||||
shared_ptr<Cipher> cipher = Cipher::New(config->cipherIface, config->keySize);
|
||||
if (!cipher) {
|
||||
cout << format(_("Unable to find specified cipher \"%s\"\n")) %
|
||||
config->cipherIface.name();
|
||||
cout << autosprintf(_("Unable to find specified cipher \"%s\"\n"),
|
||||
config->cipherIface.name().c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@ -725,12 +720,13 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (commands[offset].name == 0) {
|
||||
cerr << format(_("invalid command: \"%s\"")) % argv[1] << "\n";
|
||||
cerr << autosprintf(_("invalid command: \"%s\""), argv[1]) << "\n";
|
||||
} else {
|
||||
if ((argc - 2 < commands[offset].minOptions) ||
|
||||
(argc - 2 > commands[offset].maxOptions)) {
|
||||
cerr << format(_("Incorrect number of arguments for command \"%s\"")) %
|
||||
argv[1] << "\n";
|
||||
cerr << autosprintf(
|
||||
_("Incorrect number of arguments for command \"%s\""),
|
||||
argv[1]) << "\n";
|
||||
} else
|
||||
return (*commands[offset].func)(argc - 1, argv + 1);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
@ -29,15 +30,13 @@
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#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 "DirNode.h"
|
||||
@ -58,15 +57,10 @@
|
||||
extern "C" void fuse_unmount_compat22(const char *mountpoint);
|
||||
#define fuse_unmount fuse_unmount_compat22
|
||||
|
||||
#ifndef MAX
|
||||
inline static int MAX(int a, int b) { return (a > b) ? a : b; }
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace rlog;
|
||||
using namespace rel;
|
||||
using boost::format;
|
||||
using boost::scoped_ptr;
|
||||
using gnu::autosprintf;
|
||||
|
||||
// Maximum number of arguments that we're going to pass on to fuse. Doesn't
|
||||
// affect how many arguments we can handle, just how many we can pass on..
|
||||
@ -111,12 +105,12 @@ static int oldStderr = STDERR_FILENO;
|
||||
|
||||
static void usage(const char *name) {
|
||||
// xgroup(usage)
|
||||
cerr << format(_("Build: encfs version %s")) % VERSION << "\n\n"
|
||||
cerr << autosprintf(_("Build: encfs version %s"), VERSION) << "\n\n"
|
||||
// xgroup(usage)
|
||||
<< format(
|
||||
<< autosprintf(
|
||||
_("Usage: %s [options] rootDir mountPoint [-- [FUSE Mount "
|
||||
"Options]]")) %
|
||||
name << "\n\n"
|
||||
"Options]]"),
|
||||
name) << "\n\n"
|
||||
// xgroup(usage)
|
||||
<< _("Common Options:\n"
|
||||
" -H\t\t\t"
|
||||
@ -310,7 +304,7 @@ static bool processArgs(int argc, char *argv[],
|
||||
break;
|
||||
case 'V':
|
||||
// xgroup(usage)
|
||||
cerr << format(_("encfs version %s")) % VERSION << endl;
|
||||
cerr << autosprintf(_("encfs version %s"), VERSION) << endl;
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'H':
|
||||
@ -477,8 +471,8 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
// log to stderr by default..
|
||||
scoped_ptr<StdioNode> slog(new StdioNode(STDERR_FILENO));
|
||||
scoped_ptr<SyslogNode> logNode;
|
||||
std::unique_ptr<StdioNode> slog(new StdioNode(STDERR_FILENO));
|
||||
std::unique_ptr<SyslogNode> logNode;
|
||||
|
||||
// show error and warning output
|
||||
slog->subscribeTo(GetGlobalChannel("error"));
|
||||
@ -637,17 +631,15 @@ int main(int argc, char *argv[]) {
|
||||
// few words in libfuse's memory..
|
||||
FILE *out = fdopen(oldStderr, "a");
|
||||
// xgroup(usage)
|
||||
fprintf(out, _("fuse failed. Common problems:\n"
|
||||
fputs(_("fuse failed. Common problems:\n"
|
||||
" - fuse kernel module not installed (modprobe fuse)\n"
|
||||
" - invalid options -- see usage message\n"));
|
||||
" - invalid options -- see usage message\n"), out);
|
||||
fclose(out);
|
||||
}
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
} catch (std::exception &ex) {
|
||||
rError(_("Internal error: Caught exception from main loop: %s"),
|
||||
ex.what());
|
||||
}
|
||||
catch (...) {
|
||||
} catch (...) {
|
||||
rError(_("Internal error: Caught unexpected exception"));
|
||||
}
|
||||
}
|
||||
|
@ -22,16 +22,8 @@
|
||||
#ifndef _SHARED_PTR_incl_
|
||||
#define _SHARED_PTR_incl_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STD_SHARED_PTR
|
||||
#include <memory>
|
||||
using std::shared_ptr;
|
||||
using std::dynamic_pointer_cast;
|
||||
#else
|
||||
#include <boost/shared_ptr.hpp>
|
||||
using boost::shared_ptr;
|
||||
using boost::dynamic_pointer_cast;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,118 +0,0 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_boost_filesystem.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_BOOST_FILESYSTEM
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Test for Filesystem library from the Boost C++ libraries. The macro
|
||||
# requires a preceding call to AX_BOOST_BASE. Further documentation is
|
||||
# available at <http://randspringer.de/boost/index.html>.
|
||||
#
|
||||
# This macro calls:
|
||||
#
|
||||
# AC_SUBST(BOOST_FILESYSTEM_LIB)
|
||||
#
|
||||
# And sets:
|
||||
#
|
||||
# HAVE_BOOST_FILESYSTEM
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
|
||||
# Copyright (c) 2009 Michael Tindal
|
||||
# Copyright (c) 2009 Roman Rybalko <libtorrent@romanr.info>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 26
|
||||
|
||||
AC_DEFUN([AX_BOOST_FILESYSTEM],
|
||||
[
|
||||
AC_ARG_WITH([boost-filesystem],
|
||||
AS_HELP_STRING([--with-boost-filesystem@<:@=special-lib@:>@],
|
||||
[use the Filesystem library from boost - it is possible to specify a certain library for the linker
|
||||
e.g. --with-boost-filesystem=boost_filesystem-gcc-mt ]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ax_boost_user_filesystem_lib=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ax_boost_user_filesystem_lib="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"]
|
||||
)
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
LIBS_SAVED=$LIBS
|
||||
LIBS="$LIBS $BOOST_SYSTEM_LIB"
|
||||
export LIBS
|
||||
|
||||
AC_CACHE_CHECK(whether the Boost::Filesystem library is available,
|
||||
ax_cv_boost_filesystem,
|
||||
[AC_LANG_PUSH([C++])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/filesystem/path.hpp>]],
|
||||
[[using namespace boost::filesystem;
|
||||
path my_path( "foo/bar/data.txt" );
|
||||
return 0;]])],
|
||||
ax_cv_boost_filesystem=yes, ax_cv_boost_filesystem=no)
|
||||
AC_LANG_POP([C++])
|
||||
])
|
||||
if test "x$ax_cv_boost_filesystem" = "xyes"; then
|
||||
AC_DEFINE(HAVE_BOOST_FILESYSTEM,,[define if the Boost::Filesystem library is available])
|
||||
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
|
||||
if test "x$ax_boost_user_filesystem_lib" = "x"; then
|
||||
for libextension in `ls -r $BOOSTLIBDIR/libboost_filesystem* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
|
||||
ax_lib=${libextension}
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
|
||||
[link_filesystem="no"])
|
||||
done
|
||||
if test "x$link_filesystem" != "xyes"; then
|
||||
for libextension in `ls -r $BOOSTLIBDIR/boost_filesystem* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
|
||||
ax_lib=${libextension}
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
|
||||
[link_filesystem="no"])
|
||||
done
|
||||
fi
|
||||
else
|
||||
for ax_lib in $ax_boost_user_filesystem_lib boost_filesystem-$ax_boost_user_filesystem_lib; do
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
|
||||
[link_filesystem="no"])
|
||||
done
|
||||
|
||||
fi
|
||||
if test "x$ax_lib" = "x"; then
|
||||
AC_MSG_ERROR(Could not find a version of the library!)
|
||||
fi
|
||||
if test "x$link_filesystem" != "xyes"; then
|
||||
AC_MSG_ERROR(Could not link against $ax_lib !)
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
LIBS="$LIBS_SAVED"
|
||||
fi
|
||||
])
|
@ -1,120 +0,0 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_boost_system.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_BOOST_SYSTEM
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Test for System library from the Boost C++ libraries. The macro requires
|
||||
# a preceding call to AX_BOOST_BASE. Further documentation is available at
|
||||
# <http://randspringer.de/boost/index.html>.
|
||||
#
|
||||
# This macro calls:
|
||||
#
|
||||
# AC_SUBST(BOOST_SYSTEM_LIB)
|
||||
#
|
||||
# And sets:
|
||||
#
|
||||
# HAVE_BOOST_SYSTEM
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
|
||||
# Copyright (c) 2008 Michael Tindal
|
||||
# Copyright (c) 2008 Daniel Casimiro <dan.casimiro@gmail.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 17
|
||||
|
||||
AC_DEFUN([AX_BOOST_SYSTEM],
|
||||
[
|
||||
AC_ARG_WITH([boost-system],
|
||||
AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@],
|
||||
[use the System library from boost - it is possible to specify a certain library for the linker
|
||||
e.g. --with-boost-system=boost_system-gcc-mt ]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ax_boost_user_system_lib=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ax_boost_user_system_lib="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"]
|
||||
)
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AC_CANONICAL_BUILD])
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_CACHE_CHECK(whether the Boost::System library is available,
|
||||
ax_cv_boost_system,
|
||||
[AC_LANG_PUSH([C++])
|
||||
CXXFLAGS_SAVE=$CXXFLAGS
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/system/error_code.hpp>]],
|
||||
[[boost::system::system_category]])],
|
||||
ax_cv_boost_system=yes, ax_cv_boost_system=no)
|
||||
CXXFLAGS=$CXXFLAGS_SAVE
|
||||
AC_LANG_POP([C++])
|
||||
])
|
||||
if test "x$ax_cv_boost_system" = "xyes"; then
|
||||
AC_SUBST(BOOST_CPPFLAGS)
|
||||
|
||||
AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available])
|
||||
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
|
||||
|
||||
LDFLAGS_SAVE=$LDFLAGS
|
||||
if test "x$ax_boost_user_system_lib" = "x"; then
|
||||
for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
|
||||
ax_lib=${libextension}
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
|
||||
[link_system="no"])
|
||||
done
|
||||
if test "x$link_system" != "xyes"; then
|
||||
for libextension in `ls -r $BOOSTLIBDIR/boost_system* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
|
||||
ax_lib=${libextension}
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
|
||||
[link_system="no"])
|
||||
done
|
||||
fi
|
||||
|
||||
else
|
||||
for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
|
||||
[link_system="no"])
|
||||
done
|
||||
|
||||
fi
|
||||
if test "x$ax_lib" = "x"; then
|
||||
AC_MSG_ERROR(Could not find a version of the library!)
|
||||
fi
|
||||
if test "x$link_system" = "xno"; then
|
||||
AC_MSG_ERROR(Could not link against $ax_lib !)
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
])
|
@ -40,10 +40,10 @@ sub cleanup
|
||||
# Directory structure: plain -[encrypt]-> ciphertext -[decrypt]-> decrypted
|
||||
sub mount
|
||||
{
|
||||
my $r=system("encfs --extpass=\"echo test\" --standard $plain $ciphertext --reverse > /dev/null");
|
||||
my $r=system("./encfs/encfs --extpass=\"echo test\" --standard $plain $ciphertext --reverse > /dev/null");
|
||||
ok($r == 0, "mounted ciphertext file system");
|
||||
|
||||
$r=system("ENCFS6_CONFIG=$plain/.encfs6.xml encfs --extpass=\"echo test\" $ciphertext $decrypted");
|
||||
$r=system("ENCFS6_CONFIG=$plain/.encfs6.xml ./encfs/encfs --extpass=\"echo test\" $ciphertext $decrypted");
|
||||
ok($r == 0, "mounted decrypting file system");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user