From: František Dvořák Date: Wed, 18 Dec 2013 18:44:40 +0000 (+0100) Subject: Fix access when mode metadata is missing (owner root, no permissions). X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=0a790e1f4fe3ed2bf19a97e289e8542c3afb0545;p=dmlite-plugins-vfs.git Fix access when mode metadata is missing (owner root, no permissions). --- 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;