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.

138 lines
3.9 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File: postsrv.cpp
  6. //
  7. // Contents: Post service initialize routine
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #include "pch.cpp"
  13. #include "postsrv.h"
  14. #include "tlsjob.h"
  15. #include "globals.h"
  16. #include "init.h"
  17. extern BOOL g_bReportToSCM;
  18. DWORD
  19. PostServiceInit()
  20. {
  21. DWORD dwStatus = ERROR_SUCCESS;
  22. FILETIME ftTime;
  23. HRESULT hrStatus = NULL;
  24. BOOL fInDomain;
  25. //
  26. // Initialize work manager
  27. //
  28. dwStatus = TLSWorkManagerInit();
  29. hrStatus = g_pWriter->Initialize (); // files to exclude
  30. if (FAILED (hrStatus))
  31. {
  32. DBGPrintf(
  33. DBG_INFORMATION,
  34. DBG_FACILITY_INIT,
  35. DBGLEVEL_FUNCTION_DETAILSIMPLE,
  36. _TEXT("CVssJetWriter::Initialize failed with error code %08x...\n"),
  37. hrStatus
  38. );
  39. }
  40. if(dwStatus != ERROR_SUCCESS)
  41. {
  42. TLSLogEvent(
  43. EVENTLOG_ERROR_TYPE,
  44. TLS_E_WORKMANAGERGENERAL,
  45. TLS_E_WORKMANAGER_STARTUP,
  46. dwStatus
  47. );
  48. dwStatus = TLS_E_SERVICE_STARTUP_WORKMANAGER;
  49. return dwStatus;
  50. }
  51. //
  52. // Initialize namedpipe for client to test connect
  53. //
  54. dwStatus = InitNamedPipeThread();
  55. if(dwStatus != ERROR_SUCCESS)
  56. {
  57. TLSLogErrorEvent(TLS_E_SERVICE_STARTUP_CREATE_THREAD);
  58. dwStatus = TLS_E_SERVICE_STARTUP_CREATE_THREAD;
  59. return dwStatus;
  60. }
  61. if ((!(GetLicenseServerRole() & TLSERVER_ENTERPRISE_SERVER))
  62. && (ERROR_SUCCESS == TLSInDomain(&fInDomain,NULL) && (!fInDomain)))
  63. {
  64. //
  65. // Initialize mailslot thread to receive broadcast
  66. //
  67. dwStatus = InitMailSlotThread();
  68. if(dwStatus != ERROR_SUCCESS)
  69. {
  70. TLSLogErrorEvent(TLS_E_SERVICE_STARTUP_CREATE_THREAD);
  71. dwStatus = TLS_E_SERVICE_STARTUP_CREATE_THREAD;
  72. return dwStatus;
  73. }
  74. }
  75. //
  76. // Initialize thread to put expired permanent licenses back in pool
  77. //
  78. dwStatus = InitExpirePermanentThread();
  79. if(dwStatus != ERROR_SUCCESS)
  80. {
  81. TLSLogErrorEvent(TLS_E_SERVICE_STARTUP_CREATE_THREAD);
  82. dwStatus = TLS_E_SERVICE_STARTUP_CREATE_THREAD;
  83. return dwStatus;
  84. }
  85. DBGPrintf(
  86. DBG_INFORMATION,
  87. DBG_FACILITY_INIT,
  88. DBGLEVEL_FUNCTION_TRACE,
  89. _TEXT("Server is %s (0x%08x)\n"),
  90. (IS_ENFORCE_SERVER(TLS_CURRENT_VERSION)) ? _TEXT("Enforce") : _TEXT("Non-Enforce"),
  91. IS_ENFORCE_SERVER(TLS_CURRENT_VERSION)
  92. );
  93. // must be running as service and not in debug mode
  94. if(g_bReportToSCM == TRUE)
  95. {
  96. if(!(GetLicenseServerRole() & TLSERVER_ENTERPRISE_SERVER))
  97. {
  98. GetServiceLastShutdownTime(&ftTime);
  99. dwStatus = TLSStartAnnounceLicenseServerJob(
  100. g_pszServerPid,
  101. g_szScope,
  102. g_szComputerName,
  103. &ftTime
  104. );
  105. if(dwStatus != ERROR_SUCCESS)
  106. {
  107. return dwStatus;
  108. }
  109. }
  110. GetServiceLastShutdownTime(&ftTime);
  111. dwStatus = TLSStartAnnounceToEServerJob(
  112. g_pszServerPid,
  113. g_szScope,
  114. g_szComputerName,
  115. &ftTime
  116. );
  117. }
  118. ServiceInitPolicyModule();
  119. return dwStatus;
  120. }