From 9715cab58d6647137828eb2f79341b49dcbafad2 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 30 Mar 2015 14:56:42 -0700 Subject: [PATCH] set proper UID and GID on fuse filesystems --- fuse/ipns/ipns_unix.go | 8 +++++++- fuse/readonly/readonly_unix.go | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index d96f2b18722..16679d9477e 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -207,7 +207,11 @@ type File struct { // Attr returns the attributes of a given node. func (d *Directory) Attr() fuse.Attr { log.Debug("Directory Attr") - return fuse.Attr{Mode: os.ModeDir | 0555} + return fuse.Attr{ + Mode: os.ModeDir | 0555, + Uid: uint32(os.Getuid()), + Gid: uint32(os.Getgid()), + } } // Attr returns the attributes of a given node. @@ -221,6 +225,8 @@ func (fi *File) Attr() fuse.Attr { return fuse.Attr{ Mode: os.FileMode(0666), Size: uint64(size), + Uid: uint32(os.Getuid()), + Gid: uint32(os.Getgid()), } } diff --git a/fuse/readonly/readonly_unix.go b/fuse/readonly/readonly_unix.go index 2fa75a7f67a..fceae117f6c 100644 --- a/fuse/readonly/readonly_unix.go +++ b/fuse/readonly/readonly_unix.go @@ -92,19 +92,27 @@ func (s *Node) Attr() fuse.Attr { } switch s.cached.GetType() { case ftpb.Data_Directory: - return fuse.Attr{Mode: os.ModeDir | 0555} + return fuse.Attr{ + Mode: os.ModeDir | 0555, + Uid: uint32(os.Getuid()), + Gid: uint32(os.Getgid()), + } case ftpb.Data_File: size := s.cached.GetFilesize() return fuse.Attr{ Mode: 0444, Size: uint64(size), Blocks: uint64(len(s.Nd.Links)), + Uid: uint32(os.Getuid()), + Gid: uint32(os.Getgid()), } case ftpb.Data_Raw: return fuse.Attr{ Mode: 0444, Size: uint64(len(s.cached.GetData())), Blocks: uint64(len(s.Nd.Links)), + Uid: uint32(os.Getuid()), + Gid: uint32(os.Getgid()), } default: