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.

188 lines
3.9 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. access.h
  5. Abstract:
  6. This module contains prototypes for access related routines.
  7. Author:
  8. Jameel Hyder (microsoft!jameelh)
  9. Revision History:
  10. 20 Sep 1992 Initial Version
  11. Notes: Tab stop: 4
  12. --*/
  13. #ifndef _ACCESS_
  14. #define _ACCESS_
  15. #define AFP_READ_ACCESS (READ_CONTROL | \
  16. FILE_READ_ATTRIBUTES | \
  17. FILE_TRAVERSE | \
  18. FILE_LIST_DIRECTORY | \
  19. FILE_READ_EA)
  20. #define AFP_WRITE_ACCESS (FILE_ADD_FILE | \
  21. FILE_ADD_SUBDIRECTORY| \
  22. FILE_WRITE_ATTRIBUTES| \
  23. FILE_WRITE_EA | \
  24. DELETE)
  25. #define AFP_OWNER_ACCESS (WRITE_DAC | \
  26. WRITE_OWNER)
  27. #define AFP_MIN_ACCESS (FILE_READ_ATTRIBUTES | \
  28. READ_CONTROL)
  29. #ifdef i386
  30. #pragma warning(disable:4010)
  31. #endif
  32. GLOBAL SID AfpSidWorld EQU \
  33. { 1, 1, SECURITY_WORLD_SID_AUTHORITY, SECURITY_WORLD_RID };
  34. GLOBAL SID AfpSidSystem EQU \
  35. { 1, 1, SECURITY_NT_AUTHORITY, SECURITY_LOCAL_SYSTEM_RID };
  36. GLOBAL SID AfpSidNull EQU \
  37. { 1, 1, SECURITY_NULL_SID_AUTHORITY, SECURITY_NULL_RID };
  38. GLOBAL SID AfpSidBuiltIn EQU \
  39. { 1, 1, SECURITY_NT_AUTHORITY, SECURITY_BUILTIN_DOMAIN_RID };
  40. GLOBAL PSID AfpSidAdmins EQU NULL;
  41. GLOBAL LONG AfpSizeSidAdmins EQU 0;
  42. GLOBAL PSID AfpSidNone EQU NULL;
  43. GLOBAL LONG AfpSizeSidNone EQU 0;
  44. #ifdef OPTIMIZE_GUEST_LOGONS
  45. #ifdef INHERIT_DIRECTORY_PERMS
  46. GLOBAL DWORD AfpIdWorld EQU 0;
  47. #else
  48. GLOBAL PISECURITY_DESCRIPTOR AfpGuestSecDesc EQU NULL;
  49. #endif
  50. #endif
  51. #define AfpAccessMask2AfpPermissions(Rights, Mask, Type) \
  52. if ((Type) == ACCESS_ALLOWED_ACE_TYPE) \
  53. { \
  54. if (((Mask) & AFP_READ_ACCESS) == AFP_READ_ACCESS) \
  55. (Rights) |= (DIR_ACCESS_READ | DIR_ACCESS_SEARCH); \
  56. if (((Mask) & AFP_WRITE_ACCESS) == AFP_WRITE_ACCESS) \
  57. (Rights) |= DIR_ACCESS_WRITE; \
  58. if (((Mask) & AFP_OWNER_ACCESS) == AFP_OWNER_ACCESS) \
  59. (Rights) |= DIR_ACCESS_OWNER; \
  60. } \
  61. else \
  62. { \
  63. ASSERT((Type) == ACCESS_DENIED_ACE_TYPE); \
  64. if ((Mask) & AFP_READ_ACCESS) \
  65. (Rights) &= ~(DIR_ACCESS_READ | DIR_ACCESS_SEARCH); \
  66. if ((Mask) & AFP_WRITE_ACCESS) \
  67. (Rights) &= ~DIR_ACCESS_WRITE; \
  68. if ((Mask) & AFP_OWNER_ACCESS) \
  69. (Rights) &= ~DIR_ACCESS_OWNER; \
  70. }
  71. extern
  72. NTSTATUS
  73. AfpGetUserAndPrimaryGroupSids(
  74. IN PSDA pSda
  75. );
  76. extern
  77. AFPSTATUS
  78. AfpMakeSecurityDescriptorForUser(
  79. IN PSID OwnerSid,
  80. IN PSID GroupSid,
  81. OUT PISECURITY_DESCRIPTOR * ppSecDesc
  82. );
  83. extern
  84. AFPSTATUS
  85. AfpGetAfpPermissions(
  86. IN PSDA pSda,
  87. IN HANDLE DirHandle,
  88. IN OUT struct _FileDirParms * pFDParm
  89. );
  90. extern
  91. AFPSTATUS
  92. AfpSetAfpPermissions(
  93. IN HANDLE DirHandle,
  94. IN DWORD Bitmap,
  95. IN OUT struct _FileDirParms * pFDParm
  96. );
  97. #if DBG
  98. extern
  99. VOID
  100. AfpDumpSid(
  101. IN PBYTE pString,
  102. IN PISID pSid
  103. );
  104. extern
  105. VOID
  106. AfpDumpSidnMask(
  107. IN PBYTE pString,
  108. IN PISID pSid,
  109. IN DWORD Mask,
  110. IN UCHAR Type,
  111. IN UCHAR Flags
  112. );
  113. #else
  114. #define AfpDumpSid(pString, pSid)
  115. #define AfpDumpSidnMask(pString, pSid, Mask, Type, Flags)
  116. #endif
  117. #define ALLOC_ACCESS_MEM(x) AfpAllocNonPagedMemory(x)
  118. #ifdef _ACCESS_LOCALS
  119. LOCAL ACCESS_MASK
  120. afpPermissions2NtMask(
  121. IN BYTE AfpPermissions
  122. );
  123. LOCAL PACCESS_ALLOWED_ACE
  124. afpAddAceToAcl(
  125. IN PACL pAcl,
  126. IN PACCESS_ALLOWED_ACE pAce,
  127. IN ACCESS_MASK Mask,
  128. IN PSID pSid,
  129. IN BOOLEAN fInherit
  130. );
  131. LOCAL PACCESS_ALLOWED_ACE
  132. afpMoveAces(
  133. IN PACL pOldDacl,
  134. IN PACCESS_ALLOWED_ACE pAceStart,
  135. IN PSID pSidOldOwner,
  136. IN PSID pSidNewOwner,
  137. IN PSID pSidOldGroup,
  138. IN PSID pSidNewGroup,
  139. IN BOOLEAN DenyAces,
  140. IN BOOLEAN InheritedAces,
  141. IN OUT PACL pNewDacl
  142. );
  143. #endif // _ACCESS_LOCALS
  144. #endif // _ACCESS_