Author: ekohl
Date: Sun Sep 12 16:29:43 2010
New Revision: 48757
URL:
http://svn.reactos.org/svn/reactos?rev=48757&view=rev
Log:
Make Services.exe and Winlogon.exe wait for the LSA server to be up and running. Otherwise
calls to any LSA function might fail.
Thanks to Roel Messiant for testing and analyzing the debug logs.
See issue #5497 for more details.
Modified:
trunk/reactos/base/system/services/services.c
trunk/reactos/base/system/winlogon/winlogon.c
trunk/reactos/dll/win32/lsasrv/lsasrv.c
Modified: trunk/reactos/base/system/services/services.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
==============================================================================
--- trunk/reactos/base/system/services/services.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/services.c [iso-8859-1] Sun Sep 12 16:29:43 2010
@@ -80,6 +80,42 @@
}
+static VOID
+ScmWaitForLsass(VOID)
+{
+ HANDLE hEvent;
+ DWORD dwError;
+
+ hEvent = CreateEventW(NULL,
+ TRUE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent == NULL)
+ {
+ dwError = GetLastError();
+ DPRINT("Failed to create the notication event (Error %lu)\n",
dwError);
+
+ if (dwError == ERROR_ALREADY_EXISTS)
+ {
+ hEvent = OpenEventW(SYNCHRONIZE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent == NULL)
+ {
+ DPRINT1("Could not open the notification event (Error %lu)\n",
GetLastError());
+ return;
+ }
+ }
+ }
+
+ DPRINT("Wait for the LSA server!\n");
+ WaitForSingleObject(hEvent, INFINITE);
+ DPRINT("LSA server running!\n");
+
+ CloseHandle(hEvent);
+}
+
+
BOOL
ScmNamedPipeHandleRequest(PVOID Request,
DWORD RequestSize,
@@ -304,9 +340,6 @@
DPRINT("SERVICES: Service Control Manager\n");
- /* Acquire privileges to load drivers */
- AcquireLoadDriverPrivilege();
-
/* Create start event */
if (!ScmCreateStartEvent(&hScmStartEvent))
{
@@ -345,6 +378,12 @@
/* Register event handler (used for system shutdown) */
SetConsoleCtrlHandler(ShutdownHandlerRoutine, TRUE);
+
+ /* Wait for the LSA server */
+ ScmWaitForLsass();
+
+ /* Acquire privileges to load drivers */
+ AcquireLoadDriverPrivilege();
/* Start auto-start services */
ScmAutoStartServices();
Modified: trunk/reactos/base/system/winlogon/winlogon.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/winlo…
==============================================================================
--- trunk/reactos/base/system/winlogon/winlogon.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/winlogon/winlogon.c [iso-8859-1] Sun Sep 12 16:29:43 2010
@@ -198,6 +198,43 @@
return res;
}
+
+
+static VOID
+WaitForLsass(VOID)
+{
+ HANDLE hEvent;
+ DWORD dwError;
+
+ hEvent = CreateEventW(NULL,
+ TRUE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent == NULL)
+ {
+ dwError = GetLastError();
+ TRACE("WL: Failed to create the notication event (Error %lu)\n",
dwError);
+
+ if (dwError == ERROR_ALREADY_EXISTS)
+ {
+ hEvent = OpenEventW(SYNCHRONIZE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent == NULL)
+ {
+ ERR("WL: Could not open the notification event (Error %lu)\n",
GetLastError());
+ return;
+ }
+ }
+ }
+
+ TRACE("WL: Wait for the LSA server!\n");
+ WaitForSingleObject(hEvent, INFINITE);
+ TRACE("WL: LSA server running!\n");
+
+ CloseHandle(hEvent);
+}
+
BOOL
DisplayStatusMessage(
@@ -348,6 +385,10 @@
DisplayStatusMessage(WLSession, WLSession->WinlogonDesktop,
IDS_REACTOSISSTARTINGUP);
+
+ /* Wait for the LSA server */
+ WaitForLsass();
+
#if 0
/* Connect to NetLogon service (lsass.exe) */
/* Real winlogon uses "Winlogon" */
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.c?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.c [iso-8859-1] Sun Sep 12 16:29:43 2010
@@ -45,9 +45,10 @@
hEvent = OpenEventW(GENERIC_WRITE,
FALSE,
L"LSA_RPC_SERVER_ACTIVE");
- if (hEvent != NULL)
+ if (hEvent == NULL)
{
- ERR("Could not open the notification event!");
+ ERR("Could not open the notification event (Error %lu)\n",
GetLastError());
+ return STATUS_UNSUCCESSFUL;
}
}
}