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.

334 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. adtp.h
  5. Abstract:
  6. Auditing - Private Defines, Fuction Prototypes and Macro Functions
  7. Author:
  8. Scott Birrell (ScottBi) November 6, 1991
  9. Environment:
  10. Revision History:
  11. --*/
  12. #ifndef _ADTP_H_
  13. #define _ADTP_H_
  14. #include "tokenp.h"
  15. //
  16. // Audit Log Information
  17. //
  18. POLICY_AUDIT_LOG_INFO SepAdtLogInformation;
  19. extern BOOLEAN SepAdtAuditingEnabled;
  20. //
  21. // High and low water marks to control the length of the audit queue
  22. //
  23. extern ULONG SepAdtMaxListLength;
  24. extern ULONG SepAdtMinListLength;
  25. //
  26. // Set when LSA has died.
  27. //
  28. extern PKEVENT SepAdtLsaDeadEvent;
  29. //
  30. // Structure used to query the above values from the registry
  31. //
  32. typedef struct _SEP_AUDIT_BOUNDS {
  33. ULONG UpperBound;
  34. ULONG LowerBound;
  35. } SEP_AUDIT_BOUNDS, *PSEP_AUDIT_BOUNDS;
  36. //
  37. // Number of events discarded
  38. //
  39. extern ULONG SepAdtCountEventsDiscarded;
  40. //
  41. // Number of events on the queue
  42. //
  43. extern ULONG SepAdtCurrentListLength;
  44. //
  45. // Flag to tell us that we're discarding audits
  46. //
  47. extern BOOLEAN SepAdtDiscardingAudits;
  48. //
  49. // Flag to tell us that we should crash if we miss an audit.
  50. //
  51. extern BOOLEAN SepCrashOnAuditFail;
  52. //
  53. // Value name for verbose privilege auditing
  54. //
  55. #define FULL_PRIVILEGE_AUDITING L"FullPrivilegeAuditing"
  56. //
  57. // security descriptor to be used for adding a SACL on system processes
  58. //
  59. extern PSECURITY_DESCRIPTOR SepProcessAuditSd;
  60. //
  61. // security descriptor to check if a given token has any one of
  62. // following sids in it:
  63. // -- SeLocalSystemSid
  64. // -- SeLocalServiceSid
  65. // -- SeNetworkServiceSid
  66. //
  67. extern PSECURITY_DESCRIPTOR SepImportantProcessSd;
  68. //
  69. // pseudo access bit used in each ACE of SepImportantProcessSd
  70. //
  71. #define SEP_QUERY_MEMBERSHIP 1
  72. //
  73. // used with SepImportantProcessSd
  74. //
  75. extern GENERIC_MAPPING GenericMappingForMembershipCheck;
  76. VOID
  77. SepAdtSetAuditEventInformation(
  78. IN OPTIONAL PBOOLEAN AuditingMode,
  79. IN OPTIONAL PPOLICY_AUDIT_EVENT_OPTIONS EventAuditingOptions
  80. );
  81. VOID
  82. SepAdtGetAuditEventInformation(
  83. OUT OPTIONAL PBOOLEAN AuditingMode,
  84. OUT OPTIONAL PPOLICY_AUDIT_EVENT_OPTIONS EventAuditingOptions
  85. );
  86. VOID
  87. SepAdtSetAuditLogInformation(
  88. IN PPOLICY_AUDIT_LOG_INFO AuditLogInformation
  89. );
  90. NTSTATUS
  91. SepAdtMarshallAuditRecord(
  92. IN PSE_ADT_PARAMETER_ARRAY AuditParameters,
  93. OUT PSE_ADT_PARAMETER_ARRAY *MarshalledAuditParameters,
  94. OUT PSEP_RM_LSA_MEMORY_TYPE RecordMemoryType
  95. );
  96. BOOLEAN
  97. SepAdtPrivilegeObjectAuditAlarm (
  98. IN PUNICODE_STRING CapturedSubsystemName OPTIONAL,
  99. IN PVOID HandleId,
  100. IN PTOKEN ClientToken OPTIONAL,
  101. IN PTOKEN PrimaryToken,
  102. IN PVOID ProcessId,
  103. IN ACCESS_MASK DesiredAccess,
  104. IN PPRIVILEGE_SET CapturedPrivileges,
  105. IN BOOLEAN AccessGranted
  106. );
  107. VOID
  108. SepAdtTraverseAuditAlarm(
  109. IN PLUID OperationID,
  110. IN PVOID DirectoryObject,
  111. IN PSID UserSid,
  112. IN LUID AuthenticationId,
  113. IN ACCESS_MASK DesiredAccess,
  114. IN PPRIVILEGE_SET Privileges OPTIONAL,
  115. IN BOOLEAN AccessGranted,
  116. IN BOOLEAN GenerateAudit,
  117. IN BOOLEAN GenerateAlarm
  118. );
  119. VOID
  120. SepAdtCreateInstanceAuditAlarm(
  121. IN PLUID OperationID,
  122. IN PVOID Object,
  123. IN PSID UserSid,
  124. IN LUID AuthenticationId,
  125. IN ACCESS_MASK DesiredAccess,
  126. IN PPRIVILEGE_SET Privileges OPTIONAL,
  127. IN BOOLEAN AccessGranted,
  128. IN BOOLEAN GenerateAudit,
  129. IN BOOLEAN GenerateAlarm
  130. );
  131. VOID
  132. SepAdtCreateObjectAuditAlarm(
  133. IN PLUID OperationID,
  134. IN PUNICODE_STRING DirectoryName,
  135. IN PUNICODE_STRING ComponentName,
  136. IN PSID UserSid,
  137. IN LUID AuthenticationId,
  138. IN ACCESS_MASK DesiredAccess,
  139. IN BOOLEAN AccessGranted,
  140. IN BOOLEAN GenerateAudit,
  141. IN BOOLEAN GenerateAlarm
  142. );
  143. VOID
  144. SepAdtPrivilegedServiceAuditAlarm (
  145. IN PUNICODE_STRING CapturedSubsystemName,
  146. IN PUNICODE_STRING CapturedServiceName,
  147. IN PTOKEN ClientToken OPTIONAL,
  148. IN PTOKEN PrimaryToken,
  149. IN PPRIVILEGE_SET CapturedPrivileges,
  150. IN BOOLEAN AccessGranted
  151. );
  152. VOID
  153. SepAdtCloseObjectAuditAlarm(
  154. IN PUNICODE_STRING CapturedSubsystemName,
  155. IN PVOID HandleId,
  156. IN PSID UserSid
  157. );
  158. VOID
  159. SepAdtDeleteObjectAuditAlarm(
  160. IN PUNICODE_STRING CapturedSubsystemName,
  161. IN PVOID HandleId,
  162. IN PSID UserSid
  163. );
  164. BOOLEAN
  165. SepAdtOpenObjectAuditAlarm (
  166. IN PUNICODE_STRING CapturedSubsystemName,
  167. IN PVOID *HandleId OPTIONAL,
  168. IN PUNICODE_STRING CapturedObjectTypeName,
  169. IN PUNICODE_STRING CapturedObjectName OPTIONAL,
  170. IN PTOKEN ClientToken OPTIONAL,
  171. IN PTOKEN PrimaryToken,
  172. IN ACCESS_MASK DesiredAccess,
  173. IN ACCESS_MASK GrantedAccess,
  174. IN PLUID OperationId,
  175. IN PPRIVILEGE_SET CapturedPrivileges OPTIONAL,
  176. IN BOOLEAN AccessGranted,
  177. IN HANDLE ProcessID,
  178. IN POLICY_AUDIT_EVENT_TYPE AuditType,
  179. IN PIOBJECT_TYPE_LIST ObjectTypeList OPTIONAL,
  180. IN ULONG ObjectTypeListLength,
  181. IN PACCESS_MASK GrantedAccessArray OPTIONAL
  182. );
  183. BOOLEAN
  184. SepAdtOpenObjectForDeleteAuditAlarm(
  185. IN PUNICODE_STRING CapturedSubsystemName,
  186. IN PVOID *HandleId,
  187. IN PUNICODE_STRING CapturedObjectTypeName,
  188. IN PUNICODE_STRING CapturedObjectName,
  189. IN PTOKEN ClientToken OPTIONAL,
  190. IN PTOKEN PrimaryToken,
  191. IN ACCESS_MASK DesiredAccess,
  192. IN ACCESS_MASK GrantedAccess,
  193. IN PLUID OperationId,
  194. IN PPRIVILEGE_SET CapturedPrivileges OPTIONAL,
  195. IN BOOLEAN AccessGranted,
  196. IN HANDLE ProcessID
  197. );
  198. VOID
  199. SepAdtObjectReferenceAuditAlarm(
  200. IN PVOID Object,
  201. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  202. IN ACCESS_MASK DesiredAccess,
  203. IN BOOLEAN AccessGranted
  204. );
  205. //
  206. // BOOLEAN
  207. // SepAdtAuditThisEvent(
  208. // IN POLICY_AUDIT_EVENT_TYPE AuditType,
  209. // IN PBOOLEAN AccessGranted
  210. // );
  211. //
  212. #define SepAdtAuditThisEvent(AuditType, AccessGranted) \
  213. (SepAdtAuditingEnabled && \
  214. ((SeAuditingState[AuditType].AuditOnSuccess && *AccessGranted) || \
  215. (SeAuditingState[AuditType].AuditOnFailure && !(*AccessGranted))))
  216. #define SepAdtAuditThisEventEx(AuditType, AccessGranted, AccessDenied ) \
  217. (SepAdtAuditingEnabled && \
  218. ((SeAuditingState[AuditType].AuditOnSuccess && AccessGranted) || \
  219. (SeAuditingState[AuditType].AuditOnFailure && AccessDenied)))
  220. VOID
  221. SepAdtInitializeBounds(
  222. VOID
  223. );
  224. VOID
  225. SepAuditFailed(
  226. VOID
  227. );
  228. NTSTATUS
  229. SepAdtInitializeCrashOnFail(
  230. VOID
  231. );
  232. BOOLEAN
  233. SepInitializePrivilegeFilter(
  234. BOOLEAN Verbose
  235. );
  236. BOOLEAN
  237. SepAdtInitializePrivilegeAuditing(
  238. VOID
  239. );
  240. // ----------------------------------------------------------------------
  241. // The following is used only temporarily for NT5.
  242. //
  243. // NT5 does not provide any facility to enable/disable auditing at
  244. // audit-event level. It only supports it at audit category level.
  245. // This creates problems if one wants to audit only certain specific
  246. // audit events of a category. The current design gives you all or none for
  247. // each category.
  248. //
  249. // Post NT5 auditing will provide a better/flexible design that wil address
  250. // this issue. For now, to delight some valuable customers, we provide this
  251. // hack / registry based solution. This solution will be removed post NT5.
  252. //
  253. VOID
  254. SepAdtInitializeAuditingOptions(
  255. VOID
  256. );
  257. typedef struct _SEP_AUDIT_OPTIONS
  258. {
  259. BOOLEAN DoNotAuditCloseObjectEvents;
  260. } SEP_AUDIT_OPTIONS;
  261. extern SEP_AUDIT_OPTIONS SepAuditOptions;
  262. // ----------------------------------------------------------------------
  263. #endif // _ADTP_H_