From 5ccc06d5cb321b1400e33a7d0819bf617c52600d Mon Sep 17 00:00:00 2001 From: Bolshevik Date: Tue, 1 May 2018 18:46:51 +0200 Subject: xattr: added passing of a "flags" parameter Pass the "flags" parameter to the lower layer syscall. This makes Apple applications being able to successfully save data. --- internal/fusefrontend/xattr.go | 8 +++----- internal/fusefrontend/xattr_darwin.go | 15 +++++++++++++++ internal/fusefrontend/xattr_linux.go | 4 ++++ internal/fusefrontend/xattr_notlinux.go | 8 -------- 4 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 internal/fusefrontend/xattr_darwin.go delete mode 100644 internal/fusefrontend/xattr_notlinux.go (limited to 'internal/fusefrontend') diff --git a/internal/fusefrontend/xattr.go b/internal/fusefrontend/xattr.go index 36ab4d5..9833368 100644 --- a/internal/fusefrontend/xattr.go +++ b/internal/fusefrontend/xattr.go @@ -54,14 +54,12 @@ func (fs *FS) SetXAttr(path string, attr string, data []byte, flags int, context if fs.isFiltered(path) { return fuse.EPERM } - if flags != 0 { - // Drop this once https://github.com/pkg/xattr/pull/26 is merged - return fuse.ENOSYS - } if disallowedXAttrName(attr) { return fuse.EPERM } + flags = filterXattrSetFlags(flags) + cPath, err := fs.getBackingPath(path) if err != nil { return fuse.ToStatus(err) @@ -69,7 +67,7 @@ func (fs *FS) SetXAttr(path string, attr string, data []byte, flags int, context cAttr := fs.encryptXattrName(attr) // xattr data is encrypted like a symlink target cData64 := []byte(fs.encryptSymlinkTarget(string(data))) - return unpackXattrErr(xattr.Set(cPath, cAttr, cData64)) + return unpackXattrErr(xattr.SetWithFlags(cPath, cAttr, cData64, flags)) } // RemoveXAttr implements pathfs.Filesystem. diff --git a/internal/fusefrontend/xattr_darwin.go b/internal/fusefrontend/xattr_darwin.go new file mode 100644 index 0000000..b626006 --- /dev/null +++ b/internal/fusefrontend/xattr_darwin.go @@ -0,0 +1,15 @@ +// +build darwin + +// Package fusefrontend interfaces directly with the go-fuse library. +package fusefrontend + +import "github.com/pkg/xattr" + +func disallowedXAttrName(attr string) bool { + return false +} + +// On Darwin it is needed to unset XATTR_NOSECURITY 0x0008 +func filterXattrSetFlags(flags int) int { + return flags &^ xattr.XATTR_NOSECURITY +} diff --git a/internal/fusefrontend/xattr_linux.go b/internal/fusefrontend/xattr_linux.go index ebe42b1..61b90e3 100644 --- a/internal/fusefrontend/xattr_linux.go +++ b/internal/fusefrontend/xattr_linux.go @@ -13,3 +13,7 @@ const xattrUserPrefix = "user." func disallowedXAttrName(attr string) bool { return !strings.HasPrefix(attr, xattrUserPrefix) } + +func filterXattrSetFlags(flags int) int { + return flags +} diff --git a/internal/fusefrontend/xattr_notlinux.go b/internal/fusefrontend/xattr_notlinux.go deleted file mode 100644 index aa9c981..0000000 --- a/internal/fusefrontend/xattr_notlinux.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !linux - -// Package fusefrontend interfaces directly with the go-fuse library. -package fusefrontend - -func disallowedXAttrName(attr string) bool { - return false -} -- cgit v1.2.3