use lchmod when available, fixes #158

git-svn-id: http://encfs.googlecode.com/svn/trunk@96 db9cf616-1c43-0410-9cb8-a902689de0d6
This commit is contained in:
Valient Gough 2013-03-05 06:38:00 +00:00
parent 7e95ff90c8
commit 5a126ea797
3 changed files with 11 additions and 1 deletions

View File

@ -66,6 +66,9 @@ CHECK_CXX_SOURCE_COMPILES ("#include <sys/types.h>
#include <sys/xattr.h>
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})

View File

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

View File

@ -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<const char *, const char *, size_t, uint32_t> 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 );
}