Author: ekohl
Date: Mon Dec 28 12:59:20 2009
New Revision: 44793
URL:
http://svn.reactos.org/svn/reactos?rev=44793&view=rev
Log:
- Lsasrv: Create the LsaAuthenticationPort and add a basic server loop that listens to
incoming requests.
- Lsalib: Combine request and reply data of the register request into a connection info
struct.
My test application can now connect to the LsaAuthenticationPort.
Added:
trunk/reactos/dll/win32/lsasrv/authport.c (with props)
Modified:
trunk/reactos/dll/win32/lsasrv/lsasrv.c
trunk/reactos/dll/win32/lsasrv/lsasrv.h
trunk/reactos/dll/win32/lsasrv/lsasrv.rbuild
trunk/reactos/include/reactos/subsys/lsass/lsass.h
trunk/reactos/lib/lsalib/lsa.c
Added: trunk/reactos/dll/win32/lsasrv/authport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/authport.…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/authport.c (added)
+++ trunk/reactos/dll/win32/lsasrv/authport.c [iso-8859-1] Mon Dec 28 12:59:20 2009
@@ -1,0 +1,139 @@
+/*
+ * PROJECT: Local Security Authority Server DLL
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: dll/win32/lsasrv/authport.c
+ * PURPOSE: LsaAuthenticationPort server routines
+ * COPYRIGHT: Copyright 2009 Eric Kohl
+ */
+
+/* INCLUDES ****************************************************************/
+
+#define WIN32_NO_STATUS
+#include <windows.h>
+#define NTOS_MODE_USER
+#include <ndk/ntndk.h>
+
+#include "lsass.h"
+#include "lsasrv.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(lsasrv);
+
+
+static HANDLE PortThreadHandle = NULL;
+static HANDLE AuthPortHandle = NULL;
+
+
+/* FUNCTIONS ***************************************************************/
+
+NTSTATUS WINAPI
+AuthPortThreadRoutine(PVOID Param)
+{
+ LSASS_REQUEST Request;
+ PPORT_MESSAGE Reply = NULL;
+ NTSTATUS Status;
+
+ NTSTATUS Status2;
+
+ HANDLE ConnectionHandle = NULL;
+ PVOID Context = NULL;
+ BOOLEAN Accept;
+
+ TRACE("AuthPortThreadRoutine() called\n");
+
+ Status = STATUS_SUCCESS;
+
+ for (;;)
+ {
+ Status = NtReplyWaitReceivePort(AuthPortHandle,
+ 0,
+ Reply,
+ &Request.Header);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("NtReplyWaitReceivePort() failed (Status %lx)\n", Status);
+ break;
+ }
+
+ TRACE("Received message\n");
+
+ if (Request.Header.u2.s2.Type == LPC_CONNECTION_REQUEST)
+ {
+ TRACE("Port connection request\n");
+
+ Accept = TRUE;
+ Status2 = NtAcceptConnectPort(&ConnectionHandle,
+ &Context,
+ &Request.Header,
+ Accept,
+ NULL,
+ NULL);
+
+
+ Status2 = NtCompleteConnectPort(ConnectionHandle);
+
+ }
+ else if (Request.Header.u2.s2.Type == LPC_PORT_CLOSED ||
+ Request.Header.u2.s2.Type == LPC_CLIENT_DIED)
+ {
+ TRACE("Port closed or client died request\n");
+
+// return STATUS_UNSUCCESSFUL;
+ }
+ else if (Request.Header.u2.s2.Type == LPC_REQUEST)
+ {
+ TRACE("Received request (Type: %lu)\n", Request.Type);
+
+ }
+ else if (Request.Header.u2.s2.Type == LPC_DATAGRAM)
+ {
+ TRACE("Received datagram\n");
+
+ }
+ }
+
+ return Status;
+}
+
+
+NTSTATUS
+StartAuthenticationPort(VOID)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING PortName;
+ DWORD ThreadId;
+ NTSTATUS Status;
+
+ RtlInitUnicodeString(&PortName,
+ L"\\LsaAuthenticationPort");
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &PortName,
+ 0,
+ NULL,
+ NULL);
+
+ Status = NtCreatePort(&AuthPortHandle,
+ &ObjectAttributes,
+ 0,
+ 0x100,
+ 0x2000);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("NtCreatePort() failed (Status %lx)\n", Status);
+ return Status;
+ }
+
+ PortThreadHandle = CreateThread(NULL,
+ 0x1000,
+ (LPTHREAD_START_ROUTINE)AuthPortThreadRoutine,
+ NULL,
+ 0,
+ &ThreadId);
+
+
+ return STATUS_SUCCESS;
+}
+
+/* EOF */
Propchange: trunk/reactos/dll/win32/lsasrv/authport.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/dll/win32/lsasrv/authport.c
------------------------------------------------------------------------------
svn:keywords = author date revision
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] Mon Dec 28 12:59:20 2009
@@ -1,3 +1,13 @@
+/*
+ * PROJECT: Local Security Authority Server DLL
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: dll/win32/lsasrv/lsasrv.c
+ * PURPOSE: Main file
+ * COPYRIGHT: Copyright 2006-2009 Eric Kohl
+ */
+
+/* INCLUDES ****************************************************************/
+
#define WIN32_NO_STATUS
#include <windows.h>
#define NTOS_MODE_USER
@@ -10,17 +20,20 @@
WINE_DEFAULT_DEBUG_CHANNEL(lsasrv);
+/* FUNCTIONS ***************************************************************/
+
NTSTATUS WINAPI
LsapInitLsa(VOID)
{
HANDLE hEvent;
DWORD dwError;
- TRACE("LsapInitLsa()\n");
+ TRACE("LsapInitLsa() called\n");
/* Start the RPC server */
LsarStartRpcServer();
+ TRACE("Creating notification event!\n");
/* Notify the service manager */
hEvent = CreateEventW(NULL,
TRUE,
@@ -43,9 +56,12 @@
}
}
+ TRACE("Set notification event!\n");
SetEvent(hEvent);
/* NOTE: Do not close the event handle!!!! */
+
+ StartAuthenticationPort();
return STATUS_SUCCESS;
}
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Mon Dec 28 12:59:20 2009
@@ -2,11 +2,13 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: Local Security Authority (LSA) Server
* FILE: reactos/dll/win32/lsasrv/lsasrv.h
- * PURPOSE:
+ * PURPOSE: Common header file
*
* PROGRAMMERS: Eric Kohl
*/
+/* authport.c */
+NTSTATUS StartAuthenticationPort(VOID);
+
/* lsarpc.c */
VOID LsarStartRpcServer(VOID);
-
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.rb…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.rbuild [iso-8859-1] Mon Dec 28 12:59:20 2009
@@ -2,11 +2,13 @@
<importlibrary definition="lsasrv.spec" />
<include base="lsasrv">.</include>
<include base="lsa_server">.</include>
+ <include base="ReactOS">include/reactos/subsys/lsass</include>
<library>lsa_server</library>
<library>wine</library>
<library>rpcrt4</library>
<library>ntdll</library>
<library>pseh</library>
+ <file>authport.c</file>
<file>lsarpc.c</file>
<file>lsasrv.c</file>
<file>lsasrv.rc</file>
Modified: trunk/reactos/include/reactos/subsys/lsass/lsass.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/lsa…
==============================================================================
--- trunk/reactos/include/reactos/subsys/lsass/lsass.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/lsass/lsass.h [iso-8859-1] Mon Dec 28 12:59:20
2009
@@ -12,6 +12,8 @@
#define __INCLUDE_LSASS_LSASS_H
#include <ntsecapi.h>
+
+#define LSASS_MAX_LOGON_PROCESS_NAME_LENGTH 127
#define LSASS_REQUEST_REGISTER_LOGON_PROCESS (1)
#define LSASS_REQUEST_CALL_AUTHENTICATION_PACKAGE (2)
@@ -96,6 +98,16 @@
LSA_OPERATIONAL_MODE OperationalMode;
} LSASS_REGISTER_LOGON_PROCESS_REPLY, *PLSASS_REGISTER_LOGON_PROCESS_REPLY;
+
+typedef struct _LSASS_CONNECT_DATA
+{
+ NTSTATUS Status;
+ LSA_OPERATIONAL_MODE OperationalMode;
+ ULONG Length;
+ CHAR LogonProcessNameBuffer[LSASS_MAX_LOGON_PROCESS_NAME_LENGTH + 1];
+} LSASS_CONNECT_DATA, *PLSASS_CONNECT_DATA;
+
+
typedef union _LSASS_REQUEST
{
PORT_MESSAGE Header;
Modified: trunk/reactos/lib/lsalib/lsa.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/lsalib/lsa.c?rev=44793…
==============================================================================
--- trunk/reactos/lib/lsalib/lsa.c [iso-8859-1] (original)
+++ trunk/reactos/lib/lsalib/lsa.c [iso-8859-1] Mon Dec 28 12:59:20 2009
@@ -35,7 +35,7 @@
Request.Header.u1.s1.DataLength = 0;
Request.Header.u1.s1.TotalLength = sizeof(LSASS_REQUEST);
Request.Type = LSASS_REQUEST_DEREGISTER_LOGON_PROCESS;
- Status = NtRequestWaitReplyPort(LsaHandle,
+ Status = ZwRequestWaitReplyPort(LsaHandle,
&Request.Header,
&Reply.Header);
if (!NT_SUCCESS(Status))
@@ -59,7 +59,7 @@
LsaConnectUntrusted(PHANDLE LsaHandle)
{
UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ return STATUS_NOT_IMPLEMENTED;
}
@@ -98,7 +98,7 @@
ProtocolSubmitBuffer,
SubmitBufferLength);
- Status = NtRequestWaitReplyPort(LsaHandle,
+ Status = ZwRequestWaitReplyPort(LsaHandle,
&Request->Header,
&Reply->Header);
if (!NT_SUCCESS(Status))
@@ -154,7 +154,7 @@
sizeof(PORT_MESSAGE);
Request->Type = LSASS_REQUEST_LOOKUP_AUTHENTICATION_PACKAGE;
- Status = NtRequestWaitReplyPort(LsaHandle,
+ Status = ZwRequestWaitReplyPort(LsaHandle,
&Request->Header,
&Reply.Header);
if (!NT_SUCCESS(Status))
@@ -245,7 +245,7 @@
Reply = (PLSASS_REPLY)&RawReply;
- Status = NtRequestWaitReplyPort(LsaHandle,
+ Status = ZwRequestWaitReplyPort(LsaHandle,
&Request->Header,
&Reply->Header);
if (!NT_SUCCESS(Status))
@@ -285,26 +285,49 @@
PHANDLE Handle,
PLSA_OPERATIONAL_MODE OperationalMode)
{
- UNICODE_STRING Portname = RTL_CONSTANT_STRING(L"\\SeLsaCommandPort");
+ UNICODE_STRING PortName; // =
RTL_CONSTANT_STRING(L"\\LsaAuthenticationPort");
+ SECURITY_QUALITY_OF_SERVICE SecurityQos;
ULONG ConnectInfoLength;
NTSTATUS Status;
- LSASS_REQUEST Request;
- LSASS_REPLY Reply;
-
- ConnectInfoLength = 0;
- Status = NtConnectPort(Handle,
- &Portname,
+ LSASS_CONNECT_DATA ConnectInfo;
+// LSASS_REQUEST Request;
+// LSASS_REPLY Reply;
+
+ /* Check the logon process name length */
+ if (LsaLogonProcessName->Length > LSASS_MAX_LOGON_PROCESS_NAME_LENGTH)
+ return STATUS_NAME_TOO_LONG;
+
+ RtlInitUnicodeString(&PortName,
+ L"\\LsaAuthenticationPort");
+
+ SecurityQos.Length = sizeof (SecurityQos);
+ SecurityQos.ImpersonationLevel = SecurityIdentification;
+ SecurityQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
+ SecurityQos.EffectiveOnly = TRUE;
+
+ ConnectInfoLength = sizeof(LSASS_CONNECT_DATA);
+
+ strncpy(ConnectInfo.LogonProcessNameBuffer,
+ LsaLogonProcessName->Buffer,
+ LsaLogonProcessName->Length);
+ ConnectInfo.Length = LsaLogonProcessName->Length;
+ ConnectInfo.LogonProcessNameBuffer[ConnectInfo.Length] = '\0';
+
+ Status = ZwConnectPort(Handle,
+ &PortName,
+ &SecurityQos,
NULL,
NULL,
NULL,
- NULL,
- NULL,
+ &ConnectInfo,
&ConnectInfoLength);
if (!NT_SUCCESS(Status))
{
return Status;
}
+ return Status;
+#if 0
Request.Type = LSASS_REQUEST_REGISTER_LOGON_PROCESS;
Request.Header.u1.s1.DataLength = sizeof(LSASS_REQUEST) -
sizeof(PORT_MESSAGE);
@@ -315,26 +338,27 @@
LsaLogonProcessName->Buffer,
Request.d.RegisterLogonProcessRequest.Length);
- Status = NtRequestWaitReplyPort(*Handle,
+ Status = ZwRequestWaitReplyPort(*Handle,
&Request.Header,
&Reply.Header);
if (!NT_SUCCESS(Status))
{
- NtClose(*Handle);
- *Handle = NULL;
+// NtClose(*Handle);
+// *Handle = NULL;
return Status;
}
if (!NT_SUCCESS(Reply.Status))
{
- NtClose(*Handle);
- *Handle = NULL;
+// NtClose(*Handle);
+// *Handle = NULL;
return Status;
}
*OperationalMode = Reply.d.RegisterLogonProcessReply.OperationalMode;
return Reply.Status;
+#endif
}
@@ -347,7 +371,7 @@
PLUID *LogonSessionList)
{
UNIMPLEMENTED;
- return FALSE;
+ return STATUS_NOT_IMPLEMENTED;
}
@@ -360,7 +384,7 @@
PSECURITY_LOGON_SESSION_DATA *ppLogonSessionData)
{
UNIMPLEMENTED;
- return FALSE;
+ return STATUS_NOT_IMPLEMENTED;
}
@@ -373,7 +397,7 @@
HANDLE NotificationEventHandle)
{
UNIMPLEMENTED;
- return FALSE;
+ return STATUS_NOT_IMPLEMENTED;
}
@@ -386,5 +410,5 @@
HANDLE NotificationEventHandle)
{
UNIMPLEMENTED;
- return FALSE;
-}
+ return STATUS_NOT_IMPLEMENTED;
+}