mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 09:43:04 +00:00
Do not start LSASS as a service but as an ordinary process because:
1) LSASS and the NetLogon service are not the same. 2) The service manager must wait for LSASS to finish initialization. If LSASS is started as a service we will have a classic deadlock scenario. svn path=/trunk/; revision=38041
This commit is contained in:
parent
fc635826a5
commit
8fb679dc7c
4 changed files with 58 additions and 88 deletions
|
@ -37,23 +37,6 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static VOID CALLBACK
|
|
||||||
ServiceMain(DWORD argc, LPTSTR *argv);
|
|
||||||
|
|
||||||
static SERVICE_TABLE_ENTRY ServiceTable[2] =
|
|
||||||
{
|
|
||||||
{TEXT("NetLogon"), ServiceMain},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static VOID CALLBACK
|
|
||||||
ServiceMain(
|
|
||||||
IN DWORD argc,
|
|
||||||
IN LPWSTR *argv)
|
|
||||||
{
|
|
||||||
DPRINT("ServiceMain() called\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
INT WINAPI
|
INT WINAPI
|
||||||
wWinMain(
|
wWinMain(
|
||||||
IN HINSTANCE hInstance,
|
IN HINSTANCE hInstance,
|
||||||
|
@ -86,8 +69,6 @@ wWinMain(
|
||||||
|
|
||||||
/* FIXME: More initialization */
|
/* FIXME: More initialization */
|
||||||
|
|
||||||
StartServiceCtrlDispatcher(ServiceTable);
|
|
||||||
|
|
||||||
DPRINT(" Done...\n");
|
DPRINT(" Done...\n");
|
||||||
|
|
||||||
ByeBye:
|
ByeBye:
|
||||||
|
|
|
@ -89,70 +89,39 @@ StartServicesManager(VOID)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
|
||||||
StartCustomService(
|
|
||||||
IN LPCWSTR ServiceName)
|
|
||||||
{
|
|
||||||
SC_HANDLE hSCManager = NULL;
|
|
||||||
SC_HANDLE hService = NULL;
|
|
||||||
BOOL ret = FALSE;
|
|
||||||
|
|
||||||
hSCManager = OpenSCManager(NULL, NULL, 0);
|
|
||||||
if (!hSCManager)
|
|
||||||
{
|
|
||||||
ERR("WL: Failed to OpenSCManager\n");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
hService = OpenServiceW(hSCManager, ServiceName, SERVICE_START);
|
|
||||||
if (!hService)
|
|
||||||
{
|
|
||||||
ERR("WL: Failed to open the service\n");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (!StartServiceW(hService, 0, NULL))
|
|
||||||
{
|
|
||||||
ERR("WL: Failed to start the service\n");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (hService)
|
|
||||||
CloseServiceHandle(hService);
|
|
||||||
if (hSCManager)
|
|
||||||
CloseServiceHandle(hSCManager);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
StartLsass(VOID)
|
StartLsass(VOID)
|
||||||
{
|
{
|
||||||
HANDLE LsassInitEvent;
|
STARTUPINFOW StartupInfo;
|
||||||
|
PROCESS_INFORMATION ProcessInformation;
|
||||||
|
LPCWSTR ServiceString = L"lsass.exe";
|
||||||
|
BOOL res;
|
||||||
|
|
||||||
LsassInitEvent = CreateEventW(
|
/* Start the service control manager (services.exe) */
|
||||||
|
StartupInfo.cb = sizeof(StartupInfo);
|
||||||
|
StartupInfo.lpReserved = NULL;
|
||||||
|
StartupInfo.lpDesktop = NULL;
|
||||||
|
StartupInfo.lpTitle = NULL;
|
||||||
|
StartupInfo.dwFlags = 0;
|
||||||
|
StartupInfo.cbReserved2 = 0;
|
||||||
|
StartupInfo.lpReserved2 = 0;
|
||||||
|
|
||||||
|
TRACE("WL: Creating new process - %S\n", ServiceString);
|
||||||
|
|
||||||
|
res = CreateProcessW(
|
||||||
|
ServiceString,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
TRUE,
|
|
||||||
FALSE,
|
FALSE,
|
||||||
L"Global\\SECURITY_SERVICES_STARTED");
|
DETACHED_PROCESS,
|
||||||
if (!LsassInitEvent)
|
NULL,
|
||||||
{
|
NULL,
|
||||||
ERR("WL: Failed to create lsass notification event (error %lu)\n", GetLastError());
|
&StartupInfo,
|
||||||
return FALSE;
|
&ProcessInformation);
|
||||||
}
|
|
||||||
|
|
||||||
/* Start the local security authority subsystem (Netlogon service) */
|
return res;
|
||||||
if (!StartCustomService(L"Netlogon"))
|
|
||||||
{
|
|
||||||
ERR("WL: Failed to start NetLogon service (error %lu)\n", GetLastError());
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
WaitForSingleObject(LsassInitEvent, INFINITE);
|
|
||||||
CloseHandle(LsassInitEvent);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
|
|
|
@ -968,12 +968,12 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Ndis","Start",0x00010001,0x00000000
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\Ndis","Type",0x00010001,0x00000001
|
HKLM,"SYSTEM\CurrentControlSet\Services\Ndis","Type",0x00010001,0x00000001
|
||||||
|
|
||||||
; NetLogon
|
; NetLogon
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\NetLogon","DisplayName",0x00000000,"Net Logon"
|
;HKLM,"SYSTEM\CurrentControlSet\Services\NetLogon","DisplayName",0x00000000,"Net Logon"
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\NetLogon","Description",0x00000000,"Sets up a secure channel to a domain controller for domain authentication"
|
;HKLM,"SYSTEM\CurrentControlSet\Services\NetLogon","Description",0x00000000,"Sets up a secure channel to a domain controller for domain authentication"
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\NetLogon","ErrorControl",0x00010001,0x00000001
|
;HKLM,"SYSTEM\CurrentControlSet\Services\NetLogon","ErrorControl",0x00010001,0x00000001
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\Netlogon","ImagePath",0x00020000,"%SystemRoot%\system32\lsass.exe"
|
;HKLM,"SYSTEM\CurrentControlSet\Services\Netlogon","ImagePath",0x00020000,"%SystemRoot%\system32\lsass.exe"
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\NetLogon","Start",0x00010001,0x00000003
|
;HKLM,"SYSTEM\CurrentControlSet\Services\NetLogon","Start",0x00010001,0x00000003
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\Netlogon","Type",0x00010001,0x00000020
|
;HKLM,"SYSTEM\CurrentControlSet\Services\Netlogon","Type",0x00010001,0x00000020
|
||||||
|
|
||||||
; Named Pipe filesystem driver
|
; Named Pipe filesystem driver
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\Npfs","ErrorControl",0x00010001,0x00000000
|
HKLM,"SYSTEM\CurrentControlSet\Services\Npfs","ErrorControl",0x00010001,0x00000000
|
||||||
|
@ -1127,6 +1127,6 @@ HKLM,"SYSTEM\Setup","SystemPartition",0x00000000,"\Device\Harddisk0\Partition1"
|
||||||
HKLM,"SYSTEM\Setup","SystemSetupInProgress",0x00010001,0x00000001
|
HKLM,"SYSTEM\Setup","SystemSetupInProgress",0x00010001,0x00000001
|
||||||
|
|
||||||
; Debug channels
|
; Debug channels
|
||||||
;HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Environment","DEBUGCHANNEL",0x00020000,"+ole,+rpc"
|
HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Environment","DEBUGCHANNEL",0x00020000,"+lsasrv,+advapi"
|
||||||
|
|
||||||
; EOF
|
; EOF
|
||||||
|
|
|
@ -14,19 +14,39 @@ NTSTATUS WINAPI
|
||||||
LsapInitLsa(VOID)
|
LsapInitLsa(VOID)
|
||||||
{
|
{
|
||||||
HANDLE hEvent;
|
HANDLE hEvent;
|
||||||
|
DWORD dwError;
|
||||||
|
|
||||||
TRACE("LsapInitLsa()\n");
|
TRACE("LsapInitLsa()\n");
|
||||||
|
|
||||||
|
/* Start the RPC server */
|
||||||
LsarStartRpcServer();
|
LsarStartRpcServer();
|
||||||
|
|
||||||
hEvent = OpenEventW(EVENT_MODIFY_STATE,
|
/* Notify the service manager */
|
||||||
FALSE,
|
hEvent = CreateEventW(NULL,
|
||||||
L"Global\\SECURITY_SERVICES_STARTED");
|
TRUE,
|
||||||
if (hEvent != NULL)
|
FALSE,
|
||||||
|
L"LSA_RPC_SERVER_ACTIVE");
|
||||||
|
if (hEvent == NULL)
|
||||||
{
|
{
|
||||||
SetEvent(hEvent);
|
dwError = GetLastError();
|
||||||
CloseHandle(hEvent);
|
TRACE("Failed to create the notication event (Error %lu)\n", dwError);
|
||||||
|
|
||||||
|
if (dwError == ERROR_ALREADY_EXISTS)
|
||||||
|
{
|
||||||
|
hEvent = OpenEventW(GENERIC_WRITE,
|
||||||
|
FALSE,
|
||||||
|
L"LSA_RPC_SERVER_ACTIVE");
|
||||||
|
if (hEvent != NULL)
|
||||||
|
{
|
||||||
|
ERR("Could not open the notification event!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetEvent(hEvent);
|
||||||
|
|
||||||
|
/* NOTE: Do not close the event handle!!!! */
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue