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.

277 lines
8.9 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. dbdata.c
  5. Abstract:
  6. Local Security Authority - Database Server Global Data
  7. Author:
  8. Scott Birrell (ScottBi) July 25, 1991
  9. Environment:
  10. User Mode
  11. Revision History:
  12. --*/
  13. #include <lsapch2.h>
  14. #include "dbp.h"
  15. OBJECT_ATTRIBUTES LsapDbObjectAttributes;
  16. STRING LsapDbNameString;
  17. LARGE_INTEGER LsapDbInitSize;
  18. LARGE_INTEGER LsapDbMaximumSizeOfSection;
  19. //
  20. // LSA Initialized Status
  21. //
  22. BOOLEAN LsapInitialized = FALSE;
  23. //
  24. // Setup Event Existed
  25. // This is necessary to distinguish a psuedo install done
  26. // during a developer's first boot after install (which does
  27. // an auto init) and the case where a real setup was run.
  28. //
  29. BOOLEAN LsapSetupWasRun = FALSE;
  30. //
  31. // Boolean indicating that the Ds is up and running
  32. //
  33. BOOLEAN LsapDsIsRunning = FALSE;
  34. //
  35. // Database initialization has been performed
  36. //
  37. BOOLEAN LsapDatabaseSetupPerformed = FALSE;
  38. //
  39. // Type of product we are running
  40. //
  41. NT_PRODUCT_TYPE LsapProductType;
  42. //
  43. // Product suites available on the current machine
  44. //
  45. WORD LsapProductSuiteMask=0;
  46. //
  47. // LSA Database State information
  48. //
  49. LSAP_DB_STATE LsapDbState;
  50. #ifdef DBG
  51. BOOL g_ScePolicyLocked = FALSE;
  52. #endif
  53. //
  54. // LsaDb object Handle used internally.
  55. // Also one for use throughout LSA.
  56. //
  57. LSAPR_HANDLE LsapDbHandle;
  58. LSAPR_HANDLE LsapPolicyHandle = NULL;
  59. //
  60. // LSA Database Encryption Key
  61. //
  62. PLSAP_CR_CIPHER_KEY LsapDbCipherKey;
  63. PLSAP_CR_CIPHER_KEY LsapDbSP4SecretCipherKey;
  64. PLSAP_CR_CIPHER_KEY LsapDbSecretCipherKeyRead;
  65. PLSAP_CR_CIPHER_KEY LsapDbSecretCipherKeyWrite;
  66. PVOID LsapDbSysKey = NULL;
  67. PVOID LsapDbOldSysKey = NULL;
  68. //
  69. // Is this a DC in the root domain?
  70. //
  71. BOOLEAN DcInRootDomain = FALSE;
  72. //
  73. // Queue of name/sid lookup activities.
  74. //
  75. LSAP_DB_LOOKUP_WORK_QUEUE LookupWorkQueue;
  76. //
  77. // LSA Database Object SubKey Unicode name string and attributes array
  78. //
  79. UNICODE_STRING LsapDbNames[DummyLastName];
  80. PLSAP_DB_DS_INFO LsapDbDsAttInfo;
  81. //
  82. // LSA Database Object Type Containing Directory Names
  83. //
  84. UNICODE_STRING LsapDbContDirs[DummyLastObject];
  85. //
  86. // Object Information Requirements. These arrays, indexed by object
  87. // type id indicated whether objects have Sids or Names.
  88. //
  89. // WARNING! - These arrays must be kept in sync with the LSAP_DB_OBJECT_TYPE_ID
  90. // enumerated type.
  91. //
  92. BOOLEAN LsapDbRequiresSidInfo[DummyLastObject] = {
  93. FALSE, // NullObject
  94. FALSE, // LsaDatabaseObject
  95. FALSE, // BuiltInAccountObject
  96. TRUE, // AccountObject
  97. FALSE // SecretObject
  98. };
  99. BOOLEAN LsapDbRequiresNameInfo[DummyLastObject] = {
  100. FALSE, // NullObject,
  101. TRUE, // LsaDatabaseObject
  102. TRUE, // BuiltInAccountObject
  103. FALSE, // AccountObject
  104. TRUE // SecretObject
  105. };
  106. //
  107. // Table of accesses required to query Policy Information. This table
  108. // is indexed by Policy Information Class
  109. //
  110. ACCESS_MASK LsapDbRequiredAccessQueryPolicy[PolicyDnsDomainInformationInt + 1] = {
  111. 0, // Information classes start at 1
  112. POLICY_VIEW_AUDIT_INFORMATION, // PolicyAuditLogInformation
  113. POLICY_VIEW_AUDIT_INFORMATION, // PolicyAuditEventsInformation
  114. POLICY_VIEW_LOCAL_INFORMATION, // PolicyPrimaryDomainInformation
  115. POLICY_GET_PRIVATE_INFORMATION, // PolicyPdAccountInformation
  116. POLICY_VIEW_LOCAL_INFORMATION, // PolicyAccountDomainInformation
  117. POLICY_VIEW_LOCAL_INFORMATION, // PolicyLsaServerRoleInformation
  118. POLICY_VIEW_LOCAL_INFORMATION, // PolicyReplicaSourceInformation
  119. POLICY_VIEW_LOCAL_INFORMATION, // PolicyDefaultQuotaInformation
  120. 0, // Not settable by non-trusted call
  121. 0, // Not applicable
  122. POLICY_VIEW_AUDIT_INFORMATION, // PolicyAuditFullQueryInformation
  123. POLICY_VIEW_LOCAL_INFORMATION, // PolicyDnsDomainInformation
  124. POLICY_VIEW_LOCAL_INFORMATION, // PolicyDnsDomainInformationInt
  125. };
  126. ACCESS_MASK LsapDbRequiredAccessQueryDomainPolicy[PolicyDomainKerberosTicketInformation + 1] = {
  127. 0, // Information classes start at 2
  128. 0, // PolicyDomainQualityOfServiceInformation (outdated)
  129. POLICY_VIEW_LOCAL_INFORMATION, // PolicyDomainEfsInformation
  130. POLICY_VIEW_LOCAL_INFORMATION // PolicyDomainKerberosTicketInformation
  131. };
  132. //
  133. // Table of accesses required to set Policy Information. This table
  134. // is indexed by Policy Information Class
  135. //
  136. ACCESS_MASK LsapDbRequiredAccessSetPolicy[PolicyDnsDomainInformationInt + 1] = {
  137. 0, // Information classes start at 1
  138. POLICY_AUDIT_LOG_ADMIN, // PolicyAuditLogInformation
  139. POLICY_SET_AUDIT_REQUIREMENTS, // PolicyAuditEventsInformation
  140. POLICY_TRUST_ADMIN, // PolicyPrimaryDomainInformation
  141. 0, // Not settable by non-trusted call
  142. POLICY_TRUST_ADMIN, // PolicyAccountDomainInformation
  143. POLICY_SERVER_ADMIN, // PolicyLsaServerRoleInformation
  144. POLICY_SERVER_ADMIN, // PolicyReplicaSourceInformation
  145. POLICY_SET_DEFAULT_QUOTA_LIMITS,// PolicyDefaultQuotaInformation
  146. 0, // Not settable by non-trusted call
  147. POLICY_AUDIT_LOG_ADMIN, // PolicyAuditFullSetInformation
  148. 0, // Not applicable
  149. POLICY_TRUST_ADMIN, // PolicyDnsDomainInformation
  150. POLICY_TRUST_ADMIN, // PolicyDnsDomainInformationInt
  151. };
  152. ACCESS_MASK LsapDbRequiredAccessSetDomainPolicy[PolicyDomainKerberosTicketInformation + 1] = {
  153. 0, // Information classes start at 2
  154. 0, // PolicyDomainQualityOfServiceInformation (outdated)
  155. POLICY_SERVER_ADMIN, // PolicyDomainEfsInformation
  156. POLICY_SERVER_ADMIN // PolicyDomainKerberosTicketInformation
  157. };
  158. //
  159. // Table of accesses required to query TrustedDomain Information. This table
  160. // is indexed by TrustedDomain Information Class
  161. //
  162. ACCESS_MASK LsapDbRequiredAccessQueryTrustedDomain[TrustedDomainFullInformation2Internal + 1] = {
  163. 0, // Information classes start at 1
  164. TRUSTED_QUERY_DOMAIN_NAME, // TrustedDomainNameInformation
  165. TRUSTED_QUERY_CONTROLLERS, // TrustedControllersInformation
  166. TRUSTED_QUERY_POSIX, // TrustedPosixOffsetInformation
  167. TRUSTED_QUERY_AUTH, // TrustedPasswordInformation
  168. TRUSTED_QUERY_DOMAIN_NAME, // TrustedDomainInformationBasic
  169. TRUSTED_QUERY_DOMAIN_NAME, // TrustedDomainInformationEx
  170. TRUSTED_QUERY_AUTH, // TrustedDomainAuthInformation
  171. TRUSTED_QUERY_DOMAIN_NAME |
  172. TRUSTED_QUERY_POSIX |
  173. TRUSTED_QUERY_AUTH, // TrustedDomainFullInformation
  174. TRUSTED_QUERY_AUTH, // TrustedDomainAuthInformationInternal
  175. TRUSTED_QUERY_DOMAIN_NAME |
  176. TRUSTED_QUERY_POSIX |
  177. TRUSTED_QUERY_AUTH, // TrustedDomainFullInformationInternal
  178. TRUSTED_QUERY_DOMAIN_NAME, // TrustedDomainInformationEx2Internal
  179. TRUSTED_QUERY_DOMAIN_NAME |
  180. TRUSTED_QUERY_POSIX |
  181. TRUSTED_QUERY_AUTH // TrustedDomainFullInformation2Internal
  182. };
  183. //
  184. // Table of accesses required to set TrustedDomain Information. This table
  185. // is indexed by TrustedDomain Information Class
  186. //
  187. ACCESS_MASK LsapDbRequiredAccessSetTrustedDomain[TrustedDomainFullInformation2Internal + 1] = {
  188. 0, // Information classes start at 1
  189. 0, // not settable (TrustedDomainNameInformation)
  190. TRUSTED_SET_CONTROLLERS, // TrustedControllersInformation
  191. TRUSTED_SET_POSIX, // TrustedPosixOffsetInformation
  192. TRUSTED_SET_AUTH, // TrustedPasswordInformation
  193. TRUSTED_SET_POSIX, // TrustedDomainInformationBasic POSIX is a bad bit, but its too late to change it
  194. TRUSTED_SET_POSIX, // TrustedDomainInformationEx POSIX is a bad bit, but its too late to change it
  195. TRUSTED_SET_AUTH, // TrustedDomainAuthInformation
  196. TRUSTED_SET_POSIX |
  197. TRUSTED_SET_AUTH, // TrustedDomainFullInformation
  198. TRUSTED_SET_AUTH, // TrustedDomainAuthInformationInternal
  199. TRUSTED_SET_POSIX |
  200. TRUSTED_SET_POSIX |
  201. TRUSTED_SET_AUTH, // TrustedDomainFullInformationInternal
  202. TRUSTED_SET_POSIX, // TrustedDomainInformationEx2Internal POSIX is a bad bit, but its too late to change it
  203. TRUSTED_SET_POSIX |
  204. TRUSTED_SET_AUTH // TrustedDomainFullInformation2Internal
  205. };
  206. //
  207. // Cached Policy Object. Only default Quota Limits is cached just now.
  208. //
  209. LSAP_DB_POLICY LsapDbPolicy = {0};