summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/xattr_linux.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-11-11 18:27:37 +0100
committerJakob Unterwurzacher2019-01-01 16:24:25 +0100
commitc3adf9729de82bba52405e9f20f235b6a009308f (patch)
tree5f59613d8d1d729144d9d7e30b72cc61ce1df4ae /internal/fusefrontend/xattr_linux.go
parentd3ae87fa2b10269f9619f7a36fd4a01f35448fb6 (diff)
fusefrontend: make ListXAttr symlink-safe on Linux
Uses /proc/self/fd.
Diffstat (limited to 'internal/fusefrontend/xattr_linux.go')
-rw-r--r--internal/fusefrontend/xattr_linux.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/fusefrontend/xattr_linux.go b/internal/fusefrontend/xattr_linux.go
index a17b12c..915713d 100644
--- a/internal/fusefrontend/xattr_linux.go
+++ b/internal/fusefrontend/xattr_linux.go
@@ -99,3 +99,27 @@ func (fs *FS) removeXAttr(relPath string, cAttr string, context *fuse.Context) f
err := xattr.Remove(procFd(fd), cAttr)
return unpackXattrErr(err)
}
+
+// listXAttr - list encrypted xattr names on plaintext path "relPath".
+//
+// This function is symlink-safe on Linux by using /proc/self/fd.
+func (fs *FS) listXAttr(relPath string, context *fuse.Context) ([]string, fuse.Status) {
+ file, fd, status := fs.getFileFd(relPath, context)
+ if !status.Ok() {
+ // If relPath is a symlink, getFileFd fails with ELOOP. As setXattr()
+ // also fails with ELOOP, there is no way to set xattrs on symlinks,
+ // and we can assume that the file does not have any.
+ if status == fuse.Status(syscall.ELOOP) {
+ return nil, fuse.OK
+ }
+ return nil, status
+ }
+ defer file.Release()
+
+ cNames, err := xattr.List(procFd(fd))
+ if err != nil {
+ status := unpackXattrErr(err)
+ return nil, status
+ }
+ return cNames, fuse.OK
+}