From 730dbf0a0ab6ae62d14bd5d8e6a489f8a841dfcb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 17 Oct 2013 21:44:45 +0200 Subject: [PATCH] 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). --- src/VfsNs.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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++) { -- 1.8.2.3