Skip to content

Commit

Permalink
cmd/clone: set the attr should be done after checking permissions (#4745
Browse files Browse the repository at this point in the history
)
  • Loading branch information
zhijian-pro authored and SandyXSD committed Jun 19, 2024
1 parent f902cc6 commit 790db41
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/meta/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -3907,6 +3907,12 @@ func (m *dbMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string,
n.Inode = ino
n.Parent = parent
now := time.Now()

m.parseAttr(&n, attr)
if eno := m.Access(ctx, srcIno, MODE_MASK_R, attr); eno != 0 {
return eno
}

if cmode&CLONE_MODE_PRESERVE_ATTR == 0 {
n.Uid = ctx.Uid()
n.Gid = ctx.Gid()
Expand All @@ -3922,10 +3928,6 @@ func (m *dbMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string,
if n.Type == TypeFile && n.Nlink > 1 {
n.Nlink = 1
}
m.parseAttr(&n, attr)
if eno := m.Access(ctx, srcIno, MODE_MASK_R, attr); eno != 0 {
return eno
}

if top {
var pattr Attr
Expand Down

0 comments on commit 790db41

Please sign in to comment.