aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend/xattr.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-11-11 17:43:48 +0100
committerJakob Unterwurzacher2019-01-01 16:24:25 +0100
commit2286372603f506cf719654a9901de0749c544b12 (patch)
tree3281d54570b9a06e5be756a57d049900848db182 /internal/fusefrontend/xattr.go
parentb97d7d1d33d1274c6872d899692a56bd4070a6d9 (diff)
fusefrontend: make GetXAttr() symlink-safe on Linux
Uses the /proc/self/fd trick, which does not work on Darwin.
Diffstat (limited to 'internal/fusefrontend/xattr.go')
-rw-r--r--internal/fusefrontend/xattr.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/internal/fusefrontend/xattr.go b/internal/fusefrontend/xattr.go
index 74b3790..caf1e15 100644
--- a/internal/fusefrontend/xattr.go
+++ b/internal/fusefrontend/xattr.go
@@ -25,24 +25,22 @@ var xattrStorePrefix = "user.gocryptfs."
// GetXAttr - FUSE call. Reads the value of extended attribute "attr".
//
-// TODO: Make symlink-safe. Blocker: package xattr does not provide fgetxattr(2).
-func (fs *FS) GetXAttr(path string, attr string, context *fuse.Context) ([]byte, fuse.Status) {
- if fs.isFiltered(path) {
+// This function is symlink-safe on Linux.
+// Darwin does not have fgetxattr(2) nor /proc. How to implement this on Darwin
+// in a symlink-safe way?
+func (fs *FS) GetXAttr(relPath string, attr string, context *fuse.Context) ([]byte, fuse.Status) {
+ if fs.isFiltered(relPath) {
return nil, fuse.EPERM
}
if disallowedXAttrName(attr) {
return nil, _EOPNOTSUPP
}
cAttr := fs.encryptXattrName(attr)
- cPath, err := fs.getBackingPath(path)
- if err != nil {
- return nil, fuse.ToStatus(err)
- }
- encryptedData, err := xattr.LGet(cPath, cAttr)
- if err != nil {
- return nil, unpackXattrErr(err)
+ cData, status := fs.getXattr(relPath, cAttr, context)
+ if !status.Ok() {
+ return nil, status
}
- data, err := fs.decryptXattrValue(encryptedData)
+ data, err := fs.decryptXattrValue(cData)
if err != nil {
tlog.Warn.Printf("GetXAttr: %v", err)
return nil, fuse.EIO