Leaked source code of windows server 2003
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.

163 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. cscsec.h
  5. Abstract:
  6. This module implements all security related definitions for disconnected
  7. operation of Client Side Caching
  8. Revision History:
  9. Balan Sethu Raman [SethuR] 6-October-1997
  10. Notes:
  11. --*/
  12. #ifndef _SECURITY_H_
  13. #define _SECURITY_H_
  14. // The following functions are used to store/retrieve the access rights information
  15. // for the various files/directories cached in the CSC database.
  16. // routines to initialize/teardown the access rights infrastructure in CSC
  17. extern DWORD
  18. CscInitializeSecurity(
  19. LPVOID ShadowDatabaseName);
  20. extern DWORD
  21. CscTearDownSecurity(LPSTR s);
  22. extern DWORD
  23. CscInitializeSecurityDescriptor();
  24. extern DWORD
  25. CscUninitializeSecurityDescriptor();
  26. //
  27. // The CSC access rights database is organized around SIDs. SIDs uniquely identify
  28. // an user across reboots, i.e., they are persistent.
  29. //
  30. typedef USHORT CSC_SID_INDEX, *PCSC_SID_INDEX;
  31. extern DWORD
  32. CscAddSidToDatabase(
  33. PVOID pSid,
  34. ULONG SidLength,
  35. PCSC_SID_INDEX pSidindex);
  36. extern DWORD
  37. CscRemoveSidFromDatabase(
  38. PVOID pSid,
  39. ULONG SidLength);
  40. typedef struct _CSC_SID_ACCESS_RIGHTS_ {
  41. PVOID pSid;
  42. ULONG SidLength;
  43. ULONG MaximalAccessRights;
  44. } CSC_SID_ACCESS_RIGHTS, *PCSC_SID_ACCESS_RIGHTS;
  45. extern DWORD
  46. CscAddMaximalAccessRightsForSids(
  47. HSHADOW hParent,
  48. HSHADOW hShadow,
  49. ULONG NumberOfSids,
  50. PCSC_SID_ACCESS_RIGHTS pSidAccessRights);
  51. extern DWORD
  52. CscAddMaximalAccessRightsForShare(
  53. HSERVER hServer,
  54. ULONG NumberOfSids,
  55. PCSC_SID_ACCESS_RIGHTS pSidAccessRights);
  56. extern DWORD
  57. CscRemoveMaximalAccessRightsForSid(
  58. HSHADOW hParent,
  59. HSHADOW hShadow,
  60. PVOID pSid,
  61. ULONG SidLength);
  62. //
  63. // Since there are large number of files cached for a given SID the access rights
  64. // are stored corresponding to a SID index. The SIDs are stored persistently in
  65. // a special SID mapping file in the CSC database. Currently the SIDs are
  66. // stored as an array and linear comparions are made. Since the number of SIDs
  67. // will be typically less than 10 in any given system this organization suffices.
  68. // The length of the SID is cached to facilitate quicker comparisons and avoid
  69. // recomputation using the security API's.
  70. //
  71. typedef struct _CSC_SID_ {
  72. ULONG SidLength;
  73. PVOID pSid;
  74. } CSC_SID, *PCSC_SID;
  75. typedef struct _CSC_SIDS_ {
  76. ULONG MaximumNumberOfSids;
  77. ULONG NumberOfSids;
  78. CSC_SID Sids[];
  79. } CSC_SIDS, *PCSC_SIDS;
  80. // Two special indexes are distinguished, the CSC_GUEST_SID_INDEX which is used as
  81. // the default access rights indicator when the SID does not map to a valid
  82. // index and CSC_INVALID_SID_INDEX to indicate an invalid SID mapping.
  83. //
  84. #define CSC_GUEST_SID (PVOID)(0x11111111)
  85. #define CSC_GUEST_SID_LENGTH (0x4)
  86. // Achtung !!! these should match with those in shdcom.h
  87. #define CSC_GUEST_SID_INDEX (0xfffe)
  88. #define CSC_INVALID_SID_INDEX (0x0)
  89. // Achtung !!! this should match with that in shdcom.h
  90. #define CSC_MAXIMUM_NUMBER_OF_CACHED_SID_INDEXES (0x4)
  91. #define CSC_SID_QUANTUM (0x2)
  92. extern CSC_SID_INDEX
  93. CscMapSidToIndex(
  94. PVOID pSid,
  95. ULONG SidLength);
  96. //
  97. // Currently access rights for upto four users are cached with any given file in
  98. // the CSC database. This is based upon the fact that 4 DWORDs have been allocated
  99. // for the security information in the CSC database. The file system specific
  100. // access rights are 9 bits long ( it has been rounded off to 16 bits) and 16
  101. // bits are used for the SID index. It is possible to increase this to 8 by
  102. // squeezing in the SID index to the 7 bits in the 16 bits allocated for
  103. // access rights.
  104. //
  105. #define MAXIMUM_NUMBER_OF_USERS (0x4)
  106. typedef struct _ACCESS_RIGHTS_ {
  107. CSC_SID_INDEX SidIndex;
  108. USHORT MaximalRights;
  109. } ACCESS_RIGHTS, *PACCESS_RIGHTS;
  110. typedef struct _CACHED_ACCESS_RIGHTS_ {
  111. ACCESS_RIGHTS AccessRights[MAXIMUM_NUMBER_OF_USERS];
  112. } CACHED_SECURITY_INFORMATION, *PCACHED_SECURITY_INFORMATION;
  113. //
  114. // All the global variables used in mapping/evaluating access rights are aggregated
  115. // in the CSC_SECURITY data structure. Currently it contains the sid mapping file
  116. // in the CSC database and the in memory data structure used.
  117. //
  118. typedef struct _CSC_SECURITY_ {
  119. CSCHFILE hSidMappingsFile;
  120. PCSC_SIDS pCscSids;
  121. LPVOID ShadowDatabaseName;
  122. } CSC_SECURITY, *PCSC_SECURITY;
  123. #endif
  124.