Source code of Windows XP (NT5)
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.

193 lines
3.8 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 BOOLEAN
  120. afpIsUserMemberOfGroup(
  121. IN PTOKEN_GROUPS pGroups,
  122. IN PSID pSidGroup
  123. );
  124. LOCAL ACCESS_MASK
  125. afpPermissions2NtMask(
  126. IN BYTE AfpPermissions
  127. );
  128. LOCAL PACCESS_ALLOWED_ACE
  129. afpAddAceToAcl(
  130. IN PACL pAcl,
  131. IN PACCESS_ALLOWED_ACE pAce,
  132. IN ACCESS_MASK Mask,
  133. IN PSID pSid,
  134. IN BOOLEAN fInherit
  135. );
  136. LOCAL PACCESS_ALLOWED_ACE
  137. afpMoveAces(
  138. IN PACL pOldDacl,
  139. IN PACCESS_ALLOWED_ACE pAceStart,
  140. IN PSID pSidOldOwner,
  141. IN PSID pSidNewOwner,
  142. IN PSID pSidOldGroup,
  143. IN PSID pSidNewGroup,
  144. IN BOOLEAN DenyAces,
  145. IN OUT PACL pNewDacl
  146. );
  147. #endif // _ACCESS_LOCALS
  148. #endif // _ACCESS_
  149.