reduce boost dependencies

enables c++11 mode on GCC
also fix soft links to root paths in reverse mode
This commit is contained in:
Valient Gough 2014-10-25 00:26:12 -07:00
parent 73ea32c2c2
commit 19aba9fa77
16 changed files with 425 additions and 590 deletions

View File

@ -19,7 +19,7 @@ unset CDPATH
AC_LANG_CPLUSPLUS AC_LANG_CPLUSPLUS
AC_PROG_CXX AC_PROG_CXX
dnl almost the same like KDE_SET_PEFIX but the path is /usr/local dnl almost the same like KDE_SET_PEFIX but the path is /usr/local
dnl dnl
unset CDPATH unset CDPATH
@ -46,23 +46,7 @@ AC_PROG_LIBTOOL
AX_PTHREAD AX_PTHREAD
AX_BOOST_BASE([1.34]) AX_BOOST_BASE([1.34])
AX_BOOST_SYSTEM
AX_BOOST_SERIALIZATION 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 Need to include any user specified flags in the tests below, as they might
dnl specify required include directories.. 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 if test "$GXX" = "yes"; then
CXXFLAGS="-W -Wall -Wpointer-arith -Wwrite-strings $CXXFLAGS" CXXFLAGS="-W -Wall -Wpointer-arith -Wwrite-strings $CXXFLAGS"
CXXFLAGS="-std=c++11 $CXXFLAGS"
dnl CXXFLAGS="$CXXFLAGS -Wformat=2 -Wconversion" dnl CXXFLAGS="$CXXFLAGS -Wformat=2 -Wconversion"
elif test -z "${DARWIN_TRUE}"; then
CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS"
fi fi
if test -z "${DARWIN_TRUE}"; then if test -z "${DARWIN_TRUE}"; then
@ -99,7 +86,7 @@ fi
# check for a supported FUSE_MAJOR_VERSION. # check for a supported FUSE_MAJOR_VERSION.
AC_MSG_CHECKING([For supported FUSE API version]) AC_MSG_CHECKING([For supported FUSE API version])
AC_RUN_IFELSE([ AC_RUN_IFELSE([
AC_LANG_PROGRAM([[#include "fuse.h"]], AC_LANG_PROGRAM([[#include "fuse.h"]],
[[ [[
if(FUSE_MAJOR_VERSION == 2 && FUSE_MINOR_VERSION >= 5) if(FUSE_MAJOR_VERSION == 2 && FUSE_MINOR_VERSION >= 5)
@ -107,7 +94,7 @@ AC_RUN_IFELSE([
return 0; return 0;
} else } else
return -1; return -1;
]])], ]])],
[AC_MSG_RESULT([yes])], [AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no]) [AC_MSG_RESULT([no])
AC_MSG_FAILURE([ AC_MSG_FAILURE([
@ -122,7 +109,7 @@ dnl only enable it if setxattr function is found..
AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h]) AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h])
dnl xattr functions take additional arguments on some systems (eg Darwin). dnl xattr functions take additional arguments on some systems (eg Darwin).
AC_CACHE_CHECK([whether xattr interface takes additional options], AC_CACHE_CHECK([whether xattr interface takes additional options],
smb_attr_cv_xattr_add_opt, [ smb_attr_cv_xattr_add_opt, [
old_LIBS=$LIBS old_LIBS=$LIBS
LIBS="$LIBS $ACL_LIBS" LIBS="$LIBS $ACL_LIBS"
@ -156,7 +143,7 @@ AC_ARG_ENABLE(openssl,
[disables openssl library usage.]), [disables openssl library usage.]),
with_openssl=$enableval, with_openssl="yes" ) with_openssl=$enableval, with_openssl="yes" )
# try checking for openssl using # try checking for openssl using
if test "x$with_openssl" = "xyes"; then if test "x$with_openssl" = "xyes"; then
# look for openssl using pkg-config first.. # look for openssl using pkg-config first..
PKG_CHECK_MODULES(OPENSSL, openssl >= 0.9.7, PKG_CHECK_MODULES(OPENSSL, openssl >= 0.9.7,
@ -189,7 +176,7 @@ if test "x$with_openssl" = "xyes"; then
AC_MSG_WARN([New SSL cipher code only enabled for OpenSSL 0.9.7 or later])) AC_MSG_WARN([New SSL cipher code only enabled for OpenSSL 0.9.7 or later]))
AC_CHECK_FUNCS(HMAC_Init_ex, AC_CHECK_FUNCS(HMAC_Init_ex,
AC_DEFINE(HAVE_HMAC_INIT_EX, [1], [Have HMAC_Init_ex function])) AC_DEFINE(HAVE_HMAC_INIT_EX, [1], [Have HMAC_Init_ex function]))
CXXFLAGS="$oldflags" CXXFLAGS="$oldflags"
LIBS="$oldlibs" LIBS="$oldlibs"

View File

@ -18,14 +18,14 @@
* 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 "FileNode.h"
#include "Context.h"
#include "Mutex.h"
#include "FileUtils.h"
#include "DirNode.h"
#include <rlog/rlog.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 rel;
using namespace rlog; using namespace rlog;
@ -74,7 +74,7 @@ void EncFS_Context::setRoot(const shared_ptr<DirNode> &r) {
if (r) rootCipherDir = r->rootDirectory(); if (r) rootCipherDir = r->rootDirectory();
} }
bool EncFS_Context::isMounted() { return root; } bool EncFS_Context::isMounted() { return root.get() != nullptr; }
int EncFS_Context::getAndResetUsageCounter() { int EncFS_Context::getAndResetUsageCounter() {
Lock lock(contextMutex); Lock lock(contextMutex);

View File

@ -28,6 +28,7 @@
#else #else
#include <map> #include <map>
#endif #endif
#include <string>
#include "encfs.h" #include "encfs.h"
#include "shared_ptr.h" #include "shared_ptr.h"

View File

@ -103,8 +103,7 @@ std::string DirTraverse::nextPlaintextName(int *fileType, ino_t *inode) {
try { try {
uint64_t localIv = iv; uint64_t localIv = iv;
return naming->decodePath(de->d_name, &localIv); 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.. // .. .problem decoding, ignore it and continue on to next name..
rDebug("error decoding filename: %s", de->d_name); rDebug("error decoding filename: %s", de->d_name);
} }
@ -121,8 +120,7 @@ std::string DirTraverse::nextInvalid() {
uint64_t localIv = iv; uint64_t localIv = iv;
naming->decodePath(de->d_name, &localIv); naming->decodePath(de->d_name, &localIv);
continue; continue;
} } catch (rlog::Error &ex) {
catch (rlog::Error &ex) {
return string(de->d_name); return string(de->d_name);
} }
} }
@ -159,7 +157,7 @@ class RenameOp {
~RenameOp(); ~RenameOp();
operator bool() const { return renameList; } operator bool() const { return renameList.get() != nullptr; }
bool apply(); bool apply();
void undo(); void undo();
@ -209,8 +207,7 @@ bool RenameOp::apply() {
} }
return true; return true;
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
return false; return false;
} }
@ -238,8 +235,7 @@ void RenameOp::undo() {
::rename(it->newCName.c_str(), it->oldCName.c_str()); ::rename(it->newCName.c_str(), it->oldCName.c_str());
try { try {
dn->renameNode(it->newPName.c_str(), it->oldPName.c_str(), false); dn->renameNode(it->newPName.c_str(), it->oldPName.c_str(), false);
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
// continue on anyway... // continue on anyway...
} }
@ -291,17 +287,18 @@ string DirNode::plainPath(const char *cipherPath_) {
try { try {
if (!strncmp(cipherPath_, rootDir.c_str(), rootDir.length())) { if (!strncmp(cipherPath_, rootDir.c_str(), rootDir.length())) {
return naming->decodePath(cipherPath_ + rootDir.length()); return naming->decodePath(cipherPath_ + rootDir.length());
} else {
if (cipherPath_[0] == '+') {
// decode as fully qualified path
return string("/") +
naming->decodeName(cipherPath_ + 1, strlen(cipherPath_ + 1));
} else {
return naming->decodePath(cipherPath_);
}
} }
}
catch (rlog::Error &err) { // Handle special absolute path encodings.
char mark = fsConfig->reverseEncryption ? '/' : '+';
if (cipherPath_[0] == mark) {
return string(fsConfig->reverseEncryption ? "+" : "/") +
naming->decodeName(cipherPath_ + 1, strlen(cipherPath_ + 1));
}
// Default.
return naming->decodePath(cipherPath_);
} catch (rlog::Error &err) {
rError("decode err: %s", err.message()); rError("decode err: %s", err.message());
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
@ -311,15 +308,15 @@ string DirNode::plainPath(const char *cipherPath_) {
string DirNode::relativeCipherPath(const char *plaintextPath) { string DirNode::relativeCipherPath(const char *plaintextPath) {
try { try {
if (plaintextPath[0] == '/') { // use '+' prefix to indicate special decoding.
// mark with '+' to indicate special decoding.. char mark = fsConfig->reverseEncryption ? '+' : '/';
return string("+") + if (plaintextPath[0] == mark) {
return string(fsConfig->reverseEncryption ? "/" : "+") +
naming->encodeName(plaintextPath + 1, strlen(plaintextPath + 1)); naming->encodeName(plaintextPath + 1, strlen(plaintextPath + 1));
} else {
return naming->encodePath(plaintextPath);
} }
}
catch (rlog::Error &err) { return naming->encodePath(plaintextPath);
} catch (rlog::Error &err) {
rError("encode err: %s", err.message()); rError("encode err: %s", err.message());
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
@ -343,8 +340,7 @@ DirTraverse DirNode::openDir(const char *plaintextPath) {
// directory level.. // directory level..
try { try {
if (naming->getChainedNameIV()) naming->encodePath(plaintextPath, &iv); if (naming->getChainedNameIV()) naming->encodePath(plaintextPath, &iv);
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("encode err: %s", err.message()); rError("encode err: %s", err.message());
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -387,8 +383,7 @@ bool DirNode::genRenameList(list<RenameEl> &renameList, const char *fromP,
try { try {
plainName = naming->decodePath(de->d_name, &localIV); plainName = naming->decodePath(de->d_name, &localIV);
} } catch (rlog::Error &ex) {
catch (rlog::Error &ex) {
// if filename can't be decoded, then ignore it.. // if filename can't be decoded, then ignore it..
continue; continue;
} }
@ -433,8 +428,7 @@ bool DirNode::genRenameList(list<RenameEl> &renameList, const char *fromP,
rDebug("adding file %s to rename list", oldFull.c_str()); rDebug("adding file %s to rename list", oldFull.c_str());
renameList.push_back(ren); 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 // 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.. // it (or perhaps a valid key).. It will be inaccessible..
rWarning("Aborting rename: error on file: %s", 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; ut.modtime = st.st_mtime;
::utime(toCName.c_str(), &ut); ::utime(toCName.c_str(), &ut);
} }
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
// exception from renameNode, just show the error and continue.. // exception from renameNode, just show the error and continue..
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
res = -EIO; res = -EIO;

View File

@ -24,22 +24,6 @@
#endif #endif
#define _BSD_SOURCE // pick up setenv on RH7.3 #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/rlog.h>
#include <rlog/Error.h> #include <rlog/Error.h>
@ -56,18 +40,33 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <fstream>
#include <sstream> #include <sstream>
#include "i18n.h"
#include <boost/version.hpp> #include <boost/version.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/format.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/split_free.hpp>
#include <boost/serialization/binary_object.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 // disable rlog section grouping for this file.. seems to cause problems
#undef RLOG_SECTION #undef RLOG_SECTION
#define RLOG_SECTION #define RLOG_SECTION
@ -75,9 +74,8 @@
using namespace rel; using namespace rel;
using namespace rlog; using namespace rlog;
using namespace std; using namespace std;
namespace fs = boost::filesystem; using gnu::autosprintf;
namespace serial = boost::serialization; namespace serial = boost::serialization;
using boost::format;
static const int DefaultBlockSize = 1024; static const int DefaultBlockSize = 1024;
// The maximum length of text passwords. If longer are needed, // 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 // TODO: can we internationalize the y/n names? Seems strange to prompt in
// their own language but then have to respond 'y' or 'n'. // their own language but then have to respond 'y' or 'n'.
// xgroup(setup) // xgroup(setup)
cerr << format( cerr << autosprintf(
_("The directory \"%s\" does not exist. Should it be created? " _("The directory \"%s\" does not exist. Should it be created? "
"(y,n) ")) % "(y,n) "), path);
path;
char answer[10]; char answer[10];
char *res; char *res;
@ -370,7 +367,7 @@ bool readV6Config(const char *configFile, const shared_ptr<EncFSConfig> &config,
ConfigInfo *info) { ConfigInfo *info) {
(void)info; (void)info;
fs::ifstream st(configFile); ifstream st(configFile);
if (st.is_open()) { if (st.is_open()) {
try { try {
boost::archive::xml_iarchive ia(st); boost::archive::xml_iarchive ia(st);
@ -508,7 +505,7 @@ bool saveConfig(ConfigType type, const string &rootDir,
bool writeV6Config(const char *configFile, bool writeV6Config(const char *configFile,
const shared_ptr<EncFSConfig> &config) { const shared_ptr<EncFSConfig> &config) {
fs::ofstream st(configFile); ofstream st(configFile);
if (!st.is_open()) return false; if (!st.is_open()) return false;
st << *config; st << *config;
@ -593,28 +590,27 @@ static Cipher::CipherAlgorithm selectCipherAlgorithm() {
if (it->keyLength.min() == it->keyLength.max()) { if (it->keyLength.min() == it->keyLength.max()) {
// shown after algorithm name and description. // shown after algorithm name and description.
// xgroup(setup) // xgroup(setup)
cout << format(_(" -- key length %i bits")) % it->keyLength.min() cout << autosprintf(_(" -- key length %i bits"), it->keyLength.min())
<< "\n"; << "\n";
} else { } else {
cout << format( cout << autosprintf(
// shown after algorithm name and description. // shown after algorithm name and description.
// xgroup(setup) // xgroup(setup)
_(" -- Supports key lengths of %i to %i bits")) % _(" -- Supports key lengths of %i to %i bits"),
it->keyLength.min() % it->keyLength.max() << "\n"; it->keyLength.min(), it->keyLength.max()) << "\n";
} }
if (it->blockSize.min() == it->blockSize.max()) { if (it->blockSize.min() == it->blockSize.max()) {
cout << format( cout << autosprintf(
// shown after algorithm name and description. // shown after algorithm name and description.
// xgroup(setup) // xgroup(setup)
_(" -- block size %i bytes")) % _(" -- block size %i bytes"), it->blockSize.min()) << "\n";
it->blockSize.min() << "\n";
} else { } else {
cout << format( cout << autosprintf(
// shown after algorithm name and description. // shown after algorithm name and description.
// xgroup(setup) // xgroup(setup)
_(" -- Supports block sizes of %i to %i bytes")) % _(" -- Supports block sizes of %i to %i bytes"),
it->blockSize.min() % it->blockSize.max() << "\n"; it->blockSize.min(), it->blockSize.max()) << "\n";
} }
} }
@ -637,7 +633,7 @@ static Cipher::CipherAlgorithm selectCipherAlgorithm() {
Cipher::CipherAlgorithm alg = *it; Cipher::CipherAlgorithm alg = *it;
// xgroup(setup) // xgroup(setup)
cout << format(_("Selected algorithm \"%s\"")) % alg.name << "\n\n"; cout << autosprintf(_("Selected algorithm \"%s\""), alg.name.c_str()) << "\n\n";
return alg; return alg;
} }
@ -674,7 +670,7 @@ static Interface selectNameCoding() {
++it; ++it;
// xgroup(setup) // 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; return it->iface;
} }
@ -682,18 +678,18 @@ static Interface selectNameCoding() {
static int selectKeySize(const Cipher::CipherAlgorithm &alg) { static int selectKeySize(const Cipher::CipherAlgorithm &alg) {
if (alg.keyLength.min() == alg.keyLength.max()) { 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"; << "\n";
return alg.keyLength.min(); return alg.keyLength.min();
} }
cout cout
<< format( << autosprintf(
// xgroup(setup) // xgroup(setup)
_("Please select a key size in bits. The cipher you have chosen\n" _("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" "supports sizes from %i to %i bits in increments of %i bits.\n"
"For example: ")) % "For example: "),
alg.keyLength.min() % alg.keyLength.max() % alg.keyLength.inc() alg.keyLength.min(), alg.keyLength.max(), alg.keyLength.inc())
<< "\n"; << "\n";
int numAvail = int numAvail =
@ -725,27 +721,27 @@ static int selectKeySize(const Cipher::CipherAlgorithm &alg) {
keySize = alg.keyLength.closest(keySize); keySize = alg.keyLength.closest(keySize);
// xgroup(setup) // 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; return keySize;
} }
static int selectBlockSize(const Cipher::CipherAlgorithm &alg) { static int selectBlockSize(const Cipher::CipherAlgorithm &alg) {
if (alg.blockSize.min() == alg.blockSize.max()) { if (alg.blockSize.min() == alg.blockSize.max()) {
cout << format( cout << autosprintf(
// xgroup(setup) // xgroup(setup)
_("Using filesystem block size of %i bytes")) % _("Using filesystem block size of %i bytes"),
alg.blockSize.min() << "\n"; alg.blockSize.min()) << "\n";
return alg.blockSize.min(); return alg.blockSize.min();
} }
cout << format( cout << autosprintf(
// xgroup(setup) // xgroup(setup)
_("Select a block size in bytes. The cipher you have chosen\n" _("Select a block size in bytes. The cipher you have chosen\n"
"supports sizes from %i to %i bytes in increments of %i.\n" "supports sizes from %i to %i bytes in increments of %i.\n"
"Or just hit enter for the default (%i bytes)\n")) % "Or just hit enter for the default (%i bytes)\n"),
alg.blockSize.min() % alg.blockSize.max() % alg.blockSize.inc() % alg.blockSize.min(), alg.blockSize.max(), alg.blockSize.inc(),
DefaultBlockSize; DefaultBlockSize);
// xgroup(setup) // xgroup(setup)
cout << "\n" << _("filesystem block size: "); cout << "\n" << _("filesystem block size: ");
@ -760,7 +756,7 @@ static int selectBlockSize(const Cipher::CipherAlgorithm &alg) {
blockSize = alg.blockSize.closest(blockSize); blockSize = alg.blockSize.closest(blockSize);
// xgroup(setup) // xgroup(setup)
cout << format(_("Using filesystem block size of %i bytes")) % blockSize cout << autosprintf(_("Using filesystem block size of %i bytes"), blockSize)
<< "\n\n"; << "\n\n";
return blockSize; return blockSize;
@ -1117,12 +1113,12 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
void showFSInfo(const shared_ptr<EncFSConfig> &config) { void showFSInfo(const shared_ptr<EncFSConfig> &config) {
shared_ptr<Cipher> cipher = Cipher::New(config->cipherIface, -1); shared_ptr<Cipher> cipher = Cipher::New(config->cipherIface, -1);
{ {
cout << format( 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.revision() % config->cipherIface.current(), 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");
@ -1131,17 +1127,17 @@ void showFSInfo(const shared_ptr<EncFSConfig> &config) {
if (config->cipherIface != cipher->interface()) { if (config->cipherIface != cipher->interface()) {
Interface iface = cipher->interface(); Interface iface = cipher->interface();
// xgroup(diag) // xgroup(diag)
cout << format(_(" (using %i:%i:%i)\n")) % iface.current() % cout << autosprintf(_(" (using %i:%i:%i)\n"), iface.current(),
iface.revision() % iface.age(); iface.revision(), iface.age());
} else } else
cout << "\n"; cout << "\n";
} }
} }
{ {
// xgroup(diag) // xgroup(diag)
cout << format(_("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..
shared_ptr<NameIO> nameCoder = 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 we're using a newer interface, show the version number
if (config->nameIface != nameCoder->interface()) { if (config->nameIface != nameCoder->interface()) {
Interface iface = nameCoder->interface(); Interface iface = nameCoder->interface();
cout << format(_(" (using %i:%i:%i)\n")) % iface.current() % cout << autosprintf(_(" (using %i:%i:%i)\n"), iface.current(),
iface.revision() % iface.age(); iface.revision(), iface.age());
} else } else
cout << "\n"; cout << "\n";
} }
} }
{ {
cout << format(_("Key Size: %i bits")) % config->keySize; cout << autosprintf(_("Key Size: %i bits"), config->keySize);
cipher = config->getCipher(); cipher = config->getCipher();
if (!cipher) { if (!cipher) {
// xgroup(diag) // xgroup(diag)
@ -1169,28 +1165,28 @@ void showFSInfo(const shared_ptr<EncFSConfig> &config) {
cout << "\n"; cout << "\n";
} }
if (config->kdfIterations > 0 && config->salt.size() > 0) { if (config->kdfIterations > 0 && config->salt.size() > 0) {
cout << format(_("Using PBKDF2, with %i iterations")) % cout << autosprintf(_("Using PBKDF2, with %i iterations"),
config->kdfIterations << "\n"; config->kdfIterations) << "\n";
cout << format(_("Salt Size: %i bits")) % (8 * config->salt.size()) << "\n"; cout << autosprintf(_("Salt Size: %i bits"), 8 * config->salt.size()) << "\n";
} }
if (config->blockMACBytes || config->blockMACRandBytes) { if (config->blockMACBytes || config->blockMACRandBytes) {
if (config->subVersion < 20040813) { if (config->subVersion < 20040813) {
cout << format( cout << autosprintf(
// xgroup(diag) // xgroup(diag)
_("Block Size: %i bytes + %i byte MAC header")) % _("Block Size: %i bytes + %i byte MAC header"),
config->blockSize % config->blockSize,
(config->blockMACBytes + config->blockMACRandBytes) << endl; config->blockMACBytes + config->blockMACRandBytes) << endl;
} else { } else {
// new version stores the header as part of that block size.. // new version stores the header as part of that block size..
cout << format( cout << autosprintf(
// xgroup(diag) // xgroup(diag)
_("Block Size: %i bytes, including %i byte MAC header")) % _("Block Size: %i bytes, including %i byte MAC header"),
config->blockSize % config->blockSize,
(config->blockMACBytes + config->blockMACRandBytes) << endl; config->blockMACBytes + config->blockMACRandBytes) << endl;
} }
} else { } else {
// xgroup(diag) // xgroup(diag)
cout << format(_("Block Size: %i bytes")) % config->blockSize; cout << autosprintf(_("Block Size: %i bytes"), config->blockSize);
cout << "\n"; cout << "\n";
} }

View File

@ -3,7 +3,7 @@ include $(top_srcdir)/Makefile.common
ALL_INCLUDES = @RLOG_CFLAGS@ @OPENSSL_CFLAGS@ @BOOST_CPPFLAGS@ ALL_INCLUDES = @RLOG_CFLAGS@ @OPENSSL_CFLAGS@ @BOOST_CPPFLAGS@
ALL_LDFLAGS = @RLOG_LIBS@ @OPENSSL_LIBS@ @BOOST_LDFLAGS@ 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 AM_CXXFLAGS = -DRLOG_COMPONENT="encfs" $(ALL_INCLUDES) -I../intl
@ -43,7 +43,7 @@ endif
libencfs_la_LDFLAGS = -version-info 6:2:0 libencfs_la_LDFLAGS = -version-info 6:2:0
libencfs_la_LIBADD = @RLOG_LIBS@ \ libencfs_la_LIBADD = @RLOG_LIBS@ \
@OPENSSL_LIBS@ \ @OPENSSL_LIBS@ \
@BOOST_SERIALIZATION_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_SYSTEM_LIB@ @BOOST_SERIALIZATION_LIB@
EXTRASRC = EXTRASRC =
if BUILD_OPENSSL if BUILD_OPENSSL
@ -53,6 +53,7 @@ endif
endif endif
libencfs_la_SOURCES = \ libencfs_la_SOURCES = \
autosprintf.cpp \
readpassphrase.cpp \ readpassphrase.cpp \
base64.cpp \ base64.cpp \
ConfigReader.cpp \ ConfigReader.cpp \

67
encfs/autosprintf.cpp Normal file
View 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
View 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 */

View File

@ -37,11 +37,10 @@
#include <sys/xattr.h> #include <sys/xattr.h>
#endif #endif
#include <string> #include <functional>
#include <map> #include <map>
#include <string>
#include <boost/tuple/tuple.hpp> #include <vector>
#include <boost/scoped_array.hpp>
#include "DirNode.h" #include "DirNode.h"
#include "MemoryPool.h" #include "MemoryPool.h"
@ -59,11 +58,11 @@
#define ESUCCESS 0 #define ESUCCESS 0
using namespace std; using namespace std;
using namespace std::placeholders;
using namespace rlog; using namespace rlog;
using rel::Lock; 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); 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 // 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, static int withCipherPath(const char *opName, const char *path,
int (*op)(EncFS_Context *, const string &name, function<int(EncFS_Context *, const string &)> op,
T data), bool passReturnCode = false) {
T data, bool passReturnCode = false) {
EncFS_Context *ctx = context(); EncFS_Context *ctx = context();
int res = -EIO; int res = -EIO;
@ -87,7 +84,7 @@ static int withCipherPath(const char *opName, const char *path,
string cyName = FSRoot->cipherPath(path); string cyName = FSRoot->cipherPath(path);
rLog(Info, "%s %s", opName, cyName.c_str()); rLog(Info, "%s %s", opName, cyName.c_str());
res = op(ctx, cyName, data); res = op(ctx, cyName);
if (res == -1) { if (res == -1) {
int eno = errno; int eno = errno;
@ -95,8 +92,7 @@ static int withCipherPath(const char *opName, const char *path,
res = -eno; res = -eno;
} else if (!passReturnCode) } else if (!passReturnCode)
res = ESUCCESS; res = ESUCCESS;
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in %s", opName); rError("error caught in %s", opName);
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -104,10 +100,9 @@ static int withCipherPath(const char *opName, const char *path,
} }
// helper function -- apply a functor to a node // helper function -- apply a functor to a node
template <typename T>
static int withFileNode(const char *opName, const char *path, static int withFileNode(const char *opName, const char *path,
struct fuse_file_info *fi, struct fuse_file_info *fi,
int (*op)(FileNode *, T data), T data) { function<int(FileNode *)> op) {
EncFS_Context *ctx = context(); EncFS_Context *ctx = context();
int res = -EIO; int res = -EIO;
@ -124,11 +119,10 @@ static int withFileNode(const char *opName, const char *path,
rAssert(fnode.get() != NULL); rAssert(fnode.get() != NULL);
rLog(Info, "%s %s", opName, fnode->cipherName()); 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)); if (res < 0) rInfo("%s error: %s", opName, strerror(-res));
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in %s", opName); rError("error caught in %s", opName);
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -153,15 +147,15 @@ int _do_getattr(FileNode *fnode, struct stat *stbuf) {
shared_ptr<DirNode> FSRoot = ctx->getRoot(&res); shared_ptr<DirNode> FSRoot = ctx->getRoot(&res);
if (FSRoot) { if (FSRoot) {
// determine plaintext link size.. Easiest to read and decrypt.. // 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) { if (res >= 0) {
// other functions expect c-strings to be null-terminated, which // other functions expect c-strings to be null-terminated, which
// readlink doesn't provide // readlink doesn't provide
buf[res] = '\0'; buf[res] = '\0';
stbuf->st_size = FSRoot->plainPath(buf.get()).length(); stbuf->st_size = FSRoot->plainPath(buf.data()).length();
res = ESUCCESS; res = ESUCCESS;
} else } else
@ -173,12 +167,12 @@ int _do_getattr(FileNode *fnode, struct stat *stbuf) {
} }
int encfs_getattr(const char *path, 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, int encfs_fgetattr(const char *path, struct stat *stbuf,
struct fuse_file_info *fi) { 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) { 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; return res;
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("Error caught in getdir"); rError("Error caught in getdir");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
return -EIO; return -EIO;
@ -251,8 +244,7 @@ int encfs_mknod(const char *path, mode_t mode, dev_t rdev) {
if (dnode->getAttr(&st) == 0) if (dnode->getAttr(&st) == 0)
res = fnode->mknod(mode, rdev, uid, st.st_gid); res = fnode->mknod(mode, rdev, uid, st.st_gid);
} }
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in mknod"); rError("error caught in mknod");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -285,8 +277,7 @@ int encfs_mkdir(const char *path, mode_t mode) {
if (dnode->getAttr(&st) == 0) if (dnode->getAttr(&st) == 0)
res = FSRoot->mkdir(path, mode, uid, st.st_gid); res = FSRoot->mkdir(path, mode, uid, st.st_gid);
} }
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in mkdir"); rError("error caught in mkdir");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -304,27 +295,23 @@ int encfs_unlink(const char *path) {
// let DirNode handle it atomically so that it can handle race // let DirNode handle it atomically so that it can handle race
// conditions // conditions
res = FSRoot->unlink(path); res = FSRoot->unlink(path);
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in unlink"); rError("error caught in unlink");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
return res; return res;
} }
int _do_rmdir(EncFS_Context *, const string &cipherPath, int) { int _do_rmdir(EncFS_Context *, const string &cipherPath) {
return rmdir(cipherPath.c_str()); return rmdir(cipherPath.c_str());
} }
int encfs_rmdir(const char *path) { 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, int _do_readlink(EncFS_Context *ctx, const string &cyName, char *buf,
tuple<char *, size_t> data) { size_t size) {
char *buf = data.get<0>();
size_t size = data.get<1>();
int res = ESUCCESS; int res = ESUCCESS;
shared_ptr<DirNode> FSRoot = ctx->getRoot(&res); shared_ptr<DirNode> FSRoot = ctx->getRoot(&res);
if (!FSRoot) return res; if (!FSRoot) return res;
@ -337,8 +324,7 @@ int _do_readlink(EncFS_Context *ctx, const string &cyName,
string decodedName; string decodedName;
try { try {
decodedName = FSRoot->plainPath(buf); decodedName = FSRoot->plainPath(buf);
} } catch (...) {
catch (...) {
} }
if (!decodedName.empty()) { 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) { 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) { int encfs_symlink(const char *from, const char *to) {
@ -387,8 +374,7 @@ int encfs_symlink(const char *from, const char *to) {
res = -errno; res = -errno;
else else
res = ESUCCESS; res = ESUCCESS;
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in symlink"); rError("error caught in symlink");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -404,8 +390,7 @@ int encfs_link(const char *from, const char *to) {
try { try {
res = FSRoot->link(from, to); res = FSRoot->link(from, to);
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in link"); rError("error caught in link");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -421,8 +406,7 @@ int encfs_rename(const char *from, const char *to) {
try { try {
res = FSRoot->rename(from, to); res = FSRoot->rename(from, to);
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in rename"); rError("error caught in rename");
err.log(_RLWarningChannel); 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) { 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 _do_chown(EncFS_Context *, const string &cyName, uid_t u, gid_t g) {
int res = lchown(cyName.c_str(), data.get<0>(), data.get<1>()); int res = lchown(cyName.c_str(), u, g);
return (res == -1) ? -errno : ESUCCESS; return (res == -1) ? -errno : ESUCCESS;
} }
int encfs_chown(const char *path, uid_t uid, gid_t gid) { 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 _do_truncate(FileNode *fnode, off_t size) { return fnode->truncate(size); }
int encfs_truncate(const char *path, off_t 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) { 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) { 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) { 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, 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]) { 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) { 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; res = ESUCCESS;
} }
} }
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in open"); rError("error caught in open");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -510,7 +493,7 @@ int encfs_open(const char *path, struct fuse_file_info *file) {
return res; 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 /* 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 close the file. However it is important to call close() for some
underlying filesystems (like NFS). 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) { 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(); EncFS_Context *ctx = context();
try { try {
ctx->eraseNode(path, (void *)(uintptr_t)finfo->fh); ctx->eraseNode(path, (void *)(uintptr_t) finfo->fh);
return ESUCCESS; return ESUCCESS;
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in release"); rError("error caught in release");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
return -EIO; return -EIO;
} }
} }
int _do_read(FileNode *fnode, tuple<unsigned char *, size_t, off_t> data) { int _do_read(FileNode *fnode, unsigned char *ptr, size_t size, off_t off) {
return fnode->read(data.get<2>(), data.get<0>(), data.get<1>()); return fnode->read(off, ptr, size);
} }
int encfs_read(const char *path, char *buf, size_t size, off_t offset, int encfs_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *file) { struct fuse_file_info *file) {
return withFileNode("read", path, file, _do_read, return withFileNode("read", path, file,
make_tuple((unsigned char *)buf, size, offset)); bind(_do_read, _1, (unsigned char *)buf, size, offset));
} }
int _do_fsync(FileNode *fnode, int dataSync) { 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) { 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) { int _do_write(FileNode *fnode, unsigned char *ptr, size_t size, off_t offset) {
size_t size = data.get<1>(); if (fnode->write(offset, ptr, size))
if (fnode->write(data.get<2>(), (unsigned char *)data.get<0>(), size))
return size; return size;
else else
return -EIO; 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, int encfs_write(const char *path, const char *buf, size_t size, off_t offset,
struct fuse_file_info *file) { struct fuse_file_info *file) {
return withFileNode("write", path, file, _do_write, return withFileNode("write", path, file,
make_tuple(buf, size, offset)); bind(_do_write, _1, (unsigned char *)buf, size, offset));
} }
// statfs works even if encfs is detached.. // 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.. st->f_namemax = 6 * (st->f_namemax - 2) / 8; // approx..
} }
if (res == -1) res = -errno; if (res == -1) res = -errno;
} } catch (rlog::Error &err) {
catch (rlog::Error &err) {
rError("error caught in statfs"); rError("error caught in statfs");
err.log(_RLWarningChannel); err.log(_RLWarningChannel);
} }
@ -608,70 +588,68 @@ int encfs_statfs(const char *path, struct statvfs *st) {
#ifdef HAVE_XATTR #ifdef HAVE_XATTR
#ifdef XATTR_ADD_OPT #ifdef XATTR_ADD_OPT
int _do_setxattr(EncFS_Context *, const string &cyName, int _do_setxattr(EncFS_Context *, const string &cyName, const char *name,
tuple<const char *, const char *, size_t, uint32_t> data) { const char *value, size_t size, uint32_t pos) {
int options = 0; int options = 0;
return ::setxattr(cyName.c_str(), data.get<0>(), data.get<1>(), data.get<2>(), return ::setxattr(cyName.c_str(), name, value, size, pos, options);
data.get<3>(), options);
} }
int encfs_setxattr(const char *path, const char *name, const char *value, int encfs_setxattr(const char *path, const char *name, const char *value,
size_t size, int flags, uint32_t position) { size_t size, int flags, uint32_t position) {
(void)flags; (void)flags;
return withCipherPath("setxattr", path, _do_setxattr, return withCipherPath("setxattr", path, bind(_do_setxattr, _1, _2, name,
make_tuple(name, value, size, position)); value, size, position));
} }
#else #else
int _do_setxattr(EncFS_Context *, const string &cyName, int _do_setxattr(EncFS_Context *, const string &cyName, const char *name,
tuple<const char *, const char *, size_t, int> data) { const char *value, size_t size, int flags) {
return ::setxattr(cyName.c_str(), data.get<0>(), data.get<1>(), data.get<2>(), return ::setxattr(cyName.c_str(), name, value, size, flags);
data.get<3>());
} }
int encfs_setxattr(const char *path, const char *name, const char *value, int encfs_setxattr(const char *path, const char *name, const char *value,
size_t size, int flags) { size_t size, int flags) {
return withCipherPath("setxattr", path, _do_setxattr, return withCipherPath("setxattr", path,
make_tuple(name, value, size, flags)); bind(_do_setxattr, _1, _2, name, value, size, flags));
} }
#endif #endif
#ifdef XATTR_ADD_OPT #ifdef XATTR_ADD_OPT
int _do_getxattr(EncFS_Context *, const string &cyName, int _do_getxattr(EncFS_Context *, const string &cyName, const char *name,
tuple<const char *, void *, size_t, uint32_t> data) { void *value, size_t size, uint32_t pos) {
int options = 0; int options = 0;
return ::getxattr(cyName.c_str(), data.get<0>(), data.get<1>(), data.get<2>(), return ::getxattr(cyName.c_str(), name, value, size, pos, options);
data.get<3>(), options);
} }
int encfs_getxattr(const char *path, const char *name, char *value, size_t size, int encfs_getxattr(const char *path, const char *name, char *value, size_t size,
uint32_t position) { uint32_t position) {
return withCipherPath("getxattr", path, _do_getxattr, return withCipherPath(
make_tuple(name, (void *)value, size, position), true); "getxattr", path,
bind(_do_getxattr, _1, _2, name, (void *)value, size, position), true);
} }
#else #else
int _do_getxattr(EncFS_Context *, const string &cyName, int _do_getxattr(EncFS_Context *, const string &cyName, const char *name,
tuple<const char *, void *, size_t> data) { void *value, size_t size) {
return ::getxattr(cyName.c_str(), data.get<0>(), data.get<1>(), return ::getxattr(cyName.c_str(), name, value, size);
data.get<2>());
} }
int encfs_getxattr(const char *path, const char *name, char *value, int encfs_getxattr(const char *path, const char *name, char *value,
size_t size) { size_t size) {
return withCipherPath("getxattr", path, _do_getxattr, return withCipherPath("getxattr", path,
make_tuple(name, (void *)value, size), true); bind(_do_getxattr, _1, _2, name, (void *)value, size),
true);
} }
#endif #endif
int _do_listxattr(EncFS_Context *, const string &cyName, int _do_listxattr(EncFS_Context *, const string &cyName, char *list,
tuple<char *, size_t> data) { size_t size) {
#ifdef XATTR_ADD_OPT #ifdef XATTR_ADD_OPT
int options = 0; 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 #else
int res = ::listxattr(cyName.c_str(), data.get<0>(), data.get<1>()); int res = ::listxattr(cyName.c_str(), list, size);
#endif #endif
return (res == -1) ? -errno : res; return (res == -1) ? -errno : res;
} }
int encfs_listxattr(const char *path, char *list, size_t size) { int encfs_listxattr(const char *path, char *list, size_t size) {
return withCipherPath("listxattr", path, _do_listxattr, return withCipherPath("listxattr", path,
make_tuple(list, size), true); bind(_do_listxattr, _1, _2, list, size), true);
} }
int _do_removexattr(EncFS_Context *, const string &cyName, const char *name) { 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) { 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 #endif // HAVE_XATTR

View File

@ -25,6 +25,8 @@
#include <fuse.h> #include <fuse.h>
#include <unistd.h> #include <unistd.h>
#include <rlog/rlog.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
#endif #endif
@ -35,9 +37,10 @@
static __inline int setfsuid(uid_t uid) { static __inline int setfsuid(uid_t uid) {
uid_t olduid = geteuid(); uid_t olduid = geteuid();
seteuid(uid); if (seteuid(uid) != 0) {
// ignore error.
if (errno != EINVAL) errno = 0; rDebug("seteuid error: %i", errno);
}
return olduid; return olduid;
} }
@ -45,9 +48,10 @@ static __inline int setfsuid(uid_t uid) {
static __inline int setfsgid(gid_t gid) { static __inline int setfsgid(gid_t gid) {
gid_t oldgid = getegid(); gid_t oldgid = getegid();
setegid(gid); if (setegid(gid) != 0) {
// ignore error.
if (errno != EINVAL) errno = 0; rDebug("setfsgid error: %i", errno);
}
return oldgid; return oldgid;
} }

View File

@ -17,42 +17,35 @@
#include "encfs.h" #include "encfs.h"
#include "config.h" #include <fcntl.h>
#include <getopt.h>
#include "FileUtils.h" #include <iostream>
#include "Cipher.h" #include <string>
#include <sys/stat.h>
#include "Context.h" #include <sys/types.h>
#include "FileNode.h"
#include "DirNode.h"
#include "shared_ptr.h"
#include <rlog/rlog.h> #include <rlog/rlog.h>
#include <rlog/StdioNode.h> #include <rlog/StdioNode.h>
#include <rlog/RLogChannel.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 #ifdef HAVE_SSL
#define NO_DES #define NO_DES
#include <openssl/ssl.h> #include <openssl/ssl.h>
#endif #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 rlog;
using namespace std; using namespace std;
using boost::format; using gnu::autosprintf;
using boost::scoped_array;
static int showInfo(int argc, char **argv); static int showInfo(int argc, char **argv);
static int showVersion(int argc, char **argv); static int showVersion(int argc, char **argv);
@ -112,13 +105,14 @@ struct CommandOpts {
{0, 0, 0, 0, 0, 0}}; {0, 0, 0, 0, 0, 0}};
static void usage(const char *name) { 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) ..." // displays usage commands, eg "./encfs (root dir) ..."
// xgroup(usage) // xgroup(usage)
<< format( << autosprintf(
_("%s (root dir)\n" _("%s (root dir)\n"
" -- displays information about the filesystem, or \n")) % " -- displays information about the filesystem, or \n"),
name; name);
int offset = 0; int offset = 0;
while (commands[offset].name != 0) { while (commands[offset].name != 0) {
@ -132,12 +126,12 @@ static void usage(const char *name) {
cerr << "\n" cerr << "\n"
// xgroup(usage) // 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) { static bool checkDir(string &rootDir) {
if (!isDirectory(rootDir.c_str())) { 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; return false;
} }
if (rootDir[rootDir.length() - 1] != '/') rootDir.append("/"); if (rootDir[rootDir.length() - 1] != '/') rootDir.append("/");
@ -149,7 +143,7 @@ static int showVersion(int argc, char **argv) {
(void)argc; (void)argc;
(void)argv; (void)argv;
// xgroup(usage) // xgroup(usage)
cerr << format(_("encfsctl version %s")) % VERSION << "\n"; cerr << autosprintf(_("encfsctl version %s"), VERSION) << "\n";
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -170,36 +164,33 @@ static int showInfo(int argc, char **argv) {
return EXIT_FAILURE; return EXIT_FAILURE;
case Config_Prehistoric: case Config_Prehistoric:
// xgroup(diag) // xgroup(diag)
cout << _("A really old EncFS filesystem was found. \n" cout << _(
"It is not supported in this EncFS build.\n"); "A really old EncFS filesystem was found. \n"
"It is not supported in this EncFS build.\n");
return EXIT_FAILURE; return EXIT_FAILURE;
case Config_V3: case Config_V3:
// xgroup(diag) // xgroup(diag)
cout << "\n" << format( cout << "\n" << autosprintf(_("Version 3 configuration; "
_("Version 3 configuration; " "created by %s\n"),
"created by %s\n")) % config->creator.c_str());
config->creator.c_str();
break; break;
case Config_V4: case Config_V4:
// xgroup(diag) // xgroup(diag)
cout << "\n" << format( cout << "\n" << autosprintf(_("Version 4 configuration; "
_("Version 4 configuration; " "created by %s\n"),
"created by %s\n")) % config->creator.c_str());
config->creator.c_str();
break; break;
case Config_V5: case Config_V5:
// xgroup(diag) // xgroup(diag)
cout << "\n" << format( cout << "\n" << autosprintf(_("Version 5 configuration; "
_("Version 5 configuration; " "created by %s (revision %i)\n"),
"created by %s (revision %i)\n")) % config->creator.c_str(), config->subVersion);
config->creator % config->subVersion;
break; break;
case Config_V6: case Config_V6:
// xgroup(diag) // xgroup(diag)
cout << "\n" << format( cout << "\n" << autosprintf(_("Version 6 configuration; "
_("Version 6 configuration; " "created by %s (revision %i)\n"),
"created by %s (revision %i)\n")) % config->creator.c_str(), config->subVersion);
config->creator % config->subVersion;
break; break;
} }
@ -419,15 +410,15 @@ static int cmd_cat(int argc, char **argv) {
static int copyLink(const struct stat &stBuf, static int copyLink(const struct stat &stBuf,
const shared_ptr<EncFS_Root> &rootInfo, const string &cpath, const shared_ptr<EncFS_Root> &rootInfo, const string &cpath,
const string &destName) { const string &destName) {
scoped_array<char> buf(new char[stBuf.st_size + 1]); std::vector<char> buf(stBuf.st_size + 1, '\0');
int res = ::readlink(cpath.c_str(), buf.get(), stBuf.st_size); int res = ::readlink(cpath.c_str(), buf.data(), stBuf.st_size);
if (res == -1) { if (res == -1) {
cerr << "unable to readlink of " << cpath << "\n"; cerr << "unable to readlink of " << cpath << "\n";
return EXIT_FAILURE; return EXIT_FAILURE;
} }
buf[res] = '\0'; 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()); res = ::symlink(decodedLink.c_str(), destName.c_str());
if (res == -1) { if (res == -1) {
@ -458,7 +449,11 @@ static int copyContents(const shared_ptr<EncFS_Root> &rootInfo,
cerr << "unable to read link " << encfsName << "\n"; cerr << "unable to read link " << encfsName << "\n";
return EXIT_FAILURE; 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 { } else {
int outfd = creat(targetName, st.st_mode); int outfd = creat(targetName, st.st_mode);
@ -552,7 +547,7 @@ int showcruft(const shared_ptr<EncFS_Root> &rootInfo, const char *dirName) {
if (!showedDir) { if (!showedDir) {
// just before showing a list of files in a directory // 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; showedDir = true;
} }
++found; ++found;
@ -594,9 +589,9 @@ static int cmd_showcruft(int argc, char **argv) {
int filesFound = showcruft(rootInfo, "/"); int filesFound = showcruft(rootInfo, "/");
cerr << format(ngettext("Found %i invalid file.", "Found %i invalid files.", cerr << autosprintf(ngettext("Found %i invalid file.",
filesFound)) % "Found %i invalid files.", filesFound),
filesFound << "\n"; filesFound) << "\n";
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -617,8 +612,8 @@ static int do_chpasswd(bool useStdin, bool annotate, int argc, char **argv) {
// instanciate proper cipher // instanciate proper cipher
shared_ptr<Cipher> cipher = Cipher::New(config->cipherIface, config->keySize); shared_ptr<Cipher> cipher = Cipher::New(config->cipherIface, config->keySize);
if (!cipher) { if (!cipher) {
cout << format(_("Unable to find specified cipher \"%s\"\n")) % cout << autosprintf(_("Unable to find specified cipher \"%s\"\n"),
config->cipherIface.name(); config->cipherIface.name().c_str());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -725,12 +720,13 @@ int main(int argc, char **argv) {
} }
if (commands[offset].name == 0) { if (commands[offset].name == 0) {
cerr << format(_("invalid command: \"%s\"")) % argv[1] << "\n"; cerr << autosprintf(_("invalid command: \"%s\""), argv[1]) << "\n";
} else { } else {
if ((argc - 2 < commands[offset].minOptions) || if ((argc - 2 < commands[offset].minOptions) ||
(argc - 2 > commands[offset].maxOptions)) { (argc - 2 > commands[offset].maxOptions)) {
cerr << format(_("Incorrect number of arguments for command \"%s\"")) % cerr << autosprintf(
argv[1] << "\n"; _("Incorrect number of arguments for command \"%s\""),
argv[1]) << "\n";
} else } else
return (*commands[offset].func)(argc - 1, argv + 1); return (*commands[offset].func)(argc - 1, argv + 1);
} }

View File

@ -17,6 +17,7 @@
*/ */
#include <iostream> #include <iostream>
#include <memory>
#include <string> #include <string>
#include <sstream> #include <sstream>
@ -29,15 +30,13 @@
#include <getopt.h> #include <getopt.h>
#include <boost/format.hpp>
#include <boost/scoped_ptr.hpp>
#include <rlog/rlog.h> #include <rlog/rlog.h>
#include <rlog/Error.h> #include <rlog/Error.h>
#include <rlog/RLogChannel.h> #include <rlog/RLogChannel.h>
#include <rlog/SyslogNode.h> #include <rlog/SyslogNode.h>
#include <rlog/StdioNode.h> #include <rlog/StdioNode.h>
#include "autosprintf.h"
#include "ConfigReader.h" #include "ConfigReader.h"
#include "Context.h" #include "Context.h"
#include "DirNode.h" #include "DirNode.h"
@ -58,15 +57,10 @@
extern "C" void fuse_unmount_compat22(const char *mountpoint); extern "C" void fuse_unmount_compat22(const char *mountpoint);
#define fuse_unmount fuse_unmount_compat22 #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 std;
using namespace rlog; using namespace rlog;
using namespace rel; using namespace rel;
using boost::format; using gnu::autosprintf;
using boost::scoped_ptr;
// Maximum number of arguments that we're going to pass on to fuse. Doesn't // 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.. // 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) { static void usage(const char *name) {
// xgroup(usage) // xgroup(usage)
cerr << format(_("Build: encfs version %s")) % VERSION << "\n\n" cerr << autosprintf(_("Build: encfs version %s"), VERSION) << "\n\n"
// xgroup(usage) // xgroup(usage)
<< format( << autosprintf(
_("Usage: %s [options] rootDir mountPoint [-- [FUSE Mount " _("Usage: %s [options] rootDir mountPoint [-- [FUSE Mount "
"Options]]")) % "Options]]"),
name << "\n\n" name) << "\n\n"
// xgroup(usage) // xgroup(usage)
<< _("Common Options:\n" << _("Common Options:\n"
" -H\t\t\t" " -H\t\t\t"
@ -219,10 +213,10 @@ static bool processArgs(int argc, char *argv[],
{"stdinpass", 0, 0, 'S'}, // read password from stdin {"stdinpass", 0, 0, 'S'}, // read password from stdin
{"annotate", 0, 0, 513}, // Print annotation lines to stderr {"annotate", 0, 0, 513}, // Print annotation lines to stderr
{"verbose", 0, 0, 'v'}, // verbose mode {"verbose", 0, 0, 'v'}, // verbose mode
{"version", 0, 0, 'V'}, // version {"version", 0, 0, 'V'}, // version
{"reverse", 0, 0, 'r'}, // reverse encryption {"reverse", 0, 0, 'r'}, // reverse encryption
{"standard", 0, 0, '1'}, // standard configuration {"standard", 0, 0, '1'}, // standard configuration
{"paranoia", 0, 0, '2'}, // standard configuration {"paranoia", 0, 0, '2'}, // standard configuration
{0, 0, 0, 0}}; {0, 0, 0, 0}};
while (1) { while (1) {
@ -310,7 +304,7 @@ static bool processArgs(int argc, char *argv[],
break; break;
case 'V': case 'V':
// xgroup(usage) // xgroup(usage)
cerr << format(_("encfs version %s")) % VERSION << endl; cerr << autosprintf(_("encfs version %s"), VERSION) << endl;
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'H': case 'H':
@ -477,8 +471,8 @@ int main(int argc, char *argv[]) {
#endif #endif
// log to stderr by default.. // log to stderr by default..
scoped_ptr<StdioNode> slog(new StdioNode(STDERR_FILENO)); std::unique_ptr<StdioNode> slog(new StdioNode(STDERR_FILENO));
scoped_ptr<SyslogNode> logNode; std::unique_ptr<SyslogNode> logNode;
// show error and warning output // show error and warning output
slog->subscribeTo(GetGlobalChannel("error")); slog->subscribeTo(GetGlobalChannel("error"));
@ -637,17 +631,15 @@ int main(int argc, char *argv[]) {
// few words in libfuse's memory.. // few words in libfuse's memory..
FILE *out = fdopen(oldStderr, "a"); FILE *out = fdopen(oldStderr, "a");
// xgroup(usage) // xgroup(usage)
fprintf(out, _("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")); " - invalid options -- see usage message\n"), out);
fclose(out); fclose(out);
} }
} } catch (std::exception &ex) {
catch (std::exception &ex) {
rError(_("Internal error: Caught exception from main loop: %s"), rError(_("Internal error: Caught exception from main loop: %s"),
ex.what()); ex.what());
} } catch (...) {
catch (...) {
rError(_("Internal error: Caught unexpected exception")); rError(_("Internal error: Caught unexpected exception"));
} }
} }

View File

@ -22,16 +22,8 @@
#ifndef _SHARED_PTR_incl_ #ifndef _SHARED_PTR_incl_
#define _SHARED_PTR_incl_ #define _SHARED_PTR_incl_
#include "config.h"
#if HAVE_STD_SHARED_PTR
#include <memory> #include <memory>
using std::shared_ptr; using std::shared_ptr;
using std::dynamic_pointer_cast; using std::dynamic_pointer_cast;
#else
#include <boost/shared_ptr.hpp>
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
#endif
#endif #endif

View File

@ -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
])

View File

@ -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
])

View File

@ -40,10 +40,10 @@ sub cleanup
# Directory structure: plain -[encrypt]-> ciphertext -[decrypt]-> decrypted # Directory structure: plain -[encrypt]-> ciphertext -[decrypt]-> decrypted
sub mount 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"); 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"); ok($r == 0, "mounted decrypting file system");
} }