From 0a790e1f4fe3ed2bf19a97e289e8542c3afb0545 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 18 Dec 2013 19:44:40 +0100 Subject: [PATCH] Fix access when mode metadata is missing (owner root, no permissions). --- src/VfsNs.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/VfsNs.cpp b/src/VfsNs.cpp index da7c898..cf32d5c 100644 --- a/src/VfsNs.cpp +++ b/src/VfsNs.cpp @@ -28,9 +28,9 @@ #define IS_VFS_XATTR(NAME) (strncmp((NAME), VFS_XATTR, VFS_XATTR_LENGTH) == 0) #define IS_VFS_FILE(NAME) (strncmp((NAME), VFS_FILE, VFS_FILE_LENGTH) == 0) -// force everything to current owner for now -#define VFS_UID_NONE xStat.stat.st_uid -#define VFS_GID_NONE xStat.stat.st_gid +// no owner or group ==> root +#define VFS_UID_NONE 0 +#define VFS_GID_NONE 0 #define INODE_CACHE_SIZE 256 @@ -201,6 +201,9 @@ void VfsCatalog::vfsUpdateStat(ExtendedStat &xStat, Extensible xattrs) throw (Dm xStat.stat.st_uid = xattrs.getUnsigned(VFS_XATTR "owner", VFS_UID_NONE); modeStr = xattrs.getString(VFS_XATTR "mode", ""); + // 1) prefer type from the filesystem + // 2) no permissions at all when not in xattrs + xStat.stat.st_mode &= S_IFMT; if (!modeStr.empty()) { errno = 0; mode = strtoull(modeStr.c_str(), &parse, 8); @@ -213,8 +216,6 @@ void VfsCatalog::vfsUpdateStat(ExtendedStat &xStat, Extensible xattrs) throw (Dm log(LOG_ERR, "conversion of the mode '%s' failed on '%s'", modeStr.c_str(), xStat.name.c_str()); #endif } else { - // prefer type from the filesystem - mode &= ~S_IFMT; mode |= xStat.stat.st_mode & S_IFMT; // use xattr for everything else xStat.stat.st_mode = mode; -- 1.8.2.3