mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 14:34:24 +08:00
set proper UID and GID on fuse filesystems
This commit is contained in:
@ -207,7 +207,11 @@ type File struct {
|
|||||||
// Attr returns the attributes of a given node.
|
// Attr returns the attributes of a given node.
|
||||||
func (d *Directory) Attr() fuse.Attr {
|
func (d *Directory) Attr() fuse.Attr {
|
||||||
log.Debug("Directory 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.
|
// Attr returns the attributes of a given node.
|
||||||
@ -221,6 +225,8 @@ func (fi *File) Attr() fuse.Attr {
|
|||||||
return fuse.Attr{
|
return fuse.Attr{
|
||||||
Mode: os.FileMode(0666),
|
Mode: os.FileMode(0666),
|
||||||
Size: uint64(size),
|
Size: uint64(size),
|
||||||
|
Uid: uint32(os.Getuid()),
|
||||||
|
Gid: uint32(os.Getgid()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,19 +92,27 @@ func (s *Node) Attr() fuse.Attr {
|
|||||||
}
|
}
|
||||||
switch s.cached.GetType() {
|
switch s.cached.GetType() {
|
||||||
case ftpb.Data_Directory:
|
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:
|
case ftpb.Data_File:
|
||||||
size := s.cached.GetFilesize()
|
size := s.cached.GetFilesize()
|
||||||
return fuse.Attr{
|
return fuse.Attr{
|
||||||
Mode: 0444,
|
Mode: 0444,
|
||||||
Size: uint64(size),
|
Size: uint64(size),
|
||||||
Blocks: uint64(len(s.Nd.Links)),
|
Blocks: uint64(len(s.Nd.Links)),
|
||||||
|
Uid: uint32(os.Getuid()),
|
||||||
|
Gid: uint32(os.Getgid()),
|
||||||
}
|
}
|
||||||
case ftpb.Data_Raw:
|
case ftpb.Data_Raw:
|
||||||
return fuse.Attr{
|
return fuse.Attr{
|
||||||
Mode: 0444,
|
Mode: 0444,
|
||||||
Size: uint64(len(s.cached.GetData())),
|
Size: uint64(len(s.cached.GetData())),
|
||||||
Blocks: uint64(len(s.Nd.Links)),
|
Blocks: uint64(len(s.Nd.Links)),
|
||||||
|
Uid: uint32(os.Getuid()),
|
||||||
|
Gid: uint32(os.Getgid()),
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user