SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
POSIX: check deletion permission
chrisluf2847f1266fc
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.goindex 53633b2f1b..be140e8df5 100644--- a/weed/filesys/dir.go+++ b/weed/filesys/dir.go@@ -424,6 +424,10 @@ func findFileType(mode uint16) fuse.DirentType {func (dir *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) error {+ if err := checkPermission(dir.entry, req.Uid, req.Gid, true); err != nil {+ return err+ }+if !req.Dir {return dir.removeOneFile(req)}diff --git a/weed/filesys/permission.go b/weed/filesys/permission.gonew file mode 100644index 0000000000..a8c4cd891e--- /dev/null+++ b/weed/filesys/permission.go@@ -0,0 +1,60 @@+package filesys++import (+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"+ "github.com/seaweedfs/fuse"+)++func checkPermission(entry *filer_pb.Entry, uid, gid uint32, isWrite bool) error {+ if entry == nil {+ return nil+ }+ if entry.Attributes == nil {+ return nil+ }+ attr := entry.Attributes+ if attr.Uid == uid {+ if isWrite {+ if attr.FileMode&0002 > 0 {+ return nil+ } else {+ return fuse.EPERM+ }+ } else {+ if attr.FileMode&0004 > 0 {+ return nil+ } else {+ return fuse.EPERM+ }+ }+ } else if attr.Gid == gid {+ if isWrite {+ if attr.FileMode&0020 > 0 {+ return nil+ } else {+ return fuse.EPERM+ }+ } else {+ if attr.FileMode&0040 > 0 {+ return nil+ } else {+ return fuse.EPERM+ }+ }+ } else {+ if isWrite {+ if attr.FileMode&0200 > 0 {+ return nil+ } else {+ return fuse.EPERM+ }+ } else {+ if attr.FileMode&0400 > 0 {+ return nil+ } else {+ return fuse.EPERM+ }+ }+ }++}