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.

305 lines
6.9 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. NTSTATUS
  77. SepAdtMarshallAuditRecord(
  78. IN PSE_ADT_PARAMETER_ARRAY AuditParameters,
  79. OUT PSE_ADT_PARAMETER_ARRAY *MarshalledAuditParameters,
  80. OUT PSEP_RM_LSA_MEMORY_TYPE RecordMemoryType
  81. );
  82. BOOLEAN
  83. SepAdtPrivilegeObjectAuditAlarm (
  84. IN PUNICODE_STRING CapturedSubsystemName OPTIONAL,
  85. IN PVOID HandleId,
  86. IN PTOKEN ClientToken OPTIONAL,
  87. IN PTOKEN PrimaryToken,
  88. IN PVOID ProcessId,
  89. IN ACCESS_MASK DesiredAccess,
  90. IN PPRIVILEGE_SET CapturedPrivileges,
  91. IN BOOLEAN AccessGranted
  92. );
  93. VOID
  94. SepAdtTraverseAuditAlarm(
  95. IN PLUID OperationID,
  96. IN PVOID DirectoryObject,
  97. IN PSID UserSid,
  98. IN LUID AuthenticationId,
  99. IN ACCESS_MASK DesiredAccess,
  100. IN PPRIVILEGE_SET Privileges OPTIONAL,
  101. IN BOOLEAN AccessGranted,
  102. IN BOOLEAN GenerateAudit,
  103. IN BOOLEAN GenerateAlarm
  104. );
  105. VOID
  106. SepAdtCreateInstanceAuditAlarm(
  107. IN PLUID OperationID,
  108. IN PVOID Object,
  109. IN PSID UserSid,
  110. IN LUID AuthenticationId,
  111. IN ACCESS_MASK DesiredAccess,
  112. IN PPRIVILEGE_SET Privileges OPTIONAL,
  113. IN BOOLEAN AccessGranted,
  114. IN BOOLEAN GenerateAudit,
  115. IN BOOLEAN GenerateAlarm
  116. );
  117. VOID
  118. SepAdtCreateObjectAuditAlarm(
  119. IN PLUID OperationID,
  120. IN PUNICODE_STRING DirectoryName,
  121. IN PUNICODE_STRING ComponentName,
  122. IN PSID UserSid,
  123. IN LUID AuthenticationId,
  124. IN ACCESS_MASK DesiredAccess,
  125. IN BOOLEAN AccessGranted,
  126. IN BOOLEAN GenerateAudit,
  127. IN BOOLEAN GenerateAlarm
  128. );
  129. VOID
  130. SepAdtPrivilegedServiceAuditAlarm (
  131. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  132. IN PUNICODE_STRING CapturedSubsystemName,
  133. IN PUNICODE_STRING CapturedServiceName,
  134. IN PTOKEN ClientToken OPTIONAL,
  135. IN PTOKEN PrimaryToken,
  136. IN PPRIVILEGE_SET CapturedPrivileges,
  137. IN BOOLEAN AccessGranted
  138. );
  139. VOID
  140. SepAdtCloseObjectAuditAlarm(
  141. IN PUNICODE_STRING CapturedSubsystemName,
  142. IN PVOID HandleId,
  143. IN PSID UserSid
  144. );
  145. VOID
  146. SepAdtDeleteObjectAuditAlarm(
  147. IN PUNICODE_STRING CapturedSubsystemName,
  148. IN PVOID HandleId,
  149. IN PSID UserSid
  150. );
  151. BOOLEAN
  152. SepAdtOpenObjectAuditAlarm (
  153. IN PUNICODE_STRING CapturedSubsystemName,
  154. IN PVOID *HandleId OPTIONAL,
  155. IN PUNICODE_STRING CapturedObjectTypeName,
  156. IN PUNICODE_STRING CapturedObjectName OPTIONAL,
  157. IN PTOKEN ClientToken OPTIONAL,
  158. IN PTOKEN PrimaryToken,
  159. IN ACCESS_MASK DesiredAccess,
  160. IN ACCESS_MASK GrantedAccess,
  161. IN PLUID OperationId,
  162. IN PPRIVILEGE_SET CapturedPrivileges OPTIONAL,
  163. IN BOOLEAN AccessGranted,
  164. IN HANDLE ProcessID,
  165. IN POLICY_AUDIT_EVENT_TYPE AuditType,
  166. IN PIOBJECT_TYPE_LIST ObjectTypeList OPTIONAL,
  167. IN ULONG ObjectTypeListLength,
  168. IN PACCESS_MASK GrantedAccessArray OPTIONAL
  169. );
  170. BOOLEAN
  171. SepAdtOpenObjectForDeleteAuditAlarm(
  172. IN PUNICODE_STRING CapturedSubsystemName,
  173. IN PVOID *HandleId,
  174. IN PUNICODE_STRING CapturedObjectTypeName,
  175. IN PUNICODE_STRING CapturedObjectName,
  176. IN PTOKEN ClientToken OPTIONAL,
  177. IN PTOKEN PrimaryToken,
  178. IN ACCESS_MASK DesiredAccess,
  179. IN ACCESS_MASK GrantedAccess,
  180. IN PLUID OperationId,
  181. IN PPRIVILEGE_SET CapturedPrivileges OPTIONAL,
  182. IN BOOLEAN AccessGranted,
  183. IN HANDLE ProcessID
  184. );
  185. VOID
  186. SepAdtObjectReferenceAuditAlarm(
  187. IN PVOID Object,
  188. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
  189. IN ACCESS_MASK DesiredAccess,
  190. IN BOOLEAN AccessGranted
  191. );
  192. #define SepAdtAuditThisEvent(AuditType, AccessGranted) \
  193. (SepAdtAuditingEnabled && \
  194. ((SeAuditingState[AuditType].AuditOnSuccess && *AccessGranted) || \
  195. (SeAuditingState[AuditType].AuditOnFailure && !(*AccessGranted))))
  196. VOID
  197. SepAdtInitializeBounds(
  198. VOID
  199. );
  200. VOID
  201. SepAuditFailed(
  202. IN NTSTATUS AuditStatus
  203. );
  204. NTSTATUS
  205. SepAdtInitializeCrashOnFail(
  206. VOID
  207. );
  208. BOOLEAN
  209. SepInitializePrivilegeFilter(
  210. BOOLEAN Verbose
  211. );
  212. BOOLEAN
  213. SepAdtInitializePrivilegeAuditing(
  214. VOID
  215. );
  216. // ----------------------------------------------------------------------
  217. // The following is used only temporarily for NT5.
  218. //
  219. // NT5 does not provide any facility to enable/disable auditing at
  220. // audit-event level. It only supports it at audit category level.
  221. // This creates problems if one wants to audit only certain specific
  222. // audit events of a category. The current design gives you all or none for
  223. // each category.
  224. //
  225. // Post NT5 auditing will provide a better/flexible design that wil address
  226. // this issue. For now, to delight some valuable customers, we provide this
  227. // hack / registry based solution. This solution will be removed post NT5.
  228. //
  229. VOID
  230. SepAdtInitializeAuditingOptions(
  231. VOID
  232. );
  233. typedef struct _SEP_AUDIT_OPTIONS
  234. {
  235. BOOLEAN DoNotAuditCloseObjectEvents;
  236. } SEP_AUDIT_OPTIONS;
  237. extern SEP_AUDIT_OPTIONS SepAuditOptions;
  238. // ----------------------------------------------------------------------
  239. #endif // _ADTP_H_