From: František Dvořák Date: Thu, 17 Oct 2013 19:44:45 +0000 (+0200) Subject: Relaxed reaction on User Extended Attributes errors: X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=730dbf0a0ab6ae62d14bd5d8e6a489f8a841dfcb;p=dmlite-plugins-vfs.git Relaxed reaction on User Extended Attributes errors: - catch and cancel exeption from vfsGetXattrs() - returns VFS_UID_NONE or VFS_GID_NONE (currently it keeps original filesystem values) It's good for dangling symlinks (they're always followed for xattrs). --- diff --git a/src/VfsNs.cpp b/src/VfsNs.cpp index 658546e..fee71c8 100644 --- a/src/VfsNs.cpp +++ b/src/VfsNs.cpp @@ -161,6 +161,8 @@ std::string VfsCatalog::getWorkingDir(void) throw (DmException) void VfsCatalog::vfsUpdateStat(ExtendedStat &xStat, Extensible xattrs) throw (DmException) { if (xattrs.hasField(VFS_XATTR "acl")) xStat.acl = Acl(xattrs.getString(VFS_XATTR "acl")); + else + xStat.acl = Acl(); xStat.stat.st_gid = xattrs.getUnsigned(VFS_XATTR "group", VFS_GID_NONE); xStat.stat.st_uid = xattrs.getUnsigned(VFS_XATTR "owner", VFS_UID_NONE); } @@ -194,14 +196,15 @@ ExtendedStat VfsCatalog::vfsSimpleStat(const std::string& name, const std::strin xStat.acl = Acl(); if (perms) { - xattrs = vfsGetXattrs(path, lpath, true, VFS_XATTR_TYPE_PERMS); - vfsUpdateStat(xStat, xattrs); - } else { - xStat.acl = Acl(); - xStat.stat.st_uid = VFS_UID_NONE; - xStat.stat.st_gid = VFS_GID_NONE; + try { + xattrs = vfsGetXattrs(path, lpath, true, VFS_XATTR_TYPE_PERMS); + } catch (DmException& e) { + // ignore - default owner and no ACLs + } } + vfsUpdateStat(xStat, xattrs); + return xStat; } @@ -260,7 +263,11 @@ ExtendedStat VfsCatalog::extendedStat(const std::string& path, bool follow) thro // owner, permissions and other atributes like the original file anyway. // ==> always follow the symlinks. // - xattrs = vfsGetXattrs(path, getLocalPath(path), true, VFS_XATTR_TYPE_ALL); + try { + xattrs = vfsGetXattrs(path, getLocalPath(path), true, VFS_XATTR_TYPE_ALL); + } catch (DmException& e) { + // ignore - default owner and no ACLs + } // copy non-VFS attributes for (it = xattrs.begin(); it != xattrs.end(); it++) {