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.

195 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. rmvars.c
  5. Abstract:
  6. This module contains the variables used to implement the run-time
  7. reference monitor database.
  8. Author:
  9. Jim Kelly (JimK) 2-Apr-1991
  10. Environment:
  11. Kernel mode only.
  12. Revision History:
  13. --*/
  14. #include "pch.h"
  15. #pragma hdrstop
  16. #ifdef ALLOC_PRAGMA
  17. #pragma alloc_text(INIT,SepRmDbInitialization)
  18. #endif
  19. ////////////////////////////////////////////////////////////////////////////////
  20. // //
  21. // Read/Write Reference Monitor Variables //
  22. // //
  23. // Access to these variables is protected by the SepRmDbLock. //
  24. // //
  25. ////////////////////////////////////////////////////////////////////////////////
  26. //
  27. // Resource Lock - This lock protects access to the modifiable fields of
  28. // the reference monitor database
  29. //
  30. ERESOURCE SepRmDbLock = {0};
  31. #ifdef ALLOC_DATA_PRAGMA
  32. #pragma data_seg("PAGEDATA")
  33. #endif
  34. ////////////////////////////////////////////////////////////////////////////////
  35. // //
  36. // Read Only Reference Monitor Variables //
  37. // //
  38. ////////////////////////////////////////////////////////////////////////////////
  39. //
  40. // The process within which the RM --> LSA command LPC port was established.
  41. // All calls from the reference monitor to the LSA must be made in this
  42. // process in order for the handle to be valid.
  43. PEPROCESS SepRmLsaCallProcess = NULL;
  44. //
  45. // State of the reference monitor
  46. //
  47. SEP_RM_STATE SepRmState = {0};
  48. //
  49. // The following array is used as a hash bucket for tracking logon sessions.
  50. // The sequence number of logon LUIDs is ANDed with 0x0F and then used as an
  51. // index into this array. This entry in the array serves as a listhead of
  52. // logon session reference count records.
  53. //
  54. PSEP_LOGON_SESSION_REFERENCES *SepLogonSessions = NULL;
  55. ////////////////////////////////////////////////////////////////////////
  56. // //
  57. // Variable Initialization Routines //
  58. // //
  59. ////////////////////////////////////////////////////////////////////////
  60. BOOLEAN
  61. SepRmDbInitialization(
  62. VOID
  63. )
  64. /*++
  65. Routine Description:
  66. This function initializes the reference monitor in-memory database.
  67. Arguments:
  68. None.
  69. Return Value:
  70. TRUE if database successfully initialized.
  71. FALSE if not successfully initialized.
  72. --*/
  73. {
  74. NTSTATUS Status;
  75. ULONG i;
  76. //
  77. // Create the reference monitor database lock
  78. //
  79. // Use SepRmAcquireDbReadLock()
  80. // SepRmAcquireDbWriteLock()
  81. // SepRmReleaseDbReadLock()
  82. // SepRmReleaseDbWriteLock()
  83. //
  84. // to gain access to the reference monitor database.
  85. //
  86. ExInitializeResourceLite(&SepRmDbLock);
  87. //
  88. // Initialize the Logon Session tracking array.
  89. //
  90. SepLogonSessions = ExAllocatePoolWithTag( PagedPool,
  91. sizeof( PSEP_LOGON_SESSION_REFERENCES ) * SEP_LOGON_TRACK_ARRAY_SIZE,
  92. 'SLeS'
  93. );
  94. if (SepLogonSessions == NULL) {
  95. return( FALSE );
  96. }
  97. for (i=0;i<SEP_LOGON_TRACK_ARRAY_SIZE;i++) {
  98. SepLogonSessions[ i ] = NULL;
  99. }
  100. //
  101. // Now add in a record representing the system logon session.
  102. //
  103. Status = SepCreateLogonSessionTrack( (PLUID)&SeSystemAuthenticationId );
  104. ASSERT( NT_SUCCESS(Status) );
  105. if ( !NT_SUCCESS(Status)) {
  106. return FALSE;
  107. }
  108. //
  109. // Add one for the null session logon session
  110. //
  111. Status = SepCreateLogonSessionTrack( (PLUID)&SeAnonymousAuthenticationId );
  112. ASSERT( NT_SUCCESS(Status) );
  113. if ( !NT_SUCCESS(Status)) {
  114. return FALSE;
  115. }
  116. //
  117. // The correct RM state will be set when the local security policy
  118. // information is retrieved (by the LSA) and subsequently passed to
  119. // the reference monitor later on in initialization. For now, initialize
  120. // the state to something that will work for the remainder of
  121. // system initialization.
  122. //
  123. SepRmState.AuditingEnabled = 0; // auditing state disabled.
  124. SepRmState.OperationalMode = LSA_MODE_PASSWORD_PROTECTED;
  125. return TRUE;
  126. }