cifsacl.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 NUM_WK_SIDS 7 /* number of well known sids */
  26. #define SIDNAMELENGTH 20 /* long enough for the ones we care about */
  27. #define DEFSECDESCLEN 192 /* sec desc len contaiting a dacl with three aces */
  28. #define READ_BIT 0x4
  29. #define WRITE_BIT 0x2
  30. #define EXEC_BIT 0x1
  31. #define UBITSHIFT 6
  32. #define GBITSHIFT 3
  33. #define ACCESS_ALLOWED 0
  34. #define ACCESS_DENIED 1
  35. #define SIDOWNER 1
  36. #define SIDGROUP 2
  37. /*
  38. * Maximum size of a string representation of a SID:
  39. *
  40. * The fields are unsigned values in decimal. So:
  41. *
  42. * u8: max 3 bytes in decimal
  43. * u32: max 10 bytes in decimal
  44. *
  45. * "S-" + 3 bytes for version field + 4 bytes for each authority field (3 bytes
  46. * per number + 1 for '-') + NULL terminator.
  47. *
  48. * Add 11 bytes for each subauthority field (10 bytes each + 1 for '-')
  49. */
  50. #define SID_STRING_BASE_SIZE (2 + 3 + (4 * NUM_AUTHS) + 1)
  51. #define SID_STRING_SUBAUTH_SIZE (11) /* size of a single subauth string */
  52. struct cifs_ntsd {
  53. __le16 revision; /* revision level */
  54. __le16 type;
  55. __le32 osidoffset;
  56. __le32 gsidoffset;
  57. __le32 sacloffset;
  58. __le32 dacloffset;
  59. } __attribute__((packed));
  60. struct cifs_sid {
  61. __u8 revision; /* revision level */
  62. __u8 num_subauth;
  63. __u8 authority[NUM_AUTHS];
  64. __le32 sub_auth[SID_MAX_SUB_AUTHORITIES]; /* sub_auth[num_subauth] */
  65. } __attribute__((packed));
  66. /* size of a struct cifs_sid, sans sub_auth array */
  67. #define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS)
  68. struct cifs_acl {
  69. __le16 revision; /* revision level */
  70. __le16 size;
  71. __le32 num_aces;
  72. } __attribute__((packed));
  73. struct cifs_ace {
  74. __u8 type;
  75. __u8 flags;
  76. __le16 size;
  77. __le32 access_req;
  78. struct cifs_sid sid; /* ie UUID of user or group who gets these perms */
  79. } __attribute__((packed));
  80. #endif /* _CIFSACL_H */