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
)
zhijian-pro authored and SandyXSD committed Jun 20, 2024
1 parent 10250b2 commit 0783284
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
@@ -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()
@@ -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

0 comments on commit 0783284

Please sign in to comment.