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.

227 lines
12 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. precedence.h
  5. Abstract:
  6. This file contains the prototype for the main routine to calculate precedences.
  7. This is called during planning/diagnosis.
  8. Author:
  9. Vishnu Patankar (VishnuP) 7-April-2000
  10. Environment:
  11. User Mode - Win32
  12. Revision History:
  13. --*/
  14. ///////////////////////////////////////////////////////////////////////////////
  15. // //
  16. // Includes //
  17. // //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #ifndef _precedence_
  20. #define _precedence_
  21. #include "headers.h"
  22. #include "..\hashtable.h"
  23. #include "scedllrc.h"
  24. #include "logger.h"
  25. #include <userenv.h>
  26. typedef enum _SCEP_RSOP_CLASS_TYPE_{
  27. RSOP_SecuritySettingNumeric = 0,
  28. RSOP_SecuritySettingBoolean,
  29. RSOP_SecuritySettingString,
  30. RSOP_AuditPolicy,
  31. RSOP_SecurityEventLogSettingNumeric,
  32. RSOP_SecurityEventLogSettingBoolean,
  33. RSOP_RegistryValue,
  34. RSOP_UserPrivilegeRight,
  35. RSOP_RestrictedGroup,
  36. RSOP_SystemService,
  37. RSOP_File,
  38. RSOP_RegistryKey
  39. };
  40. const static PWSTR ScepRsopSchemaClassNames [] = {
  41. L"RSOP_SecuritySettingNumeric",
  42. L"RSOP_SecuritySettingBoolean",
  43. L"RSOP_SecuritySettingString",
  44. L"RSOP_AuditPolicy",
  45. L"RSOP_SecurityEventLogSettingNumeric",
  46. L"RSOP_SecurityEventLogSettingBoolean",
  47. L"RSOP_RegistryValue",
  48. L"RSOP_UserPrivilegeRight",
  49. L"RSOP_RestrictedGroup",
  50. L"RSOP_SystemService",
  51. L"RSOP_File",
  52. L"RSOP_RegistryKey"
  53. };
  54. typedef struct _SCE_KEY_LOOKUP_PRECEDENCE {
  55. SCE_KEY_LOOKUP KeyLookup;
  56. DWORD Precedence;
  57. }SCE_KEY_LOOKUP_PRECEDENCE;
  58. #define SCEP_TYPECAST(type, bufptr, offset) (*((type *)((CHAR *)bufptr + offset)))
  59. #define NUM_KERBEROS_SUB_SETTINGS 5
  60. #define NUM_EVENTLOG_TYPES 3
  61. #define PLANNING_GPT_DIR TEXT("\\security\\templates\\policies\\planning\\")
  62. #define DIAGNOSIS_GPT_DIR TEXT("\\security\\templates\\policies\\")
  63. #define WINLOGON_LOG_PATH TEXT("\\security\\logs\\winlogon.log")
  64. #define PLANNING_LOG_PATH TEXT("\\security\\logs\\planning.log")
  65. #define DIAGNOSIS_LOG_FILE TEXT("\\security\\logs\\diagnosis.log")
  66. // matrix description
  67. // first column has keyName / settingName
  68. // second column has field offset in SCE_PROFILE_INFO - hardcoded
  69. // third column has setting types - from _SCEP_RSOP_CLASS_TYPE_
  70. // fourth column has current precedence - unused for dynamic types
  71. static SCE_KEY_LOOKUP_PRECEDENCE PrecedenceLookup[] = {
  72. //RSOP_SecuritySettingNumeric
  73. {{(PWSTR)TEXT("MinimumPasswordAge"), offsetof(struct _SCE_PROFILE_INFO, MinimumPasswordAge), RSOP_SecuritySettingNumeric}, (DWORD)0},
  74. {{(PWSTR)TEXT("MaximumPasswordAge"), offsetof(struct _SCE_PROFILE_INFO, MaximumPasswordAge), RSOP_SecuritySettingNumeric}, (DWORD)0},
  75. {{(PWSTR)TEXT("MinimumPasswordLength"), offsetof(struct _SCE_PROFILE_INFO, MinimumPasswordLength), RSOP_SecuritySettingNumeric}, (DWORD)0},
  76. {{(PWSTR)TEXT("PasswordHistorySize"), offsetof(struct _SCE_PROFILE_INFO, PasswordHistorySize), RSOP_SecuritySettingNumeric}, (DWORD)0},
  77. {{(PWSTR)TEXT("LockoutBadCount"), offsetof(struct _SCE_PROFILE_INFO, LockoutBadCount), RSOP_SecuritySettingNumeric}, (DWORD)0},
  78. {{(PWSTR)TEXT("ResetLockoutCount"), offsetof(struct _SCE_PROFILE_INFO, ResetLockoutCount), RSOP_SecuritySettingNumeric}, (DWORD)0},
  79. {{(PWSTR)TEXT("LockoutDuration"), offsetof(struct _SCE_PROFILE_INFO, LockoutDuration), RSOP_SecuritySettingNumeric}, (DWORD)0},
  80. // RSOP_SecuritySettingBoolean
  81. {{(PWSTR)TEXT("ClearTextPassword"), offsetof(struct _SCE_PROFILE_INFO, ClearTextPassword), RSOP_SecuritySettingBoolean}, (DWORD)0},
  82. {{(PWSTR)TEXT("PasswordComplexity"), offsetof(struct _SCE_PROFILE_INFO, PasswordComplexity), RSOP_SecuritySettingBoolean}, (DWORD)0},
  83. {{(PWSTR)TEXT("RequireLogonToChangePassword"), offsetof(struct _SCE_PROFILE_INFO, RequireLogonToChangePassword), RSOP_SecuritySettingBoolean}, (DWORD)0},
  84. {{(PWSTR)TEXT("ForceLogoffWhenHourExpire"), offsetof(struct _SCE_PROFILE_INFO, ForceLogoffWhenHourExpire), RSOP_SecuritySettingBoolean}, (DWORD)0},
  85. {{(PWSTR)TEXT("LSAAnonymousNameLookup"), offsetof(struct _SCE_PROFILE_INFO, LSAAnonymousNameLookup), RSOP_SecuritySettingBoolean}, (DWORD)0},
  86. {{(PWSTR)TEXT("EnableAdminAccount"), offsetof(struct _SCE_PROFILE_INFO, EnableAdminAccount), RSOP_SecuritySettingBoolean}, (DWORD)0},
  87. {{(PWSTR)TEXT("EnableGuestAccount"), offsetof(struct _SCE_PROFILE_INFO, EnableGuestAccount), RSOP_SecuritySettingBoolean}, (DWORD)0},
  88. //RSOP_SecuritySettingString
  89. {{(PWSTR)TEXT("NewAdministratorName"), offsetof(struct _SCE_PROFILE_INFO, NewAdministratorName), RSOP_SecuritySettingString}, (DWORD)0},
  90. {{(PWSTR)TEXT("NewGuestName"), offsetof(struct _SCE_PROFILE_INFO, NewGuestName), RSOP_SecuritySettingString}, (DWORD)0},
  91. // RSOP_AuditPolicy
  92. {{(PWSTR)TEXT("AuditSystemEvents"), offsetof(struct _SCE_PROFILE_INFO, AuditSystemEvents), RSOP_AuditPolicy}, (DWORD)0},
  93. {{(PWSTR)TEXT("AuditLogonEvents"), offsetof(struct _SCE_PROFILE_INFO, AuditLogonEvents), RSOP_AuditPolicy}, (DWORD)0},
  94. {{(PWSTR)TEXT("AuditObjectAccess"), offsetof(struct _SCE_PROFILE_INFO, AuditObjectAccess), RSOP_AuditPolicy}, (DWORD)0},
  95. {{(PWSTR)TEXT("AuditPrivilegeUse"), offsetof(struct _SCE_PROFILE_INFO, AuditPrivilegeUse), RSOP_AuditPolicy}, (DWORD)0},
  96. {{(PWSTR)TEXT("AuditPolicyChange"), offsetof(struct _SCE_PROFILE_INFO, AuditPolicyChange), RSOP_AuditPolicy}, (DWORD)0},
  97. {{(PWSTR)TEXT("AuditAccountManage"), offsetof(struct _SCE_PROFILE_INFO, AuditAccountManage), RSOP_AuditPolicy}, (DWORD)0},
  98. {{(PWSTR)TEXT("AuditProcessTracking"), offsetof(struct _SCE_PROFILE_INFO, AuditProcessTracking), RSOP_AuditPolicy}, (DWORD)0},
  99. {{(PWSTR)TEXT("AuditDSAccess"), offsetof(struct _SCE_PROFILE_INFO, AuditDSAccess), RSOP_AuditPolicy}, (DWORD)0},
  100. {{(PWSTR)TEXT("AuditAccountLogon"), offsetof(struct _SCE_PROFILE_INFO, AuditAccountLogon), RSOP_AuditPolicy}, (DWORD)0},
  101. // RSOP_SecurityEventLogSettingNumeric
  102. // one each for system, application, security
  103. // following eventlog entries should be contiguous in the same order to resemble contiguous memory
  104. {{(PWSTR)TEXT("MaximumLogSize"), offsetof(struct _SCE_PROFILE_INFO, MaximumLogSize), RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  105. {{(PWSTR)TEXT("MaximumLogSize"), offsetof(struct _SCE_PROFILE_INFO, MaximumLogSize) + sizeof(DWORD), RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  106. {{(PWSTR)TEXT("MaximumLogSize"), offsetof(struct _SCE_PROFILE_INFO, MaximumLogSize) + 2*sizeof(DWORD), RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  107. {{(PWSTR)TEXT("AuditLogRetentionPeriod"), offsetof(struct _SCE_PROFILE_INFO, AuditLogRetentionPeriod), RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  108. {{(PWSTR)TEXT("AuditLogRetentionPeriod"), offsetof(struct _SCE_PROFILE_INFO, AuditLogRetentionPeriod) + sizeof(DWORD),RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  109. {{(PWSTR)TEXT("AuditLogRetentionPeriod"), offsetof(struct _SCE_PROFILE_INFO, AuditLogRetentionPeriod) + 2 * sizeof(DWORD),RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  110. {{(PWSTR)TEXT("RetentionDays"), offsetof(struct _SCE_PROFILE_INFO, RetentionDays), RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  111. {{(PWSTR)TEXT("RetentionDays"), offsetof(struct _SCE_PROFILE_INFO, RetentionDays) + sizeof(DWORD), RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  112. {{(PWSTR)TEXT("RetentionDays"), offsetof(struct _SCE_PROFILE_INFO, RetentionDays) + 2 * sizeof(DWORD), RSOP_SecurityEventLogSettingNumeric}, (DWORD)0},
  113. // RSOP_SecurityEventLogSettingBoolean - one each for system, application, security
  114. {{(PWSTR)TEXT("RestrictGuestAccess"), offsetof(struct _SCE_PROFILE_INFO, RestrictGuestAccess), RSOP_SecurityEventLogSettingBoolean}, (DWORD)0},
  115. {{(PWSTR)TEXT("RestrictGuestAccess"), offsetof(struct _SCE_PROFILE_INFO, RestrictGuestAccess) + sizeof(DWORD), RSOP_SecurityEventLogSettingBoolean}, (DWORD)0},
  116. {{(PWSTR)TEXT("RestrictGuestAccess"), offsetof(struct _SCE_PROFILE_INFO, RestrictGuestAccess) + 2 * sizeof(DWORD), RSOP_SecurityEventLogSettingBoolean}, (DWORD)0},
  117. // RSOP_RegistryValue
  118. // can compute offset of aRegValues from this
  119. {{(PWSTR)TEXT("RegValueCount"), offsetof(struct _SCE_PROFILE_INFO, RegValueCount), RSOP_RegistryValue}, (DWORD)0},
  120. // RSOP_UserPrivilegeRight
  121. {{(PWSTR)TEXT("pInfPrivilegeAssignedTo"), offsetof(struct _SCE_PROFILE_INFO, OtherInfo) + sizeof(PSCE_NAME_LIST), RSOP_UserPrivilegeRight}, (DWORD)0},
  122. // RSOP_RestrictedGroup
  123. {{(PWSTR)TEXT("pGroupMembership"), offsetof(struct _SCE_PROFILE_INFO, pGroupMembership), RSOP_RestrictedGroup}, (DWORD)0},
  124. // RSOP_SystemService
  125. {{(PWSTR)TEXT("pServices"), offsetof(struct _SCE_PROFILE_INFO, pServices), RSOP_SystemService}, (DWORD)0},
  126. // RSOP_File
  127. {{(PWSTR)TEXT("pFiles"), offsetof(struct _SCE_PROFILE_INFO, pFiles), RSOP_File}, (DWORD)0},
  128. // RSOP_RegistryKey
  129. {{(PWSTR)TEXT("pRegistryKeys"), offsetof(struct _SCE_PROFILE_INFO, pRegistryKeys), RSOP_RegistryKey}, (DWORD)0},
  130. // following kerberos entries should be contiguous in the same order to resemble contiguous memory
  131. {{(PWSTR)TEXT("pKerberosInfo"), offsetof(struct _SCE_PROFILE_INFO, pKerberosInfo), RSOP_SecuritySettingNumeric}, (DWORD)0},
  132. //RSOP_SecuritySettingNumeric
  133. {{(PWSTR)TEXT("MaxTicketAge"), offsetof(struct _SCE_KERBEROS_TICKET_INFO_, MaxTicketAge), RSOP_SecuritySettingNumeric}, (DWORD)0},
  134. {{(PWSTR)TEXT("MaxRenewAge"), offsetof(struct _SCE_KERBEROS_TICKET_INFO_, MaxRenewAge), RSOP_SecuritySettingNumeric}, (DWORD)0},
  135. {{(PWSTR)TEXT("MaxServiceAge"), offsetof(struct _SCE_KERBEROS_TICKET_INFO_, MaxServiceAge), RSOP_SecuritySettingNumeric}, (DWORD)0},
  136. {{(PWSTR)TEXT("MaxClockSkew"), offsetof(struct _SCE_KERBEROS_TICKET_INFO_, MaxClockSkew), RSOP_SecuritySettingNumeric}, (DWORD)0},
  137. // RSOP_SecuritySettingBoolean
  138. {{(PWSTR)TEXT("TicketValidateClient"), offsetof(struct _SCE_KERBEROS_TICKET_INFO_, TicketValidateClient), RSOP_SecuritySettingBoolean}, (DWORD)0}
  139. };
  140. DWORD SceLogSettingsPrecedenceGPOs(
  141. IN IWbemServices *pWbemServices,
  142. IN BOOL bPlanningMode,
  143. IN PWSTR *ppwszLogFile
  144. );
  145. DWORD
  146. ScepConvertSingleSlashToDoubleSlashPath(
  147. IN wchar_t *pSettingInfo,
  148. OUT PWSTR *ppwszDoubleSlashPath
  149. );
  150. DWORD
  151. ScepClientTranslateFileDirName(
  152. IN PWSTR oldFileName,
  153. OUT PWSTR *newFileName
  154. );
  155. VOID
  156. ScepLogEventAndReport(
  157. IN HINSTANCE hInstance,
  158. IN LPTSTR LogFileName,
  159. IN DWORD LogLevel,
  160. IN DWORD dwEventID,
  161. IN UINT idMsg,
  162. IN DWORD rc,
  163. IN PWSTR pwszMsg
  164. );
  165. BOOL
  166. ScepRsopLookupBuiltinNameTable(
  167. IN PWSTR pwszGroupName
  168. );
  169. DWORD
  170. ScepCanonicalizeGroupName(
  171. IN PWSTR pwszGroupName,
  172. OUT PWSTR *ppwszCanonicalGroupName
  173. );
  174. #endif