Skip to content

Commit

Permalink
Merge pull request #988 from jbenet/feat/fuse-id
Browse files Browse the repository at this point in the history
set proper UID and GID on fuse filesystems
  • Loading branch information
jbenet committed Mar 30, 2015
2 parents 8a533be + 9715cab commit a768e58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion fuse/ipns/ipns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()),
}
}

Expand Down
10 changes: 9 additions & 1 deletion fuse/readonly/readonly_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a768e58

Please sign in to comment.