cifsacl.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 '-') + 11 bytes for each subauthority field (10 bytes
  47. * per number + 1 for '-') + NULL terminator.
  48. */
  49. #define SID_STRING_MAX (195)
  50. #define SID_ID_MAPPED 0
  51. #define SID_ID_PENDING 1
  52. #define SID_MAP_EXPIRE (3600 * HZ) /* map entry expires after one hour */
  53. #define SID_MAP_RETRY (300 * HZ) /* wait 5 minutes for next attempt to map */
  54. struct cifs_ntsd {
  55. __le16 revision; /* revision level */
  56. __le16 type;
  57. __le32 osidoffset;
  58. __le32 gsidoffset;
  59. __le32 sacloffset;
  60. __le32 dacloffset;
  61. } __attribute__((packed));
  62. struct cifs_sid {
  63. __u8 revision; /* revision level */
  64. __u8 num_subauth;
  65. __u8 authority[NUM_AUTHS];
  66. __le32 sub_auth[SID_MAX_SUB_AUTHORITIES]; /* sub_auth[num_subauth] */
  67. } __attribute__((packed));
  68. /* size of a struct cifs_sid, sans sub_auth array */
  69. #define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS)
  70. struct cifs_acl {
  71. __le16 revision; /* revision level */
  72. __le16 size;
  73. __le32 num_aces;
  74. } __attribute__((packed));
  75. struct cifs_ace {
  76. __u8 type;
  77. __u8 flags;
  78. __le16 size;
  79. __le32 access_req;
  80. struct cifs_sid sid; /* ie UUID of user or group who gets these perms */
  81. } __attribute__((packed));
  82. struct cifs_wksid {
  83. struct cifs_sid cifssid;
  84. char sidname[SIDNAMELENGTH];
  85. } __attribute__((packed));
  86. struct cifs_sid_id {
  87. unsigned int refcount; /* increment with spinlock, decrement without */
  88. unsigned long id;
  89. unsigned long time;
  90. unsigned long state;
  91. char *sidstr;
  92. struct rb_node rbnode;
  93. struct cifs_sid sid;
  94. };
  95. #endif /* _CIFSACL_H */