Skip to content

Commit c9e4e4f

Browse files
valeriangalliatrfjakob
authored andcommitted
Fix reverse gocryptfs.conf access on macOS
Unlike the FUSE implementation on Linux, macFUSE doesn't cache the file attributes from the `LOOKUP` call, so it calls `GETATTR` prior to accessing a file. In the case of the `VirtualConfNode` (reverse config file passthrough), this resulted in the default `GETATTR` implementation returning an empty result, ultimately resulting in a "permission denied" error. 14:44:14.095207 rx 3: GETATTR n2 14:44:14.095229 tx 3: OK, {tA=1s {M0100000 SZ=0 L=0 0:0 0 0:8954996 A 0.000000 M 0.000000 C 0.000000}} 14:44:14.099943 rx 4: ACCESS n2 {u=501 g=20 r} 14:44:14.099990 tx 4: 13=permission denied By impementing `Getattr` (from `fs.NodeGetattrer`) on `VirtualConfNode` this solves the issue.
1 parent ad2904f commit c9e4e4f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/fusefrontend_reverse/virtualconf.go

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
)
1111

1212
var _ = (fs.NodeOpener)((*VirtualConfNode)(nil))
13+
var _ = (fs.NodeGetattrer)((*VirtualConfNode)(nil))
1314

1415
type VirtualConfNode struct {
1516
fs.Inode
@@ -27,6 +28,17 @@ func (n *VirtualConfNode) Open(ctx context.Context, flags uint32) (fh fs.FileHan
2728
return
2829
}
2930

31+
func (n *VirtualConfNode) Getattr(ctx context.Context, fh fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
32+
var st syscall.Stat_t
33+
err := syscall.Stat(n.path, &st)
34+
if err != nil {
35+
return fs.ToErrno(err)
36+
}
37+
out.FromStat(&st)
38+
return 0
39+
}
40+
41+
3042
// Check that we have implemented the fs.File* interfaces
3143
var _ = (fs.FileReader)((*VirtualConfFile)(nil))
3244
var _ = (fs.FileReleaser)((*VirtualConfFile)(nil))

0 commit comments

Comments
 (0)