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 Apr 22, 2024
1 parent 38ebf17 commit f553dcf
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 @@ -4023,6 +4023,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 @@ -4038,10 +4044,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 f553dcf

Please sign in to comment.