Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/clone: set the attr should be done after checking permissions
Browse files Browse the repository at this point in the history
zhijian-pro committed Apr 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8dc1781 commit 43cb95c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/meta/sql.go
Original file line number Diff line number Diff line change
@@ -4023,6 +4023,16 @@ func (m *dbMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string,
n.Inode = ino
n.Parent = parent
now := time.Now()

// TODO: preserve hardlink
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 cmode&CLONE_MODE_PRESERVE_ATTR == 0 {
n.Uid = ctx.Uid()
n.Gid = ctx.Gid()
@@ -4034,14 +4044,6 @@ func (m *dbMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string,
n.Mtimensec = int16(now.UnixNano() % 1e3)
n.Ctimensec = int16(now.UnixNano() % 1e3)
}
// TODO: preserve hardlink
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 43cb95c

Please sign in to comment.