commit 90ec08d4677d4739a49f018cc1947480c46f7000
parent 1ddfb8c5a9a4b934f88201f52f6eb780ee09c12c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 3 Jan 2024 12:31:27 +0900
use isGroupLeader in wstat permission check
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/server.go b/server.go
@@ -1097,6 +1097,7 @@ func sWStat(ctx context.Context, c *conn, rc <-chan *request) {
newStat.Name = wstat.Name
}
if wstat.Length != ^int64(0) && wstat.Length != newStat.Length {
+ // TODO: deal with wstat which changes directory length to 0
if fi.IsDir() || !hasPerm(c.s.fs, fi, r.fid.uid, AWRITE) {
r.err = ErrPerm
goto resp
@@ -1105,7 +1106,7 @@ func sWStat(ctx context.Context, c *conn, rc <-chan *request) {
}
if wstat.Mode != FileMode(^uint32(0)) && wstat.Mode != newStat.Mode {
// the owner of the file or the group leader of the file'c group.
- if r.fid.uid != newStat.Uid && r.fid.uid != newStat.Gid {
+ if r.fid.uid != newStat.Uid && !isGroupLeader(c.s.fs, newStat.Gid, r.fid.uid) {
r.err = ErrPerm
goto resp
}
@@ -1117,7 +1118,7 @@ func sWStat(ctx context.Context, c *conn, rc <-chan *request) {
}
if wstat.Mtime != ^uint32(0) && wstat.Mtime != newStat.Mtime {
// the owner of the file or the group leader of the file'c group.
- if r.fid.uid != newStat.Uid && r.fid.uid != newStat.Gid {
+ if r.fid.uid != newStat.Uid && !isGroupLeader(c.s.fs, newStat.Gid, r.fid.uid) {
r.err = ErrPerm
goto resp
}
@@ -1142,6 +1143,7 @@ func sWStat(ctx context.Context, c *conn, rc <-chan *request) {
goto resp
}
r.ofcall = &RWStat{}
+ // TODO: update r.fid.path
resp:
if r.err != nil {
setError(r, r.err)