cifsacl.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * fs/cifs/cifsacl.h
  3. *
  4. * Copyright (c) International Business Machines Corp., 2007
  5. * Author(s): Steve French (sfrench@us.ibm.com)
  6. *
  7. * This library is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published
  9. * by the Free Software Foundation; either version 2.1 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  15. * the GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #ifndef _CIFSACL_H
  22. #define _CIFSACL_H
  23. #define NUM_AUTHS (6) /* number of authority fields */
  24. #define SID_MAX_SUB_AUTHORITIES (15) /* max number of sub authority fields */
  25. #define READ_BIT 0x4
  26. #define WRITE_BIT 0x2
  27. #define EXEC_BIT 0x1
  28. #define UBITSHIFT 6
  29. #define GBITSHIFT 3
  30. #define ACCESS_ALLOWED 0
  31. #define ACCESS_DENIED 1
  32. #define SIDOWNER 1
  33. #define SIDGROUP 2
  34. /*
  35. * Security Descriptor length containing DACL with 3 ACEs (one each for
  36. * owner, group and world).
  37. */
  38. #define DEFAULT_SEC_DESC_LEN (sizeof(struct cifs_ntsd) + \
  39. sizeof(struct cifs_acl) + \
  40. (sizeof(struct cifs_ace) * 3))
  41. /*
  42. * Maximum size of a string representation of a SID:
  43. *
  44. * The fields are unsigned values in decimal. So:
  45. *
  46. * u8: max 3 bytes in decimal
  47. * u32: max 10 bytes in decimal
  48. *
  49. * "S-" + 3 bytes for version field + 15 for authority field + NULL terminator
  50. *
  51. * For authority field, max is when all 6 values are non-zero and it must be
  52. * represented in hex. So "-0x" + 12 hex digits.
  53. *
  54. * Add 11 bytes for each subauthority field (10 bytes each + 1 for '-')
  55. */
  56. #define SID_STRING_BASE_SIZE (2 + 3 + 15 + 1)
  57. #define SID_STRING_SUBAUTH_SIZE (11) /* size of a single subauth string */
  58. struct cifs_ntsd {
  59. __le16 revision; /* revision level */
  60. __le16 type;
  61. __le32 osidoffset;
  62. __le32 gsidoffset;
  63. __le32 sacloffset;
  64. __le32 dacloffset;
  65. } __attribute__((packed));
  66. struct cifs_sid {
  67. __u8 revision; /* revision level */
  68. __u8 num_subauth;
  69. __u8 authority[NUM_AUTHS];
  70. __le32 sub_auth[SID_MAX_SUB_AUTHORITIES]; /* sub_auth[num_subauth] */
  71. } __attribute__((packed));
  72. /* size of a struct cifs_sid, sans sub_auth array */
  73. #define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS)
  74. struct cifs_acl {
  75. __le16 revision; /* revision level */
  76. __le16 size;
  77. __le32 num_aces;
  78. } __attribute__((packed));
  79. struct cifs_ace {
  80. __u8 type;
  81. __u8 flags;
  82. __le16 size;
  83. __le32 access_req;
  84. struct cifs_sid sid; /* ie UUID of user or group who gets these perms */
  85. } __attribute__((packed));
  86. #endif /* _CIFSACL_H */