Skip to content

Commit

Permalink
Fix access to trash dir (#1356)
Browse files Browse the repository at this point in the history
* fix nil when access .trash

* don't allow setattr on trash files
  • Loading branch information
davies authored Jan 28, 2022
1 parent 5a5837e commit 5c6d557
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions pkg/vfs/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,10 @@ func (v *VFS) Open(ctx Context, ino Ino, flags uint32) (entry *meta.Entry, fh ui
h.data, _ = json.MarshalIndent(v.Conf, "", " ")
}
n := getInternalNode(ino)
entry = &meta.Entry{Inode: ino, Attr: n.attr}
return
if n != nil {
entry = &meta.Entry{Inode: ino, Attr: n.attr}
return
}
}
defer func() {
if entry != nil {
Expand Down
12 changes: 9 additions & 3 deletions pkg/vfs/vfs_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ func (v *VFS) Access(ctx Context, ino Ino, mask int) (err syscall.Errno) {
}
if IsSpecialNode(ino) {
node := getInternalNode(ino)
err = accessTest(node.attr, mmask, ctx.Uid(), ctx.Gid())
return
if node != nil {
err = accessTest(node.attr, mmask, ctx.Uid(), ctx.Gid())
return
}
}

err = v.Meta.Access(ctx, ino, uint8(mmask), nil)
Expand Down Expand Up @@ -144,7 +146,11 @@ func (v *VFS) SetAttr(ctx Context, ino Ino, set int, opened uint8, mode, uid, gi
}()
if IsSpecialNode(ino) {
n := getInternalNode(ino)
entry = &meta.Entry{Inode: ino, Attr: n.attr}
if n != nil {
entry = &meta.Entry{Inode: ino, Attr: n.attr}
} else {
err = syscall.EPERM
}
return
}
err = syscall.EINVAL
Expand Down

0 comments on commit 5c6d557

Please sign in to comment.