From c3adf9729de82bba52405e9f20f235b6a009308f Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 11 Nov 2018 18:27:37 +0100 Subject: fusefrontend: make ListXAttr symlink-safe on Linux Uses /proc/self/fd. --- internal/fusefrontend/xattr.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'internal/fusefrontend/xattr.go') diff --git a/internal/fusefrontend/xattr.go b/internal/fusefrontend/xattr.go index 8e88a62..816754c 100644 --- a/internal/fusefrontend/xattr.go +++ b/internal/fusefrontend/xattr.go @@ -82,21 +82,18 @@ func (fs *FS) RemoveXAttr(relPath string, attr string, context *fuse.Context) fu return fs.removeXAttr(relPath, cAttr, context) } -// ListXAttr - FUSE call. Lists extended attributes on the file at "path". +// ListXAttr - FUSE call. Lists extended attributes on the file at "relPath". // -// TODO: Make symlink-safe. Blocker: package xattr does not provide -// flistxattr(2). -func (fs *FS) ListXAttr(path string, context *fuse.Context) ([]string, fuse.Status) { - if fs.isFiltered(path) { +// This function is symlink-safe on Linux. +// Darwin does not have flistxattr(2) nor /proc/self/fd. How to implement this +// on Darwin in a symlink-safe way? +func (fs *FS) ListXAttr(relPath string, context *fuse.Context) ([]string, fuse.Status) { + if fs.isFiltered(relPath) { return nil, fuse.EPERM } - cPath, err := fs.getBackingPath(path) - if err != nil { - return nil, fuse.ToStatus(err) - } - cNames, err := xattr.LList(cPath) - if err != nil { - return nil, unpackXattrErr(err) + cNames, status := fs.listXAttr(relPath, context) + if !status.Ok() { + return nil, status } names := make([]string, 0, len(cNames)) for _, curName := range cNames { -- cgit v1.2.3