@cryptotaxi247 / kubo / commits / 9715cab58

set proper UID and GID on fuse filesystems

Jeromy committed Mar 30, 2015 at 14:56 UTC 9715cab58d6647137828eb2f79341b49dcbafad2
2 files changed +16 -2
fuse/ipns/ipns_unix.go
+7 -1
@@ -207,7 +207,11 @@ type File struct {
207 // Attr returns the attributes of a given node.
208 func (d *Directory) Attr() fuse.Attr {
209 log.Debug("Directory Attr")
210 - return fuse.Attr{Mode: os.ModeDir | 0555}
210 + return fuse.Attr{
211 + Mode: os.ModeDir | 0555,
212 + Uid: uint32(os.Getuid()),
213 + Gid: uint32(os.Getgid()),
214 + }
215 }
216
217 // Attr returns the attributes of a given node.
@@ -221,6 +225,8 @@ func (fi *File) Attr() fuse.Attr {
225 return fuse.Attr{
226 Mode: os.FileMode(0666),
227 Size: uint64(size),
228 + Uid: uint32(os.Getuid()),
229 + Gid: uint32(os.Getgid()),
230 }
231 }
232
fuse/readonly/readonly_unix.go
+9 -1
@@ -92,19 +92,27 @@ func (s *Node) Attr() fuse.Attr {
92 }
93 switch s.cached.GetType() {
94 case ftpb.Data_Directory:
95 - return fuse.Attr{Mode: os.ModeDir | 0555}
95 + return fuse.Attr{
96 + Mode: os.ModeDir | 0555,
97 + Uid: uint32(os.Getuid()),
98 + Gid: uint32(os.Getgid()),
99 + }
100 case ftpb.Data_File:
101 size := s.cached.GetFilesize()
102 return fuse.Attr{
103 Mode: 0444,
104 Size: uint64(size),
105 Blocks: uint64(len(s.Nd.Links)),
106 + Uid: uint32(os.Getuid()),
107 + Gid: uint32(os.Getgid()),
108 }
109 case ftpb.Data_Raw:
110 return fuse.Attr{
111 Mode: 0444,
112 Size: uint64(len(s.cached.GetData())),
113 Blocks: uint64(len(s.Nd.Links)),
114 + Uid: uint32(os.Getuid()),
115 + Gid: uint32(os.Getgid()),
116 }
117
118 default: