diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a3ed14..782b26c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,9 @@ CHECK_CXX_SOURCE_COMPILES ("#include #include int main() { getxattr(0,0,0,0,0,0); return 1; } " XATTR_ADD_OPT) +include (CheckFunctionExists) +check_function_exists(lchmod HAVE_LCHMOD) + # Libraries or programs used for multiple modules. find_package (Protobuf REQUIRED) include_directories (${PROTOBUF_INCLUDE_DIR}) diff --git a/base/config.h.cmake b/base/config.h.cmake index 748bd61..68fecab 100644 --- a/base/config.h.cmake +++ b/base/config.h.cmake @@ -14,6 +14,8 @@ #cmakedefine HAVE_EVP_AES #cmakedefine HAVE_EVP_AES_XTS +#cmakedefine HAVE_LCHMOD + #cmakedefine HAVE_VALGRIND_VALGRIND_H #cmakedefine HAVE_VALGRIND_MEMCHECK_H diff --git a/fs/encfs.cpp b/fs/encfs.cpp index 500acb6..5068c68 100644 --- a/fs/encfs.cpp +++ b/fs/encfs.cpp @@ -50,6 +50,7 @@ using namespace std::tr1; using namespace std; #endif +#include "base/config.h" #include "base/shared_ptr.h" #include "base/Mutex.h" #include "base/Error.h" @@ -483,7 +484,11 @@ int encfs_rename(const char *from, const char *to) int _do_chmod(EncFS_Context *, const string &cipherPath, mode_t mode) { +#ifdef HAVE_LCHMOD + return lchmod( cipherPath.c_str(), mode ); +#else return chmod( cipherPath.c_str(), mode ); +#endif } int encfs_chmod(const char *path, mode_t mode) @@ -697,7 +702,7 @@ int encfs_statfs(const char *path, struct statvfs *st) int _do_setxattr(EncFS_Context *, const string &cyName, tuple data) { - int options = 0; + int options = XATTR_NOFOLLOW; return ::setxattr( cyName.c_str(), get<0>(data), get<1>(data), get<2>(data), get<3>(data), options ); }