You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
966 B

  1. package filesys
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  4. "github.com/seaweedfs/fuse"
  5. )
  6. func checkPermission(entry *filer_pb.Entry, uid, gid uint32, isWrite bool) error {
  7. if entry == nil {
  8. return nil
  9. }
  10. if entry.Attributes == nil {
  11. return nil
  12. }
  13. attr := entry.Attributes
  14. if attr.Uid == uid {
  15. if isWrite {
  16. if attr.FileMode&0002 > 0 {
  17. return nil
  18. } else {
  19. return fuse.EPERM
  20. }
  21. } else {
  22. if attr.FileMode&0004 > 0 {
  23. return nil
  24. } else {
  25. return fuse.EPERM
  26. }
  27. }
  28. } else if attr.Gid == gid {
  29. if isWrite {
  30. if attr.FileMode&0020 > 0 {
  31. return nil
  32. } else {
  33. return fuse.EPERM
  34. }
  35. } else {
  36. if attr.FileMode&0040 > 0 {
  37. return nil
  38. } else {
  39. return fuse.EPERM
  40. }
  41. }
  42. } else {
  43. if isWrite {
  44. if attr.FileMode&0200 > 0 {
  45. return nil
  46. } else {
  47. return fuse.EPERM
  48. }
  49. } else {
  50. if attr.FileMode&0400 > 0 {
  51. return nil
  52. } else {
  53. return fuse.EPERM
  54. }
  55. }
  56. }
  57. }