fix (nfs): nfs permissions

This commit is contained in:
MickaelK
2025-09-15 15:16:29 +10:00
parent 2888cc5f99
commit 118f17724b

View File

@ -136,20 +136,41 @@ func (this NfsShare) Meta(path string) Metadata {
if fattr == nil { // happen at the root if fattr == nil { // happen at the root
return Metadata{} return Metadata{}
} else if isIn(fattr.UID, []uint32{this.uid}) || }
isIn(fattr.GID, []uint32{this.gid}) || var (
isIn(fattr.GID, this.gids) { r, w bool
return Metadata{} perms = fattr.Mode().Perm()
)
if perms&0002 != 0 {
w = true
}
if perms&0004 != 0 {
r = true
}
if fattr.UID == this.uid {
if perms&0400 != 0 {
r = true
}
if perms&0200 != 0 {
w = true
}
}
if (fattr.GID == this.gid) || isIn(fattr.GID, this.gids) {
if perms&0040 != 0 {
r = true
}
if perms&0020 != 0 {
w = true
}
} }
return Metadata{ return Metadata{
CanSee: NewBool(false), CanSee: NewBool(r),
CanCreateFile: NewBool(false), CanCreateFile: NewBool(w),
CanCreateDirectory: NewBool(false), CanCreateDirectory: NewBool(w),
CanRename: NewBool(false), CanRename: NewBool(w),
CanMove: NewBool(false), CanMove: NewBool(w),
CanUpload: NewBool(false), CanUpload: NewBool(w),
CanDelete: NewBool(false), CanDelete: NewBool(w),
CanShare: NewBool(false),
} }
} }