POSIX: check permission when removing items
This commit is contained in:
@@ -6,6 +6,9 @@ import (
|
||||
)
|
||||
|
||||
func checkPermission(entry *filer_pb.Entry, uid, gid uint32, isWrite bool) error {
|
||||
if uid == 0 || gid == 0 {
|
||||
return nil
|
||||
}
|
||||
if entry == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -15,13 +18,13 @@ func checkPermission(entry *filer_pb.Entry, uid, gid uint32, isWrite bool) error
|
||||
attr := entry.Attributes
|
||||
if attr.Uid == uid {
|
||||
if isWrite {
|
||||
if attr.FileMode&0002 > 0 {
|
||||
if attr.FileMode&0200 > 0 {
|
||||
return nil
|
||||
} else {
|
||||
return fuse.EPERM
|
||||
}
|
||||
} else {
|
||||
if attr.FileMode&0004 > 0 {
|
||||
if attr.FileMode&0400 > 0 {
|
||||
return nil
|
||||
} else {
|
||||
return fuse.EPERM
|
||||
@@ -43,13 +46,13 @@ func checkPermission(entry *filer_pb.Entry, uid, gid uint32, isWrite bool) error
|
||||
}
|
||||
} else {
|
||||
if isWrite {
|
||||
if attr.FileMode&0200 > 0 {
|
||||
if attr.FileMode&0002 > 0 {
|
||||
return nil
|
||||
} else {
|
||||
return fuse.EPERM
|
||||
}
|
||||
} else {
|
||||
if attr.FileMode&0400 > 0 {
|
||||
if attr.FileMode&0004 > 0 {
|
||||
return nil
|
||||
} else {
|
||||
return fuse.EPERM
|
||||
|
||||
Reference in New Issue
Block a user