https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c901c3d37fd929d768e53…
commit c901c3d37fd929d768e5378bb35e05921a5cddd3
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Tue Jun 26 22:19:40 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Jun 27 23:40:16 2018 +0200
[LSASRV] Move the LSA_RPC_SERVER_ACTIVE event creation to a better place, in
LsarStartRpcServer().
---
dll/win32/lsasrv/lookup.c | 1 -
dll/win32/lsasrv/lsarpc.c | 42 ++++++++++++++++++++++++++++++++++++++----
dll/win32/lsasrv/lsasrv.c | 36 +++++-------------------------------
dll/win32/lsasrv/lsasrv.h | 2 +-
4 files changed, 44 insertions(+), 37 deletions(-)
diff --git a/dll/win32/lsasrv/lookup.c b/dll/win32/lsasrv/lookup.c
index b0805ebc0f..79cbffca57 100644
--- a/dll/win32/lsasrv/lookup.c
+++ b/dll/win32/lsasrv/lookup.c
@@ -182,7 +182,6 @@ LsapInitSids(VOID)
hInstance = GetModuleHandleW(L"lsasrv.dll");
/* NT Authority */
-
LsapLoadString(hInstance, IDS_NT_AUTHORITY, szAccountName,
ARRAYSIZE(szAccountName));
LsapLoadString(hInstance, IDS_NT_AUTHORITY, szDomainName, ARRAYSIZE(szDomainName));
LsapCreateSid(&NtAuthority,
diff --git a/dll/win32/lsasrv/lsarpc.c b/dll/win32/lsasrv/lsarpc.c
index 4b9ef392c2..5f314e8c2b 100644
--- a/dll/win32/lsasrv/lsarpc.c
+++ b/dll/win32/lsasrv/lsarpc.c
@@ -36,10 +36,12 @@ LsapSecretMapping = {SECRET_READ,
/* FUNCTIONS ***************************************************************/
-VOID
+NTSTATUS
LsarStartRpcServer(VOID)
{
RPC_STATUS Status;
+ DWORD dwError;
+ HANDLE hEvent;
RtlInitializeCriticalSection(&PolicyHandleTableLock);
@@ -52,7 +54,7 @@ LsarStartRpcServer(VOID)
if (Status != RPC_S_OK)
{
WARN("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
- return;
+ return I_RpcMapWin32Status(Status);
}
Status = RpcServerRegisterIf(lsarpc_v0_0_s_ifspec,
@@ -61,7 +63,7 @@ LsarStartRpcServer(VOID)
if (Status != RPC_S_OK)
{
WARN("RpcServerRegisterIf() failed (Status %lx)\n", Status);
- return;
+ return I_RpcMapWin32Status(Status);
}
DsSetupInit();
@@ -70,10 +72,42 @@ LsarStartRpcServer(VOID)
if (Status != RPC_S_OK)
{
WARN("RpcServerListen() failed (Status %lx)\n", Status);
- return;
+ return I_RpcMapWin32Status(Status);
}
+ /* Notify the service manager */
+ TRACE("Creating notification event!\n");
+ hEvent = CreateEventW(NULL,
+ TRUE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent == NULL)
+ {
+ dwError = GetLastError();
+ TRACE("Failed to create or open the notification event (Error %lu)\n",
dwError);
+#if 0
+ 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 (Error %lu)\n",
GetLastError());
+ return STATUS_UNSUCCESSFUL;
+ }
+ }
+#endif
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ TRACE("Set notification event!\n");
+ SetEvent(hEvent);
+
+ /* NOTE: Do not close the event handle, as it must remain alive! */
+
TRACE("LsarStartRpcServer() done\n");
+ return STATUS_SUCCESS;
}
diff --git a/dll/win32/lsasrv/lsasrv.c b/dll/win32/lsasrv/lsasrv.c
index 12fac372d8..e2a28bd600 100644
--- a/dll/win32/lsasrv/lsasrv.c
+++ b/dll/win32/lsasrv/lsasrv.c
@@ -271,8 +271,6 @@ LsaIFree_LSAPR_TRANSLATED_SIDS(
NTSTATUS WINAPI
LsapInitLsa(VOID)
{
- HANDLE hEvent;
- DWORD dwError;
NTSTATUS Status;
TRACE("LsapInitLsa() called\n");
@@ -302,7 +300,7 @@ LsapInitLsa(VOID)
return Status;
}
- /* Start the authentication port thread */
+ /* Start the authentication LPC port thread */
Status = StartAuthenticationPort();
if (!NT_SUCCESS(Status))
{
@@ -311,37 +309,13 @@ LsapInitLsa(VOID)
}
/* Start the RPC server */
- LsarStartRpcServer();
-
- TRACE("Creating notification event!\n");
- /* Notify the service manager */
- hEvent = CreateEventW(NULL,
- TRUE,
- FALSE,
- L"LSA_RPC_SERVER_ACTIVE");
- if (hEvent == NULL)
+ Status = LsarStartRpcServer();
+ if (!NT_SUCCESS(Status))
{
- dwError = GetLastError();
- TRACE("Failed to create the notification 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 (Error %lu)\n",
GetLastError());
- return STATUS_UNSUCCESSFUL;
- }
- }
+ ERR("LsarStartRpcServer() failed (Status 0x%08lx)\n", Status);
+ return Status;
}
- TRACE("Set notification event!\n");
- SetEvent(hEvent);
-
- /* NOTE: Do not close the event handle!!!! */
-
return STATUS_SUCCESS;
}
diff --git a/dll/win32/lsasrv/lsasrv.h b/dll/win32/lsasrv/lsasrv.h
index 4bc0673c71..8a772aba21 100644
--- a/dll/win32/lsasrv/lsasrv.h
+++ b/dll/win32/lsasrv/lsasrv.h
@@ -206,7 +206,7 @@ LsapLookupSids(PLSAPR_SID_ENUM_BUFFER SidEnumBuffer,
DWORD ClientRevision);
/* lsarpc.c */
-VOID
+NTSTATUS
LsarStartRpcServer(VOID);
/* policy.c */