- Add authentication package loader code.
- Load registered authentication packages before the rpc server is started.

svn path=/trunk/; revision=58421
This commit is contained in:
Eric Kohl 2013-03-03 19:43:33 +00:00
parent c8725cc1ca
commit 5f16c2b7ed
4 changed files with 170 additions and 2 deletions

View file

@ -8,6 +8,7 @@ add_rpc_files(server ${REACTOS_SOURCE_DIR}/include/reactos/idl/lsa.idl)
spec2def(lsasrv.dll lsasrv.spec ADD_IMPORTLIB)
list(APPEND SOURCE
authpackage.c
authport.c
database.c
lookup.c

View file

@ -0,0 +1,147 @@
/*
* PROJECT: Local Security Authority Server DLL
* LICENSE: GPL - See COPYING in the top level directory
* FILE: dll/win32/lsasrv/authpackage.c
* PURPOSE: Authenticaton package management routines
* COPYRIGHT: Copyright 2013 Eric Kohl
*/
/* INCLUDES ****************************************************************/
#include "lsasrv.h"
WINE_DEFAULT_DEBUG_CHANNEL(lsasrv);
typedef NTSTATUS (NTAPI *PLSA_AP_INITIALIZE_PACKAGE)(ULONG, PVOID /*PLSA_DISPATCH_TABLE*/,
PLSA_STRING, PLSA_STRING, PLSA_STRING *);
typedef struct _AUTH_PACKAGE
{
LIST_ENTRY Entry;
PSTRING Name;
PVOID ModuleHandle;
PLSA_AP_INITIALIZE_PACKAGE LsaApInitializePackage;
// PLSA_AP_CALL_PACKAGE LsaApCallPackage;
// PLSA_AP_CALL_PACKAGE_UNTRUSTED LsaApCallPackageUntrusted;
// PLSA_AP_LOGON_TERMINATED LsaApLogonTerminated;
// PLSA_AP_LOGON_USER_EX2 LsaApLogonUserEx2;
// PLSA_AP_LOGON_USER_EX LsaApLogonUserEx;
// PLSA_AP_LOGON_USER LsaApLogonUser;
} AUTH_PACKAGE, *PAUTH_PACKAGE;
/* GLOBALS *****************************************************************/
static LIST_ENTRY PackageListHead;
static ULONG PackageId;
/* FUNCTIONS ***************************************************************/
static
NTSTATUS
NTAPI
LsapAddAuthPackage(IN PWSTR ValueName,
IN ULONG ValueType,
IN PVOID ValueData,
IN ULONG ValueLength,
IN PVOID Context,
IN PVOID EntryContext)
{
PAUTH_PACKAGE Package = NULL;
UNICODE_STRING PackageName;
STRING ProcName;
PULONG Id;
NTSTATUS Status = STATUS_SUCCESS;
TRACE("LsapAddAuthPackage()\n");
PackageName.Length = (USHORT)ValueLength - sizeof(WCHAR);
PackageName.MaximumLength = (USHORT)ValueLength;
PackageName.Buffer = ValueData;
Id = (PULONG)Context;
Package = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(AUTH_PACKAGE));
if (Package == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
Status = LdrLoadDll(NULL,
NULL,
&PackageName,
&Package->ModuleHandle);
if (!NT_SUCCESS(Status))
{
TRACE("LdrLoadDll failed (Status 0x%08lx)\n", Status);
goto done;
}
RtlInitAnsiString(&ProcName, "LsaApInitializePackage");
Status = LdrGetProcedureAddress(Package->ModuleHandle,
&ProcName,
0,
(PVOID *)&Package->LsaApInitializePackage);
if (!NT_SUCCESS(Status))
{
TRACE("LdrGetProcedureAddress() failed (Status 0x%08lx)\n", Status);
goto done;
}
Status = Package->LsaApInitializePackage(*Id,
NULL,
NULL,
NULL,
&Package->Name);
if (!NT_SUCCESS(Status))
{
TRACE("Package->LsaApInitializePackage() failed (Status 0x%08lx)\n", Status);
goto done;
}
*Id++;
InsertTailList(&PackageListHead, &Package->Entry);
done:
if (!NT_SUCCESS(Status))
{
if (Package != NULL)
{
if (Package->ModuleHandle != NULL)
LdrUnloadDll(Package->ModuleHandle);
RtlFreeHeap(RtlGetProcessHeap(), 0, Package);
}
}
return Status;
}
NTSTATUS
LsapInitAuthPackages(VOID)
{
RTL_QUERY_REGISTRY_TABLE AuthPackageTable[] = {
{LsapAddAuthPackage, 0, L"Authentication Packages", NULL, REG_NONE, NULL, 0},
{NULL, 0, NULL, NULL, REG_NONE, NULL, 0}};
NTSTATUS Status;
InitializeListHead(&PackageListHead);
PackageId = 0;
/* Add registered authentication packages */
Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL,
L"Lsa",
AuthPackageTable,
&PackageId,
NULL);
return STATUS_SUCCESS;
}
/* EOF */

View file

@ -20,6 +20,7 @@ LsapInitLsa(VOID)
{
HANDLE hEvent;
DWORD dwError;
NTSTATUS Status;
TRACE("LsapInitLsa() called\n");
@ -29,6 +30,22 @@ LsapInitLsa(VOID)
/* Initialize the LSA database */
LsapInitDatabase();
/* Initialize registered authentication packages */
Status = LsapInitAuthPackages();
if (!NT_SUCCESS(Status))
{
ERR("LsapInitAuthPackages() failed (Status 0x%08lx)\n", Status);
return Status;
}
/* Start the authentication port thread */
Status = StartAuthenticationPort();
if (!NT_SUCCESS(Status))
{
ERR("StartAuthenticationPort() failed (Status 0x%08lx)\n", Status);
return Status;
}
/* Start the RPC server */
LsarStartRpcServer();
@ -61,8 +78,6 @@ LsapInitLsa(VOID)
/* NOTE: Do not close the event handle!!!! */
StartAuthenticationPort();
return STATUS_SUCCESS;
}

View file

@ -19,10 +19,12 @@
#include <ndk/kefuncs.h>
#include <ndk/lpctypes.h>
#include <ndk/lpcfuncs.h>
#include <ndk/mmfuncs.h>
#include <ndk/obfuncs.h>
#include <ndk/psfuncs.h>
#include <ndk/rtlfuncs.h>
#include <ndk/setypes.h>
#include <ndk/umfuncs.h>
#include <ntsam.h>
#include <ntlsa.h>
@ -79,6 +81,9 @@ extern UNICODE_STRING BuiltinDomainName;
extern PSID AccountDomainSid;
extern UNICODE_STRING AccountDomainName;
/* authpackage.c */
NTSTATUS
LsapInitAuthPackages(VOID);
/* authport.c */
NTSTATUS