@@ -32,6 +32,10 @@ func isAcl(attr string) bool {
3232// This function is symlink-safe through Fgetxattr.
3333func (n * Node ) Getxattr (ctx context.Context , attr string , dest []byte ) (uint32 , syscall.Errno ) {
3434 rn := n .rootNode ()
35+ // If -noxattr is enabled, return ENOATTR for all getxattr calls
36+ if rn .args .NoXattr {
37+ return 0 , noSuchAttributeError
38+ }
3539 // If we are not mounted with -suid, reading the capability xattr does not
3640 // make a lot of sense, so reject the request and gain a massive speedup.
3741 // See https://github.com/rfjakob/gocryptfs/issues/515 .
@@ -77,6 +81,10 @@ func (n *Node) Getxattr(ctx context.Context, attr string, dest []byte) (uint32,
7781// This function is symlink-safe through Fsetxattr.
7882func (n * Node ) Setxattr (ctx context.Context , attr string , data []byte , flags uint32 ) syscall.Errno {
7983 rn := n .rootNode ()
84+ // If -noxattr is enabled, fail all setxattr calls
85+ if rn .args .NoXattr {
86+ return syscall .EOPNOTSUPP
87+ }
8088 flags = uint32 (filterXattrSetFlags (int (flags )))
8189
8290 // ACLs are passed through without encryption
@@ -102,6 +110,10 @@ func (n *Node) Setxattr(ctx context.Context, attr string, data []byte, flags uin
102110// This function is symlink-safe through Fremovexattr.
103111func (n * Node ) Removexattr (ctx context.Context , attr string ) syscall.Errno {
104112 rn := n .rootNode ()
113+ // If -noxattr is enabled, fail all removexattr calls
114+ if rn .args .NoXattr {
115+ return syscall .EOPNOTSUPP
116+ }
105117
106118 // ACLs are passed through without encryption
107119 if isAcl (attr ) {
@@ -119,11 +131,15 @@ func (n *Node) Removexattr(ctx context.Context, attr string) syscall.Errno {
119131//
120132// This function is symlink-safe through Flistxattr.
121133func (n * Node ) Listxattr (ctx context.Context , dest []byte ) (uint32 , syscall.Errno ) {
134+ rn := n .rootNode ()
135+ // If -noxattr is enabled, return zero results for listxattr
136+ if rn .args .NoXattr {
137+ return 0 , 0
138+ }
122139 cNames , errno := n .listXAttr ()
123140 if errno != 0 {
124141 return 0 , errno
125142 }
126- rn := n .rootNode ()
127143 var buf bytes.Buffer
128144 for _ , curName := range cNames {
129145 // ACLs are passed through without encryption
0 commit comments