diff --git a/encfs/DirNode.cpp b/encfs/DirNode.cpp
index 009c8f8..58e7ab7 100644
--- a/encfs/DirNode.cpp
+++ b/encfs/DirNode.cpp
@@ -52,8 +52,8 @@ class DirDeleter {
};
DirTraverse::DirTraverse(std::shared_ptr
_dirPtr, uint64_t _iv,
- std::shared_ptr _naming)
- : dir(std::move(_dirPtr)), iv(_iv), naming(std::move(_naming)) {}
+ std::shared_ptr _naming, bool _root)
+ : dir(std::move(_dirPtr)), iv(_iv), naming(std::move(_naming)), root(_root) {}
DirTraverse &DirTraverse::operator=(const DirTraverse &src) = default;
@@ -61,6 +61,7 @@ DirTraverse::~DirTraverse() {
dir.reset();
iv = 0;
naming.reset();
+ root = false;
}
static bool _nextName(struct dirent *&de, const std::shared_ptr &dir,
@@ -90,6 +91,10 @@ static bool _nextName(struct dirent *&de, const std::shared_ptr &dir,
std::string DirTraverse::nextPlaintextName(int *fileType, ino_t *inode) {
struct dirent *de = nullptr;
while (_nextName(de, dir, fileType, inode)) {
+ if (root && (strcmp(".encfs6.xml", de->d_name) == 0)) {
+ VLOG(1) << "skipping filename: " << de->d_name;
+ continue;
+ }
try {
uint64_t localIv = iv;
return naming->decodePath(de->d_name, &localIv);
@@ -106,6 +111,10 @@ std::string DirTraverse::nextInvalid() {
struct dirent *de = nullptr;
// find the first name which produces a decoding error...
while (_nextName(de, dir, (int *)nullptr, (ino_t *)nullptr)) {
+ if (root && (strcmp(".encfs6.xml", de->d_name) == 0)) {
+ VLOG(1) << "skipping filename: " << de->d_name;
+ continue;
+ }
try {
uint64_t localIv = iv;
naming->decodePath(de->d_name, &localIv);
@@ -355,7 +364,7 @@ DirTraverse DirNode::openDir(const char *plaintextPath) {
if (dir == nullptr) {
int eno = errno;
VLOG(1) << "opendir error " << strerror(eno);
- return DirTraverse(shared_ptr(), 0, std::shared_ptr());
+ return DirTraverse(shared_ptr(), 0, std::shared_ptr(), false);
}
std::shared_ptr dp(dir, DirDeleter());
@@ -369,7 +378,7 @@ DirTraverse DirNode::openDir(const char *plaintextPath) {
} catch (encfs::Error &err) {
RLOG(ERROR) << "encode err: " << err.what();
}
- return DirTraverse(dp, iv, naming);
+ return DirTraverse(dp, iv, naming, (strlen(plaintextPath) == 1));
}
bool DirNode::genRenameList(list &renameList, const char *fromP,
diff --git a/encfs/DirNode.h b/encfs/DirNode.h
index f8f6609..d2fb0dc 100644
--- a/encfs/DirNode.h
+++ b/encfs/DirNode.h
@@ -49,7 +49,7 @@ struct RenameEl;
class DirTraverse {
public:
DirTraverse(std::shared_ptr dirPtr, uint64_t iv,
- std::shared_ptr naming);
+ std::shared_ptr naming, bool root);
~DirTraverse();
DirTraverse &operator=(const DirTraverse &src);
@@ -74,6 +74,7 @@ class DirTraverse {
// more efficient to support filename IV chaining..
uint64_t iv;
std::shared_ptr naming;
+ bool root;
};
inline bool DirTraverse::valid() const { return dir.get() != 0; }
diff --git a/integration/normal.t.pl b/integration/normal.t.pl
index de617ea..e239f64 100755
--- a/integration/normal.t.pl
+++ b/integration/normal.t.pl
@@ -2,7 +2,7 @@
# Test EncFS normal and paranoid mode
-use Test::More tests => 132;
+use Test::More tests => 136;
use File::Path;
use File::Copy;
use File::Temp;
@@ -235,6 +235,11 @@ sub truncate
# Test file creation and removal
sub fileCreation
{
+ # first be sure .encfs6.xml does not show up
+ my $f = encName(".encfs6.xml");
+ cmp_ok( length($f), '>', 8, "encrypted name ok" );
+ ok( ! -f "$raw/$f", "configuration file .encfs6.xml not visible in $raw" );
+
# create a file
qx(date > "$crypt/df.txt");
ok( -f "$crypt/df.txt", "file created" ) || BAIL_OUT("file create failed");
diff --git a/integration/reverse.t.pl b/integration/reverse.t.pl
index 24c1b71..bb37162 100755
--- a/integration/reverse.t.pl
+++ b/integration/reverse.t.pl
@@ -91,11 +91,11 @@ sub encName
return $enc;
}
-# Copy a directory tree and verify that the decrypted data is identical
+# Copy a directory tree and verify that the decrypted data is identical, we also create a foo/.encfs6.xml file, to be sure it correctly shows-up
sub copy_test
{
- ok(system("cp -a encfs $plain")==0, "copying files to plain");
- ok(system("diff -r -q $plain $decrypted")==0, "decrypted files are identical");
+ ok(system("cp -a encfs $plain && mkdir $plain/foo && touch $plain/foo/.encfs6.xml")==0, "copying files to plain");
+ ok(system("diff -r -q --exclude='.encfs6.xml' $plain $decrypted")==0, "decrypted files are identical");
ok(-f "$plain/encfs/encfs.cpp", "file exists");
unlink("$plain/encfs/encfs.cpp");
ok(! -f "$decrypted/encfs.cpp", "file deleted");