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.

1162 lines
29 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. authzp.h
  5. Abstract:
  6. Internal header file for authorization APIs.
  7. Author:
  8. Kedar Dubhashi - March 2000
  9. Environment:
  10. User mode only.
  11. Revision History:
  12. Created - March 2000
  13. --*/
  14. #ifndef __AUTHZP_H__
  15. #define __AUTHZP_H__
  16. #define _AUTHZ_
  17. #include <authz.h>
  18. #include <authzi.h>
  19. #if 0
  20. #define AUTHZ_DEBUG
  21. #define AUTHZ_DEBUG_QUEUE
  22. #define AUTHZ_DEBUG_MEMLEAK
  23. #else
  24. #define AUTHZ_PARAM_CHECK
  25. #define AUTHZ_AUDIT_COUNTER
  26. #endif
  27. #define AuthzpCloseHandleNonNull(h) if (NULL != (h)) { AuthzpCloseHandle((h)); }
  28. #define AuthzpCloseHandle(h) CloseHandle((h))
  29. //
  30. // Size of the local stack buffer used to save a kernel call as well as a memory
  31. // allocation.
  32. //
  33. #define AUTHZ_MAX_STACK_BUFFER_SIZE 1024
  34. #ifndef AUTHZ_DEBUG_MEMLEAK
  35. #define AuthzpAlloc(s) LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, (s))
  36. #define AuthzpFree(p) LocalFree((p))
  37. #else
  38. //
  39. // This is to be used for debugging memory leaks. Primitive method but works in
  40. // a small project like this.
  41. //
  42. PVOID
  43. AuthzpAlloc(IN DWORD Size);
  44. VOID
  45. AuthzpFree(PVOID l);
  46. #endif
  47. //
  48. // Given two sids and length of the first sid, compare the two sids.
  49. //
  50. #define AUTHZ_EQUAL_SID(s, d, l) ((*((DWORD*) s) == *((DWORD*) d)) && (RtlEqualMemory((s), (d), (l))))
  51. //
  52. // Compares a given sids with a well known constant PrincipalSelfSid.
  53. //
  54. #define AUTHZ_IS_PRINCIPAL_SELF_SID(s) (RtlEqualMemory(pAuthzPrincipalSelfSid, (s), 12))
  55. //
  56. // The client context is restricted if the restricted sid and attribute array is
  57. // present.
  58. //
  59. #define AUTHZ_TOKEN_RESTRICTED(t) (NULL != (t)->RestrictedSids)
  60. //
  61. // Two privileges are inportant for access check:
  62. // SeSecurityPrivilege
  63. // SeTakeOwnershipPrivilege
  64. // Both these are detected at the time of client context capture from token
  65. // and stored in the flags.
  66. //
  67. #define AUTHZ_PRIVILEGE_CHECK(t, f) (FLAG_ON((t)->Flags, (f)))
  68. //
  69. // Flags in the cached handle.
  70. //
  71. #define AUTHZ_DENY_ACE_PRESENT 0x00000001
  72. #define AUTHZ_PRINCIPAL_SELF_ACE_PRESENT 0x00000002
  73. #define AUTHZ_DYNAMIC_ALLOW_ACE_PRESENT 0x00000004
  74. #define AUTHZ_DYNAMIC_DENY_ACE_PRESENT 0x00000008
  75. #define AUTHZ_DYNAMIC_EVALUATION_PRESENT (AUTHZ_PRINCIPAL_SELF_ACE_PRESENT | \
  76. AUTHZ_DYNAMIC_ALLOW_ACE_PRESENT | \
  77. AUTHZ_DYNAMIC_DENY_ACE_PRESENT)
  78. //
  79. // There are only two valid attributes from access check point of view
  80. // SE_GROUP_ENABLED
  81. // SE_GROUP_USE_FOR_DENY_ONLY
  82. //
  83. #define AUTHZ_VALID_SID_ATTRIBUTES (SE_GROUP_ENABLED | SE_GROUP_USE_FOR_DENY_ONLY)
  84. #ifdef FLAG_ON
  85. #undef FLAG_ON
  86. #endif
  87. #define FLAG_ON(f, b) (0 != ((f) & (b)))
  88. #ifdef AUTHZ_NON_NULL_PTR
  89. #undef AUTHZ_NON_NULL_PTR
  90. #endif
  91. #define AUTHZ_NON_NULL_PTR(f) (NULL != (f))
  92. //
  93. // If the pointer is not null then free it. This will save us a function call in
  94. // cases when the pointer is null. Note that LocalFree would also take care null
  95. // pointer being freed.
  96. //
  97. #define AuthzpFreeNonNull(p) if (NULL != (p)) { AuthzpFree((p)); }
  98. //
  99. // Check to see if the memory allocation failed.
  100. //
  101. #define AUTHZ_ALLOCATION_FAILED(p) (NULL == (p))
  102. //
  103. // Macros to traverse the acl.
  104. // The first one gets the first ace in a given acl.
  105. // The second one gives the next ace given the current one.
  106. //
  107. #define FirstAce(Acl) ((PVOID)((PUCHAR)(Acl) + sizeof(ACL)))
  108. #define NextAce(Ace) ((PVOID)((PUCHAR)(Ace) + ((PACE_HEADER)(Ace))->AceSize))
  109. //
  110. // These do not need to be defined now since the decision was to put the burden
  111. // on the resource managers. There are disadvantages of making it thread safe.
  112. // Our choices are:
  113. // 1. Have exactly one lock in authz.dll and suffer heavy contention.
  114. // 2. Define one lock per client context which might be too expensive in
  115. // cases where the clients are too many.
  116. // 3. Let the resource manager decide whether they need locking - unlikely
  117. // that locks are needed since it is wrong design on part of the RM to
  118. // have one thread that changes the client context while the other one
  119. // is doing an access check.
  120. //
  121. #define AuthzpAcquireClientContextWriteLock(c)
  122. #define AuthzpAcquireClientContextReadLock(c)
  123. #define AuthzpReleaseClientContextLock(c)
  124. #define AuthzpAcquireClientCacheWriteLock(c)
  125. #define AuthzpReleaseClientCacheLock(c)
  126. #define AuthzpZeroMemory(p, s) RtlZeroMemory((p), (s))
  127. #define AuthzObjectAceSid(Ace) \
  128. ((PSID)(((PUCHAR)&(((PKNOWN_OBJECT_ACE)(Ace))->SidStart)) + \
  129. (RtlObjectAceObjectTypePresent(Ace) ? sizeof(GUID) : 0 ) + \
  130. (RtlObjectAceInheritedObjectTypePresent(Ace) ? sizeof(GUID) : 0 )))
  131. #define AuthzAceSid(Ace) ((PSID)&((PKNOWN_ACE)Ace)->SidStart)
  132. #define AuthzCallbackAceSid(Ace) AuthzAceSid(Ace)
  133. #define AuthzCallbackObjectAceSid(Ace) AuthzObjectAceSid(Ace)
  134. //
  135. // Internal structure of the object type list.
  136. //
  137. // Level - Level of the element in the tree. The level of the root is 0.
  138. // Flags - To be used for auditing. The valid ones are
  139. // AUTHZ_OBJECT_SUCCESS_AUDIT
  140. // AUTHZ_OBJECT_FAILURE_AUDIT
  141. // ObjectType - Pointer to the guid for this element.
  142. // ParentIndex - The index of the parent of this element in the array. The
  143. // parent index for the root is -1.
  144. // Remaining - Remaining access bits for this element, used during normal access
  145. // check algorithm.
  146. // CurrentGranted - Granted access bits so far for this element, used during
  147. // maximum allowed access check.
  148. // CurrentDenied - Explicitly denied access bits for this element, used during
  149. // maximum allowed access check.
  150. //
  151. typedef struct _IOBJECT_TYPE_LIST {
  152. USHORT Level;
  153. USHORT Flags;
  154. #define AUTHZ_OBJECT_SUCCESS_AUDIT 0x1
  155. #define AUTHZ_OBJECT_FAILURE_AUDIT 0x2
  156. GUID ObjectType;
  157. LONG ParentIndex;
  158. ACCESS_MASK Remaining;
  159. ACCESS_MASK CurrentGranted;
  160. ACCESS_MASK CurrentDenied;
  161. } IOBJECT_TYPE_LIST, *PIOBJECT_TYPE_LIST;
  162. typedef struct _AUTHZI_AUDIT_QUEUE
  163. {
  164. //
  165. // Flags defined in authz.h
  166. //
  167. DWORD Flags;
  168. //
  169. // High and low marks for the auditing queue
  170. //
  171. DWORD dwAuditQueueHigh;
  172. DWORD dwAuditQueueLow;
  173. //
  174. // CS for locking the audit queue
  175. //
  176. RTL_CRITICAL_SECTION AuthzAuditQueueLock;
  177. //
  178. // The audit queue and length.
  179. //
  180. LIST_ENTRY AuthzAuditQueue;
  181. ULONG AuthzAuditQueueLength;
  182. //
  183. // Handle to the thread that maintains the audit queue.
  184. //
  185. HANDLE hAuthzAuditThread;
  186. //
  187. // This event signals that an audit was placed on the queue.
  188. //
  189. HANDLE hAuthzAuditAddedEvent;
  190. //
  191. // This event signals that the queue is empty. Initially signalled.
  192. //
  193. HANDLE hAuthzAuditQueueEmptyEvent;
  194. //
  195. // This boolean indicates that the queue size has reached the RM-specified high water mark.
  196. //
  197. BOOL bAuthzAuditQueueHighEvent;
  198. //
  199. // This event signals that the queue size is at or below the RM-specified low water mark.
  200. //
  201. HANDLE hAuthzAuditQueueLowEvent;
  202. //
  203. // This boolean is set to TRUE during the life of the resource manager. When it turns to FALSE, the
  204. // dequeue thread knows that it should exit.
  205. //
  206. BOOL bWorker;
  207. } AUTHZI_AUDIT_QUEUE, *PAUTHZI_AUDIT_QUEUE;
  208. typedef struct _AUTHZI_RESOURCE_MANAGER
  209. {
  210. //
  211. // No valid flags have been defined yet.
  212. //
  213. DWORD Flags;
  214. //
  215. // Callback function registered by AuthzRegisterRMAccessCheckCallback, to be
  216. // used to interpret callback aces. If no such function is registered by the
  217. // RM then the default behavior is to return TRUE for a deny ACE, FALSE for
  218. // a grant ACE.
  219. //
  220. PFN_AUTHZ_DYNAMIC_ACCESS_CHECK pfnDynamicAccessCheck;
  221. //
  222. // Callback function registered by AuthzRegisterDynamicGroupsCallback, to be
  223. // used to compute groups to be added to the client context. If no such
  224. // function is registered by the RM then the default behavior is to return
  225. // no groups.
  226. //
  227. PFN_AUTHZ_COMPUTE_DYNAMIC_GROUPS pfnComputeDynamicGroups;
  228. //
  229. // Callback function registered by AuthzRegisterDynamicGroupsCallback, to be
  230. // used to free memory allocated by ComputeDynamicGroupsFn.
  231. //
  232. PFN_AUTHZ_FREE_DYNAMIC_GROUPS pfnFreeDynamicGroups;
  233. //
  234. // String name of resource manager. Appears in audits.
  235. //
  236. PWSTR szResourceManagerName;
  237. //
  238. // The user SID and Authentication ID of the RM process
  239. //
  240. PSID pUserSID;
  241. LUID AuthID;
  242. //
  243. // Default queue and audit events for the RM
  244. //
  245. #define AUTHZP_DEFAULT_RM_EVENTS 0x2
  246. AUTHZ_AUDIT_EVENT_TYPE_HANDLE hAET;
  247. AUTHZ_AUDIT_EVENT_TYPE_HANDLE hAETDS;
  248. AUTHZ_AUDIT_QUEUE_HANDLE hAuditQueue;
  249. } AUTHZI_RESOURCE_MANAGER, *PAUTHZI_RESOURCE_MANAGER;
  250. typedef struct _AUTHZI_CLIENT_CONTEXT AUTHZI_CLIENT_CONTEXT, *PAUTHZI_CLIENT_CONTEXT;
  251. typedef struct _AUTHZI_HANDLE AUTHZI_HANDLE, *PAUTHZI_HANDLE;
  252. //
  253. // the number of sids that we hash is equal to
  254. // the number of bits in AUTHZI_SID_HASH_ENTRY
  255. //
  256. #ifdef _WIN64_
  257. typedef ULONGLONG AUTHZI_SID_HASH_ENTRY, *PAUTHZI_SID_HASH_ENTRY;
  258. #else
  259. typedef DWORD AUTHZI_SID_HASH_ENTRY, *PAUTHZI_SID_HASH_ENTRY;
  260. #endif
  261. #define AUTHZI_SID_HASH_ENTRY_NUM_BITS (8*sizeof(AUTHZI_SID_HASH_ENTRY))
  262. //
  263. // the hash size is not related to the number of bits. it is the size
  264. // required to hold two 16 element arrays
  265. //
  266. #define AUTHZI_SID_HASH_SIZE 32
  267. struct _AUTHZI_CLIENT_CONTEXT
  268. {
  269. //
  270. // The client context structure is recursive to support delegated clients.
  271. // Not in the picture yet though.
  272. //
  273. PAUTHZI_CLIENT_CONTEXT Server;
  274. //
  275. // Context will always be created with Revision of AUTHZ_CURRENT_CONTEXT_REVISION.
  276. //
  277. #define AUTHZ_CURRENT_CONTEXT_REVISION 1
  278. DWORD Revision;
  279. //
  280. // Resource manager supplied identifier. We do not ever use this.
  281. //
  282. LUID Identifier;
  283. //
  284. // AuthenticationId captured from the token of the client. Needed for
  285. // auditing.
  286. //
  287. LUID AuthenticationId;
  288. //
  289. // Token expiration time. This one will be checked at the time of access check against
  290. // the current time.
  291. //
  292. LARGE_INTEGER ExpirationTime;
  293. //
  294. // Internal flags for the token.
  295. //
  296. #define AUTHZ_TAKE_OWNERSHIP_PRIVILEGE_ENABLED 0x00000001
  297. #define AUTHZ_SECURITY_PRIVILEGE_ENABLED 0x00000002
  298. DWORD Flags;
  299. //
  300. // Sids used for normal access checks.
  301. //
  302. DWORD SidCount;
  303. DWORD SidLength;
  304. PSID_AND_ATTRIBUTES Sids;
  305. AUTHZI_SID_HASH_ENTRY SidHash[AUTHZI_SID_HASH_SIZE];
  306. //
  307. // Sids used if the token is resticted. These will usually be 0 and NULL respectively.
  308. //
  309. DWORD RestrictedSidCount;
  310. DWORD RestrictedSidLength;
  311. PSID_AND_ATTRIBUTES RestrictedSids;
  312. AUTHZI_SID_HASH_ENTRY RestrictedSidHash[AUTHZI_SID_HASH_SIZE];
  313. //
  314. // Privileges used in access checks. Relevant ones are:
  315. // 1. SeSecurityPrivilege
  316. // 2. SeTakeOwnershipPrivilege
  317. // If there are no privileges associated with the client context then the PrivilegeCount = 0
  318. // and Privileges = NULL
  319. //
  320. DWORD PrivilegeCount;
  321. DWORD PrivilegeLength;
  322. PLUID_AND_ATTRIBUTES Privileges;
  323. //
  324. // Handles open for this client. When the client context is destroyed all the handles are
  325. // cleaned up.
  326. //
  327. PAUTHZI_HANDLE AuthzHandleHead;
  328. //
  329. // Pointer to the resource manager, needed to retrieve static auditing information.
  330. //
  331. PAUTHZI_RESOURCE_MANAGER pResourceManager;
  332. };
  333. struct _AUTHZI_HANDLE
  334. {
  335. //
  336. // Pointers to the next handle maintained by the AuthzClientContext object.
  337. //
  338. PAUTHZI_HANDLE next;
  339. //
  340. // Pointer to the security descriptors provided by the RM at the time of first access
  341. // check call. We do not make a copy of the security descriptors. The assumption
  342. // is that the SDs will be valid at least as long as the the handle is open.
  343. //
  344. PSECURITY_DESCRIPTOR pSecurityDescriptor;
  345. PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray;
  346. DWORD OptionalSecurityDescriptorCount;
  347. //
  348. // Flags for internal usage only.
  349. //
  350. DWORD Flags;
  351. //
  352. // Back pointer to the client context that created this handle, required if the static
  353. // access granted is insufficient and access check needs to be performed again.
  354. //
  355. PAUTHZI_CLIENT_CONTEXT pAuthzClientContext;
  356. //
  357. // Results of the maximum allowed static access.
  358. //
  359. DWORD ResultListLength;
  360. ACCESS_MASK GrantedAccessMask[ANYSIZE_ARRAY];
  361. };
  362. //
  363. // This structure stores per access audit information. The structure
  364. // is opaque and initialized with AuthzInitAuditInfo
  365. //
  366. typedef struct _AUTHZI_AUDIT_EVENT
  367. {
  368. //
  369. // size of allocated blob for this structure
  370. //
  371. DWORD dwSize;
  372. //
  373. // Flags are specified in authz.h, and this single private flag for DS callers.
  374. //
  375. DWORD Flags;
  376. //
  377. // AuditParams used for audit if available. If no AuditParams is available
  378. // and the audit id is SE_AUDITID_OBJECT_OPERATION then Authz will construct a
  379. // suitable structure.
  380. //
  381. PAUDIT_PARAMS pAuditParams;
  382. //
  383. // Structure defining the Audit Event category and id
  384. //
  385. AUTHZ_AUDIT_EVENT_TYPE_HANDLE hAET;
  386. //
  387. // millisecond timeout value
  388. //
  389. DWORD dwTimeOut;
  390. //
  391. // RM specified strings describing this event.
  392. //
  393. PWSTR szOperationType;
  394. PWSTR szObjectType;
  395. PWSTR szObjectName;
  396. PWSTR szAdditionalInfo;
  397. AUTHZ_AUDIT_QUEUE_HANDLE hAuditQueue;
  398. } AUTHZI_AUDIT_EVENT, *PAUTHZI_AUDIT_EVENT;
  399. //
  400. // structure to maintain queue of audits to be sent to LSA
  401. //
  402. typedef struct _AUTHZ_AUDIT_QUEUE_ENTRY
  403. {
  404. LIST_ENTRY list;
  405. PAUTHZ_AUDIT_EVENT_TYPE_OLD pAAETO;
  406. DWORD Flags;
  407. AUDIT_PARAMS * pAuditParams;
  408. PVOID pReserved;
  409. } AUTHZ_AUDIT_QUEUE_ENTRY, *PAUTHZ_AUDIT_QUEUE_ENTRY;
  410. //
  411. // Enumeration type to be used to specify what type of coloring should be
  412. // passed on to the rest of the tree starting at a given node.
  413. // Deny gets propagted down the entire subtree as well as to all the
  414. // ancestors (but NOT to siblings and below)
  415. // Grants get propagated down the subtree. When a grant exists on all the
  416. // siblings the parent automatically gets it.
  417. // Remaining is propagated downwards. The remaining on the parent is a
  418. // logical OR of the remaining bits on all the children.
  419. //
  420. typedef enum {
  421. AuthzUpdateRemaining = 1,
  422. AuthzUpdateCurrentGranted,
  423. AuthzUpdateCurrentDenied
  424. } ACCESS_MASK_FIELD_TO_UPDATE;
  425. //
  426. // Enumeration type to be used to specify the kind of well known sid for context
  427. // changes. We are not going to support these unless we get a requirement.
  428. //
  429. typedef enum _AUTHZ_WELL_KNOWN_SID_TYPE
  430. {
  431. AuthzWorldSid = 1,
  432. AuthzUserSid,
  433. AuthzAdminSid,
  434. AuthzDomainAdminSid,
  435. AuthzAuthenticatedUsersSid,
  436. AuthzSystemSid
  437. } AUTHZ_WELL_KNOWN_SID_TYPE;
  438. BOOL
  439. AuthzpVerifyAccessCheckArguments(
  440. IN PAUTHZI_CLIENT_CONTEXT pCC,
  441. IN PAUTHZ_ACCESS_REQUEST pRequest,
  442. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  443. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  444. IN DWORD OptionalSecurityDescriptorCount,
  445. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  446. IN OUT PAUTHZ_ACCESS_CHECK_RESULTS_HANDLE phAccessCheckResults OPTIONAL
  447. );
  448. BOOL
  449. AuthzpVerifyOpenObjectArguments(
  450. IN PAUTHZI_CLIENT_CONTEXT pCC,
  451. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  452. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  453. IN DWORD OptionalSecurityDescriptorCount,
  454. IN PAUTHZI_AUDIT_EVENT pAuditEvent
  455. );
  456. BOOL
  457. AuthzpCaptureObjectTypeList(
  458. IN POBJECT_TYPE_LIST ObjectTypeList,
  459. IN DWORD ObjectTypeLocalTypeListLength,
  460. OUT PIOBJECT_TYPE_LIST *CapturedObjectTypeList,
  461. OUT PIOBJECT_TYPE_LIST *CapturedCachingObjectTypeList OPTIONAL
  462. );
  463. VOID
  464. AuthzpFillReplyStructure(
  465. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  466. IN DWORD Error,
  467. IN ACCESS_MASK GrantedAccess
  468. );
  469. BOOL
  470. AuthzpMaximumAllowedAccessCheck(
  471. IN PAUTHZI_CLIENT_CONTEXT pCC,
  472. IN PAUTHZ_ACCESS_REQUEST pRequest,
  473. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  474. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  475. IN DWORD OptionalSecurityDescriptorCount,
  476. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  477. IN OUT PIOBJECT_TYPE_LIST LocalCachingTypeList OPTIONAL,
  478. IN DWORD LocalTypeListLength,
  479. IN BOOL ObjectTypeListPresent,
  480. OUT PDWORD pCachingFlags
  481. );
  482. BOOL
  483. AuthzpMaximumAllowedMultipleSDAccessCheck(
  484. IN PAUTHZI_CLIENT_CONTEXT pCC,
  485. IN PAUTHZ_ACCESS_REQUEST pRequest,
  486. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  487. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  488. IN DWORD OptionalSecurityDescriptorCount,
  489. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  490. IN OUT PIOBJECT_TYPE_LIST LocalCachingTypeList OPTIONAL,
  491. IN DWORD LocalTypeListLength,
  492. IN BOOL ObjectTypeListPresent,
  493. IN BOOL Restricted,
  494. OUT PDWORD pCachingFlags
  495. );
  496. BOOL
  497. AuthzpMaximumAllowedSingleAclAccessCheck(
  498. IN PAUTHZI_CLIENT_CONTEXT pCC,
  499. IN PSID_AND_ATTRIBUTES pSidAttr,
  500. IN DWORD SidCount,
  501. IN PAUTHZI_SID_HASH_ENTRY pHash,
  502. IN PAUTHZ_ACCESS_REQUEST pRequest,
  503. IN PACL pAcl,
  504. IN PSID pOwnerSid,
  505. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  506. IN OUT PIOBJECT_TYPE_LIST LocalCachingTypeList OPTIONAL,
  507. IN DWORD LocalTypeListLength,
  508. IN BOOL ObjectTypeListPresent,
  509. OUT PDWORD pCachingFlags
  510. );
  511. BOOL
  512. AuthzpSidApplicable(
  513. IN DWORD SidCount,
  514. IN PSID_AND_ATTRIBUTES pSidAttr,
  515. IN PAUTHZI_SID_HASH_ENTRY pHash,
  516. IN PSID pSid,
  517. IN PSID PrincipalSelfSid,
  518. IN PSID CreatorOwnerSid,
  519. IN BOOL DenyAce,
  520. OUT PDWORD pCachingFlags
  521. );
  522. BOOL
  523. AuthzpAccessCheckWithCaching(
  524. IN DWORD Flags,
  525. IN PAUTHZI_CLIENT_CONTEXT pCC,
  526. IN PAUTHZ_ACCESS_REQUEST pRequest,
  527. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  528. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  529. IN DWORD OptionalSecurityDescriptorCount,
  530. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  531. OUT PAUTHZ_ACCESS_CHECK_RESULTS_HANDLE phAccessCheckResults OPTIONAL,
  532. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  533. IN OUT PIOBJECT_TYPE_LIST LocalCachingTypeList OPTIONAL,
  534. IN DWORD LocalTypeListLength
  535. );
  536. BOOL
  537. AuthzpNormalAccessCheckWithoutCaching(
  538. IN PAUTHZI_CLIENT_CONTEXT pCC,
  539. IN PAUTHZ_ACCESS_REQUEST pRequest,
  540. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  541. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  542. IN DWORD OptionalSecurityDescriptorCount,
  543. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  544. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  545. IN DWORD LocalTypeListLength
  546. );
  547. BOOL
  548. AuthzpNormalMultipleSDAccessCheck(
  549. IN PAUTHZI_CLIENT_CONTEXT pCC,
  550. IN PSID_AND_ATTRIBUTES pSidAttr,
  551. IN DWORD SidCount,
  552. IN PAUTHZI_SID_HASH_ENTRY pSidHash,
  553. IN ACCESS_MASK Remaining,
  554. IN PAUTHZ_ACCESS_REQUEST pRequest,
  555. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  556. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  557. IN DWORD OptionalSecurityDescriptorCount,
  558. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  559. IN DWORD LocalTypeListLength
  560. );
  561. BOOL
  562. AuthzpOwnerSidInClientContext(
  563. IN PAUTHZI_CLIENT_CONTEXT pCC,
  564. IN PISECURITY_DESCRIPTOR pSecurityDescriptor
  565. );
  566. BOOL
  567. AuthzpNormalAccessCheck(
  568. IN PAUTHZI_CLIENT_CONTEXT pCC,
  569. IN PSID_AND_ATTRIBUTES pSidAttr,
  570. IN DWORD SidCount,
  571. IN PAUTHZI_SID_HASH_ENTRY pSidHash,
  572. IN ACCESS_MASK Remaining,
  573. IN PAUTHZ_ACCESS_REQUEST pRequest,
  574. IN PACL pAcl,
  575. IN PSID pOwnerSid,
  576. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  577. IN DWORD LocalTypeListLength
  578. );
  579. BOOL
  580. AuthzpQuickMaximumAllowedAccessCheck(
  581. IN PAUTHZI_CLIENT_CONTEXT pCC,
  582. IN PAUTHZI_HANDLE pAH,
  583. IN PAUTHZ_ACCESS_REQUEST pRequest,
  584. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  585. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  586. IN DWORD LocalTypeListLength
  587. );
  588. BOOL
  589. AuthzpQuickNormalAccessCheck(
  590. IN PAUTHZI_CLIENT_CONTEXT pCC,
  591. IN PAUTHZI_HANDLE pAH,
  592. IN PAUTHZ_ACCESS_REQUEST pRequest,
  593. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  594. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  595. IN DWORD LocalTypeListLength
  596. );
  597. BOOL
  598. AuthzpAllowOnlyNormalMultipleSDAccessCheck(
  599. IN PAUTHZI_CLIENT_CONTEXT pCC,
  600. IN PSID_AND_ATTRIBUTES pSidAttr,
  601. IN DWORD SidCount,
  602. IN PAUTHZI_SID_HASH_ENTRY pSidHash,
  603. IN ACCESS_MASK Remaining,
  604. IN PAUTHZ_ACCESS_REQUEST pRequest,
  605. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  606. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  607. IN DWORD OptionalSecurityDescriptorCount,
  608. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  609. IN DWORD LocalTypeListLength
  610. );
  611. BOOL
  612. AuthzpAllowOnlyNormalSingleAclAccessCheck(
  613. IN PAUTHZI_CLIENT_CONTEXT pCC,
  614. IN PSID_AND_ATTRIBUTES pSidAttr,
  615. IN DWORD SidCount,
  616. IN PAUTHZI_SID_HASH_ENTRY pSidHash,
  617. IN ACCESS_MASK Remaining,
  618. IN PAUTHZ_ACCESS_REQUEST pRequest,
  619. IN PACL pAcl,
  620. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  621. IN DWORD LocalTypeListLength
  622. );
  623. BOOL
  624. AuthzpAllowOnlySidApplicable(
  625. IN DWORD SidCount,
  626. IN PSID_AND_ATTRIBUTES pSidAttr,
  627. IN PAUTHZI_SID_HASH_ENTRY pSidHash,
  628. IN PSID pSid
  629. );
  630. VOID
  631. AuthzpAddAccessTypeList (
  632. IN PIOBJECT_TYPE_LIST ObjectTypeList,
  633. IN DWORD ObjectTypeListLength,
  634. IN DWORD StartIndex,
  635. IN ACCESS_MASK AccessMask,
  636. IN ACCESS_MASK_FIELD_TO_UPDATE FieldToUpdate
  637. );
  638. BOOL
  639. AuthzpObjectInTypeList (
  640. IN GUID *ObjectType,
  641. IN PIOBJECT_TYPE_LIST ObjectTypeList,
  642. IN DWORD ObjectTypeListLength,
  643. OUT PDWORD ReturnedIndex
  644. );
  645. BOOL
  646. AuthzpCacheResults(
  647. IN DWORD Flags,
  648. IN PAUTHZI_CLIENT_CONTEXT pCC,
  649. IN PIOBJECT_TYPE_LIST LocalCachingTypeList,
  650. IN DWORD LocalTypeListLength,
  651. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  652. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  653. IN DWORD OptionalSecurityDescriptorCount,
  654. IN DWORD CachingFlags,
  655. IN PAUTHZ_ACCESS_CHECK_RESULTS_HANDLE phAccessCheckResults
  656. );
  657. BOOL
  658. AuthzpVerifyCachedAccessCheckArguments(
  659. IN PAUTHZI_HANDLE pAH,
  660. IN PAUTHZ_ACCESS_REQUEST pRequest,
  661. IN OUT PAUTHZ_ACCESS_REPLY pReply
  662. );
  663. BOOL
  664. AuthzpAllowOnlyMaximumAllowedMultipleSDAccessCheck(
  665. IN PAUTHZI_CLIENT_CONTEXT pCC,
  666. IN PAUTHZ_ACCESS_REQUEST pRequest,
  667. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  668. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  669. IN DWORD OptionalSecurityDescriptorCount,
  670. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  671. IN DWORD LocalTypeListLength,
  672. IN BOOL ObjectTypeListPresent,
  673. IN BOOL Restricted
  674. );
  675. BOOL
  676. AuthzpAllowOnlyMaximumAllowedSingleAclAccessCheck(
  677. IN PAUTHZI_CLIENT_CONTEXT pCC,
  678. IN PSID_AND_ATTRIBUTES pSidAttr,
  679. IN DWORD SidCount,
  680. IN PAUTHZI_SID_HASH_ENTRY pSidHash,
  681. IN PAUTHZ_ACCESS_REQUEST pRequest,
  682. IN PACL pAcl,
  683. IN PSID pOwnerSid,
  684. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  685. IN DWORD LocalTypeListLength,
  686. IN BOOL ObjectTypeListPresent
  687. );
  688. VOID
  689. AuthzpAddAccessTypeList (
  690. IN OUT PIOBJECT_TYPE_LIST ObjectTypeList,
  691. IN DWORD ObjectTypeListLength,
  692. IN DWORD StartIndex,
  693. IN ACCESS_MASK AccessMask,
  694. IN ACCESS_MASK_FIELD_TO_UPDATE FieldToUpdate
  695. );
  696. VOID
  697. AuthzpUpdateParentTypeList(
  698. IN OUT PIOBJECT_TYPE_LIST ObjectTypeList,
  699. IN DWORD ObjectTypeListLength,
  700. IN DWORD StartIndex
  701. );
  702. BOOL
  703. AuthzpObjectInTypeList (
  704. IN GUID *ObjectType,
  705. IN PIOBJECT_TYPE_LIST ObjectTypeList,
  706. IN DWORD ObjectTypeListLength,
  707. OUT PDWORD ReturnedIndex
  708. );
  709. BOOL
  710. AuthzpGenerateAudit(
  711. IN PAUTHZI_CLIENT_CONTEXT pCC,
  712. IN PAUTHZ_ACCESS_REQUEST pRequest,
  713. IN PAUTHZI_AUDIT_EVENT pAuditEvent,
  714. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  715. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  716. IN DWORD OptionalSecurityDescriptorCount,
  717. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  718. IN OUT PIOBJECT_TYPE_LIST LocalTypeList
  719. );
  720. BOOL
  721. AuthzpCopySidsAndAttributes(
  722. IN OUT PSID_AND_ATTRIBUTES DestSidAttr,
  723. IN PSID_AND_ATTRIBUTES SidAttr1,
  724. IN DWORD Count1,
  725. IN PSID_AND_ATTRIBUTES SidAttr2,
  726. IN DWORD Count2
  727. );
  728. VOID
  729. AuthzpCopyLuidAndAttributes(
  730. IN PAUTHZI_CLIENT_CONTEXT pCC,
  731. IN PLUID_AND_ATTRIBUTES Source,
  732. IN DWORD Count,
  733. IN OUT PLUID_AND_ATTRIBUTES Destination
  734. );
  735. BOOL
  736. AuthzpDefaultAccessCheck(
  737. IN AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzClientContext,
  738. IN PACE_HEADER pAce,
  739. IN PVOID pArgs OPTIONAL,
  740. IN OUT PBOOL pbAceApplicable
  741. );
  742. VOID
  743. AuthzPrintContext(
  744. IN PAUTHZI_CLIENT_CONTEXT pCC
  745. );
  746. VOID
  747. AuthzpFillReplyFromParameters(
  748. IN PAUTHZ_ACCESS_REQUEST pRequest,
  749. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  750. IN PIOBJECT_TYPE_LIST LocalTypeList
  751. );
  752. BOOL
  753. AuthzpGetAllGroupsBySid(
  754. IN PSID pUserSid,
  755. IN DWORD Flags,
  756. OUT PSID_AND_ATTRIBUTES *ppSidAttr,
  757. OUT PDWORD pSidCount,
  758. OUT PDWORD pSidLength
  759. );
  760. BOOL
  761. AuthzpGetAllGroupsByName(
  762. IN PUNICODE_STRING pusUserName,
  763. IN PUNICODE_STRING pusDomainName,
  764. IN DWORD Flags,
  765. OUT PSID_AND_ATTRIBUTES *ppSidAttr,
  766. OUT PDWORD pSidCount,
  767. OUT PDWORD pSidLength
  768. );
  769. BOOL
  770. AuthzpAllocateAndInitializeClientContext(
  771. OUT PAUTHZI_CLIENT_CONTEXT *ppCC,
  772. IN PAUTHZI_CLIENT_CONTEXT Server,
  773. IN DWORD Revision,
  774. IN LUID Identifier,
  775. IN LARGE_INTEGER ExpirationTime,
  776. IN DWORD Flags,
  777. IN DWORD SidCount,
  778. IN DWORD SidLength,
  779. IN PSID_AND_ATTRIBUTES Sids,
  780. IN DWORD RestrictedSidCount,
  781. IN DWORD RestrictedSidLength,
  782. IN PSID_AND_ATTRIBUTES RestrictedSids,
  783. IN DWORD PrivilegeCount,
  784. IN DWORD PrivilegeLength,
  785. IN PLUID_AND_ATTRIBUTES Privileges,
  786. IN LUID AuthenticationId,
  787. IN PAUTHZI_HANDLE AuthzHandleHead,
  788. IN PAUTHZI_RESOURCE_MANAGER pRM
  789. );
  790. BOOL
  791. AuthzpAddDynamicSidsToToken(
  792. IN PAUTHZI_CLIENT_CONTEXT pCC,
  793. IN PAUTHZI_RESOURCE_MANAGER pRM,
  794. IN PVOID DynamicGroupsArgs,
  795. IN PSID_AND_ATTRIBUTES Sids,
  796. IN DWORD SidLength,
  797. IN DWORD SidCount,
  798. IN PSID_AND_ATTRIBUTES RestrictedSids,
  799. IN DWORD RestrictedSidLength,
  800. IN DWORD RestrictedSidCount,
  801. IN PLUID_AND_ATTRIBUTES Privileges,
  802. IN DWORD PrivilegeLength,
  803. IN DWORD PrivilegeCount,
  804. IN BOOL bAllocated
  805. );
  806. BOOL
  807. AuthzpExamineSingleSacl(
  808. IN PAUTHZI_CLIENT_CONTEXT pCC,
  809. IN PAUTHZ_ACCESS_REQUEST pRequest,
  810. IN ACCESS_MASK AccessMask,
  811. IN PACL pAcl,
  812. IN PSID pOwnerSid,
  813. IN UCHAR AuditMaskType,
  814. IN BOOL bMaximumFailed,
  815. OUT PAUTHZ_ACCESS_REPLY pReply,
  816. OUT PBOOL pbGenerateAudit
  817. );
  818. BOOL
  819. AuthzpExamineSacl(
  820. IN PAUTHZI_CLIENT_CONTEXT pCC,
  821. IN PAUTHZ_ACCESS_REQUEST pRequest,
  822. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  823. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  824. IN DWORD OptionalSecurityDescriptorCount,
  825. IN PAUTHZ_ACCESS_REPLY pReply,
  826. OUT PBOOL pbGenerateAudit
  827. );
  828. BOOL
  829. AuthzpExamineSaclForObjectTypeList(
  830. IN PAUTHZI_CLIENT_CONTEXT pCC,
  831. IN PAUTHZ_ACCESS_REQUEST pRequest,
  832. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  833. IN PSECURITY_DESCRIPTOR *OptionalSecurityDescriptorArray OPTIONAL,
  834. IN DWORD OptionalSecurityDescriptorCount,
  835. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  836. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  837. OUT PBOOL pbGenerateSuccessAudit,
  838. OUT PBOOL pbGenerateFailureAudit
  839. );
  840. BOOL
  841. AuthzpExamineSingleSaclForObjectTypeList(
  842. IN PAUTHZI_CLIENT_CONTEXT pCC,
  843. IN PAUTHZ_ACCESS_REQUEST pRequest,
  844. IN PACL pAcl,
  845. IN PSID pOwnerSid,
  846. IN PAUTHZ_ACCESS_REPLY pReply,
  847. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  848. OUT PBOOL pbGenerateSuccessAudit,
  849. OUT PBOOL pbGenerateFailureAudit
  850. );
  851. VOID
  852. AuthzpSetAuditInfoForObjectType(
  853. IN PAUTHZ_ACCESS_REPLY pReply,
  854. IN OUT PIOBJECT_TYPE_LIST LocalTypeList,
  855. IN DWORD StartIndex,
  856. IN ACCESS_MASK AceAccessMask,
  857. IN ACCESS_MASK DesiredAccessMask,
  858. IN UCHAR AceFlags,
  859. OUT PBOOL pbGenerateSuccessAudit,
  860. OUT PBOOL pbGenerateFailureAudit
  861. );
  862. BOOL
  863. AuthzpCreateAndLogAudit(
  864. IN DWORD AuditTypeFlag,
  865. IN PAUTHZI_CLIENT_CONTEXT pAuthzClientContext,
  866. IN PAUTHZI_AUDIT_EVENT pAuditEvent,
  867. IN PAUTHZI_RESOURCE_MANAGER pRM,
  868. IN PIOBJECT_TYPE_LIST LocalTypeList,
  869. IN PAUTHZ_ACCESS_REQUEST pRequest,
  870. IN PAUTHZ_ACCESS_REPLY pReply
  871. );
  872. VOID
  873. AuthzpFillReplyStructureFromCachedGrantedAccessMask(
  874. IN OUT PAUTHZ_ACCESS_REPLY pReply,
  875. IN ACCESS_MASK DesiredAccess,
  876. IN PACCESS_MASK GrantedAccessMask
  877. );
  878. BOOL
  879. AuthzpSendAuditToLsa(
  880. IN AUDIT_HANDLE hAuditContext,
  881. IN DWORD Flags,
  882. IN PAUDIT_PARAMS pAuditParams,
  883. IN PVOID Reserved
  884. );
  885. BOOL
  886. AuthzpEnQueueAuditEvent(
  887. PAUTHZI_AUDIT_QUEUE pQueue,
  888. PAUTHZ_AUDIT_QUEUE_ENTRY pAudit
  889. );
  890. BOOL
  891. AuthzpEnQueueAuditEventMonitor(
  892. PAUTHZI_AUDIT_QUEUE pQueue,
  893. PAUTHZ_AUDIT_QUEUE_ENTRY pAudit
  894. );
  895. BOOL
  896. AuthzpMarshallAuditParams(
  897. OUT PAUDIT_PARAMS * ppMarshalledAuditParams,
  898. IN PAUDIT_PARAMS pAuditParams
  899. );
  900. ULONG
  901. AuthzpDeQueueThreadWorker(
  902. LPVOID lpParameter
  903. );
  904. #define AUTHZ_SID_HASH_LOW_MASK 0xf
  905. #define AUTHZ_SID_HASH_HIGH_MASK 0xf0
  906. #define AUTHZ_SID_HASH_HIGH 16
  907. #define AUTHZ_SID_HASH_LOOKUP(table, byte) (((table)[(byte) & 0xf]) & ((table)[AUTHZ_SID_HASH_HIGH + (((byte) & 0xf0) >> 4)]))
  908. VOID
  909. AuthzpInitSidHash(
  910. IN PSID_AND_ATTRIBUTES pSidAttr,
  911. IN ULONG SidCount,
  912. OUT PAUTHZI_SID_HASH_ENTRY pHash
  913. );
  914. BOOL
  915. AuthzpGetThreadTokenInfo(
  916. OUT PSID* pUserSid,
  917. OUT PLUID pAuthenticationId
  918. );
  919. BOOL
  920. AuthzpGetProcessTokenInfo(
  921. OUT PSID* ppUserSid,
  922. OUT PLUID pAuthenticationId
  923. );
  924. VOID
  925. AuthzpReferenceAuditEventType(
  926. IN AUTHZ_AUDIT_EVENT_TYPE_HANDLE
  927. );
  928. BOOL
  929. AuthzpDereferenceAuditEventType(
  930. IN OUT AUTHZ_AUDIT_EVENT_TYPE_HANDLE
  931. );
  932. BOOL
  933. AuthzpEveryoneIncludesAnonymous(
  934. );
  935. #endif