From 6013d56f0c09100190107613ce8c5c4c929216dd Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Sun, 18 Jan 2026 10:48:51 -0800 Subject: added -noxattr flag which ignores all xattr operations (#987) * added -noxattr flag which ignores all xattr operations--- internal/fusefrontend_reverse/node_xattr.go | 10 +++++++++- internal/fusefrontend_reverse/node_xattr_darwin.go | 3 +++ internal/fusefrontend_reverse/node_xattr_linux.go | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'internal/fusefrontend_reverse') diff --git a/internal/fusefrontend_reverse/node_xattr.go b/internal/fusefrontend_reverse/node_xattr.go index f4e3bda..f22764a 100644 --- a/internal/fusefrontend_reverse/node_xattr.go +++ b/internal/fusefrontend_reverse/node_xattr.go @@ -25,6 +25,10 @@ func isAcl(attr string) bool { // This function is symlink-safe through Fgetxattr. func (n *Node) Getxattr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno) { rn := n.rootNode() + // If -noxattr is enabled, return ENOATTR for all getxattr calls + if rn.args.NoXattr { + return 0, noSuchAttributeError + } var data []byte // ACLs are passed through without encryption if isAcl(attr) { @@ -56,11 +60,15 @@ func (n *Node) Getxattr(ctx context.Context, attr string, dest []byte) (uint32, // // This function is symlink-safe through Flistxattr. func (n *Node) Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Errno) { + rn := n.rootNode() + // If -noxattr is enabled, return zero results for listxattr + if rn.args.NoXattr { + return 0, 0 + } pNames, errno := n.listXAttr() if errno != 0 { return 0, errno } - rn := n.rootNode() var buf bytes.Buffer for _, pName := range pNames { // ACLs are passed through without encryption diff --git a/internal/fusefrontend_reverse/node_xattr_darwin.go b/internal/fusefrontend_reverse/node_xattr_darwin.go index f5b58d9..6816a18 100644 --- a/internal/fusefrontend_reverse/node_xattr_darwin.go +++ b/internal/fusefrontend_reverse/node_xattr_darwin.go @@ -8,6 +8,9 @@ import ( "github.com/rfjakob/gocryptfs/v2/internal/syscallcompat" ) +// On Darwin, ENOATTR is returned when an attribute is not found. +const noSuchAttributeError = syscall.ENOATTR + func (n *Node) getXAttr(cAttr string) (out []byte, errno syscall.Errno) { d, errno := n.prepareAtSyscall("") if errno != 0 { diff --git a/internal/fusefrontend_reverse/node_xattr_linux.go b/internal/fusefrontend_reverse/node_xattr_linux.go index f6d04a5..3c574f5 100644 --- a/internal/fusefrontend_reverse/node_xattr_linux.go +++ b/internal/fusefrontend_reverse/node_xattr_linux.go @@ -9,6 +9,9 @@ import ( "github.com/rfjakob/gocryptfs/v2/internal/syscallcompat" ) +// On Linux, ENODATA is returned when an attribute is not found. +const noSuchAttributeError = syscall.ENODATA + func (n *Node) getXAttr(cAttr string) (out []byte, errno syscall.Errno) { d, errno := n.prepareAtSyscall("") if errno != 0 { -- cgit v1.2.3