mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 05:26:58 +00:00
[LSASRV][SECUR32] Implement LsaRegisterPolicyChangeNotification and LsaUnregisterPolicyChangeNotification
This commit is contained in:
parent
cf77354dce
commit
620217cec9
|
@ -17,6 +17,7 @@ list(APPEND SOURCE
|
||||||
lookup.c
|
lookup.c
|
||||||
lsarpc.c
|
lsarpc.c
|
||||||
lsasrv.c
|
lsasrv.c
|
||||||
|
notify.c
|
||||||
policy.c
|
policy.c
|
||||||
privileges.c
|
privileges.c
|
||||||
registry.c
|
registry.c
|
||||||
|
|
|
@ -242,6 +242,11 @@ AuthPortThreadRoutine(PVOID Param)
|
||||||
ReplyMsg = &RequestMsg;
|
ReplyMsg = &RequestMsg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LSASS_REQUEST_POLICY_CHANGE_NOTIFY:
|
||||||
|
RequestMsg.Status = LsapRegisterNotification(&RequestMsg);
|
||||||
|
ReplyMsg = &RequestMsg;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
RequestMsg.Status = STATUS_INVALID_SYSTEM_SERVICE;
|
RequestMsg.Status = STATUS_INVALID_SYSTEM_SERVICE;
|
||||||
ReplyMsg = &RequestMsg;
|
ReplyMsg = &RequestMsg;
|
||||||
|
|
|
@ -293,6 +293,9 @@ LsapInitLsa(VOID)
|
||||||
/* Initialize logon sessions */
|
/* Initialize logon sessions */
|
||||||
LsapInitLogonSessions();
|
LsapInitLogonSessions();
|
||||||
|
|
||||||
|
/* Initialize the notification list */
|
||||||
|
LsapInitNotificationList();
|
||||||
|
|
||||||
/* Initialize registered authentication packages */
|
/* Initialize registered authentication packages */
|
||||||
Status = LsapInitAuthPackages();
|
Status = LsapInitAuthPackages();
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -209,6 +209,14 @@ LsapLookupSids(PLSAPR_SID_ENUM_BUFFER SidEnumBuffer,
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LsarStartRpcServer(VOID);
|
LsarStartRpcServer(VOID);
|
||||||
|
|
||||||
|
/* notify.c */
|
||||||
|
VOID
|
||||||
|
LsapInitNotificationList(VOID);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
LsapRegisterNotification(
|
||||||
|
PLSA_API_MSG RequestMsg);
|
||||||
|
|
||||||
/* policy.c */
|
/* policy.c */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LsarQueryAuditLog(PLSA_DB_OBJECT PolicyObject,
|
LsarQueryAuditLog(PLSA_DB_OBJECT PolicyObject,
|
||||||
|
|
102
dll/win32/lsasrv/notify.c
Normal file
102
dll/win32/lsasrv/notify.c
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: Local Security Authority Server DLL
|
||||||
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
|
* PURPOSE: LSA policy change notifications
|
||||||
|
* COPYRIGHT: Eric Kohl 2018
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "lsasrv.h"
|
||||||
|
|
||||||
|
typedef struct _LSA_NOTIFICATION_ENTRY
|
||||||
|
{
|
||||||
|
LIST_ENTRY Entry;
|
||||||
|
POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass;
|
||||||
|
HANDLE EventHandle;
|
||||||
|
} LSA_NOTIFICATION_ENTRY, *PLSA_NOTIFICATION_ENTRY;
|
||||||
|
|
||||||
|
/* GLOBALS *****************************************************************/
|
||||||
|
|
||||||
|
static LIST_ENTRY NotificationListHead;
|
||||||
|
static RTL_RESOURCE NotificationListLock;
|
||||||
|
|
||||||
|
|
||||||
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
VOID
|
||||||
|
LsapInitNotificationList(VOID)
|
||||||
|
{
|
||||||
|
InitializeListHead(&NotificationListHead);
|
||||||
|
RtlInitializeResource(&NotificationListLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
PLSA_NOTIFICATION_ENTRY
|
||||||
|
LsapGetNotificationEntryByHandle(
|
||||||
|
HANDLE EventHandle)
|
||||||
|
{
|
||||||
|
PLIST_ENTRY NotificationEntry;
|
||||||
|
PLSA_NOTIFICATION_ENTRY CurrentNotification;
|
||||||
|
|
||||||
|
NotificationEntry = NotificationListHead.Flink;
|
||||||
|
while (NotificationEntry != &NotificationListHead)
|
||||||
|
{
|
||||||
|
CurrentNotification = CONTAINING_RECORD(NotificationEntry, LSA_NOTIFICATION_ENTRY, Entry);
|
||||||
|
|
||||||
|
if (CurrentNotification->EventHandle == EventHandle)
|
||||||
|
return CurrentNotification;
|
||||||
|
|
||||||
|
NotificationEntry = NotificationEntry->Flink;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
LsapRegisterNotification(
|
||||||
|
PLSA_API_MSG pRequestMsg)
|
||||||
|
{
|
||||||
|
PLSA_NOTIFICATION_ENTRY pEntry;
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
FIXME("LsapRegisterNotification(%p)\n", pRequestMsg);
|
||||||
|
|
||||||
|
/* Acquire the notification list lock exclusively */
|
||||||
|
RtlAcquireResourceExclusive(&NotificationListLock, TRUE);
|
||||||
|
|
||||||
|
if (pRequestMsg->PolicyChangeNotify.Request.Register)
|
||||||
|
{
|
||||||
|
pEntry = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
sizeof(LSA_NOTIFICATION_ENTRY));
|
||||||
|
if (pEntry == NULL)
|
||||||
|
{
|
||||||
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
pEntry->InformationClass = pRequestMsg->PolicyChangeNotify.Request.InformationClass;
|
||||||
|
pEntry->EventHandle = pRequestMsg->PolicyChangeNotify.Request.NotificationEventHandle;
|
||||||
|
|
||||||
|
InsertHeadList(&NotificationListHead,
|
||||||
|
&pEntry->Entry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pEntry = LsapGetNotificationEntryByHandle(pRequestMsg->PolicyChangeNotify.Request.NotificationEventHandle);
|
||||||
|
if (pEntry)
|
||||||
|
{
|
||||||
|
RemoveEntryList(&pEntry->Entry);
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
/* Release the notification list lock */
|
||||||
|
RtlReleaseResource(&NotificationListLock);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -322,28 +322,96 @@ LsaGetLogonSessionData(
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
LsaRegisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
|
LsaRegisterPolicyChangeNotification(
|
||||||
HANDLE NotificationEventHandle)
|
POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
|
||||||
|
HANDLE NotificationEventHandle)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
LSA_API_MSG ApiMessage;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
TRACE("LsaRegisterPolicyChangeNotification(%lu %p)\n",
|
||||||
|
InformationClass, NotificationEventHandle);
|
||||||
|
|
||||||
|
Status = LsapOpenLsaPort();
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
ApiMessage.ApiNumber = LSASS_REQUEST_POLICY_CHANGE_NOTIFY;
|
||||||
|
ApiMessage.h.u1.s1.DataLength = LSA_PORT_DATA_SIZE(ApiMessage.PolicyChangeNotify);
|
||||||
|
ApiMessage.h.u1.s1.TotalLength = LSA_PORT_MESSAGE_SIZE;
|
||||||
|
ApiMessage.h.u2.ZeroInit = 0;
|
||||||
|
|
||||||
|
ApiMessage.PolicyChangeNotify.Request.InformationClass = InformationClass;
|
||||||
|
ApiMessage.PolicyChangeNotify.Request.NotificationEventHandle = NotificationEventHandle;
|
||||||
|
ApiMessage.PolicyChangeNotify.Request.Register = TRUE;
|
||||||
|
|
||||||
|
Status = NtRequestWaitReplyPort(LsaPortHandle,
|
||||||
|
(PPORT_MESSAGE)&ApiMessage,
|
||||||
|
(PPORT_MESSAGE)&ApiMessage);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("NtRequestWaitReplyPort() failed (Status 0x%08lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
|
{
|
||||||
|
ERR("NtRequestWaitReplyPort() failed (ApiMessage.Status 0x%08lx)\n", ApiMessage.Status);
|
||||||
|
return ApiMessage.Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
LsaUnregisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
|
LsaUnregisterPolicyChangeNotification(
|
||||||
HANDLE NotificationEventHandle)
|
POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
|
||||||
|
HANDLE NotificationEventHandle)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
LSA_API_MSG ApiMessage;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
TRACE("LsaUnregisterPolicyChangeNotification(%lu %p)\n",
|
||||||
|
InformationClass, NotificationEventHandle);
|
||||||
|
|
||||||
|
Status = LsapOpenLsaPort();
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
ApiMessage.ApiNumber = LSASS_REQUEST_POLICY_CHANGE_NOTIFY;
|
||||||
|
ApiMessage.h.u1.s1.DataLength = LSA_PORT_DATA_SIZE(ApiMessage.PolicyChangeNotify);
|
||||||
|
ApiMessage.h.u1.s1.TotalLength = LSA_PORT_MESSAGE_SIZE;
|
||||||
|
ApiMessage.h.u2.ZeroInit = 0;
|
||||||
|
|
||||||
|
ApiMessage.PolicyChangeNotify.Request.InformationClass = InformationClass;
|
||||||
|
ApiMessage.PolicyChangeNotify.Request.NotificationEventHandle = NotificationEventHandle;
|
||||||
|
ApiMessage.PolicyChangeNotify.Request.Register = FALSE;
|
||||||
|
|
||||||
|
Status = NtRequestWaitReplyPort(LsaPortHandle,
|
||||||
|
(PPORT_MESSAGE)&ApiMessage,
|
||||||
|
(PPORT_MESSAGE)&ApiMessage);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("NtRequestWaitReplyPort() failed (Status 0x%08lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
|
{
|
||||||
|
ERR("NtRequestWaitReplyPort() failed (ApiMessage.Status 0x%08lx)\n", ApiMessage.Status);
|
||||||
|
return ApiMessage.Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -770,6 +770,8 @@ NTSTATUS NTAPI LsaQueryTrustedDomainInfo(LSA_HANDLE,PSID,
|
||||||
NTSTATUS NTAPI LsaQueryTrustedDomainInfoByName(LSA_HANDLE,PLSA_UNICODE_STRING,
|
NTSTATUS NTAPI LsaQueryTrustedDomainInfoByName(LSA_HANDLE,PLSA_UNICODE_STRING,
|
||||||
TRUSTED_INFORMATION_CLASS,PVOID*);
|
TRUSTED_INFORMATION_CLASS,PVOID*);
|
||||||
NTSTATUS NTAPI LsaRegisterLogonProcess(PLSA_STRING,PHANDLE,PLSA_OPERATIONAL_MODE);
|
NTSTATUS NTAPI LsaRegisterLogonProcess(PLSA_STRING,PHANDLE,PLSA_OPERATIONAL_MODE);
|
||||||
|
NTSTATUS NTAPI LsaRegisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS,
|
||||||
|
HANDLE);
|
||||||
NTSTATUS NTAPI LsaRemoveAccountRights(LSA_HANDLE,PSID,BOOLEAN,
|
NTSTATUS NTAPI LsaRemoveAccountRights(LSA_HANDLE,PSID,BOOLEAN,
|
||||||
PLSA_UNICODE_STRING,ULONG);
|
PLSA_UNICODE_STRING,ULONG);
|
||||||
NTSTATUS NTAPI LsaRemovePrivilegesFromAccount(LSA_HANDLE,BOOLEAN,PPRIVILEGE_SET);
|
NTSTATUS NTAPI LsaRemovePrivilegesFromAccount(LSA_HANDLE,BOOLEAN,PPRIVILEGE_SET);
|
||||||
|
@ -790,6 +792,8 @@ NTSTATUS NTAPI LsaSetTrustedDomainInfoByName(LSA_HANDLE,PLSA_UNICODE_STRING,
|
||||||
TRUSTED_INFORMATION_CLASS,PVOID);
|
TRUSTED_INFORMATION_CLASS,PVOID);
|
||||||
NTSTATUS NTAPI LsaStorePrivateData(LSA_HANDLE,PLSA_UNICODE_STRING,
|
NTSTATUS NTAPI LsaStorePrivateData(LSA_HANDLE,PLSA_UNICODE_STRING,
|
||||||
PLSA_UNICODE_STRING);
|
PLSA_UNICODE_STRING);
|
||||||
|
NTSTATUS NTAPI LsaUnregisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS,
|
||||||
|
HANDLE);
|
||||||
typedef NTSTATUS (NTAPI *PSAM_PASSWORD_NOTIFICATION_ROUTINE)(PUNICODE_STRING,
|
typedef NTSTATUS (NTAPI *PSAM_PASSWORD_NOTIFICATION_ROUTINE)(PUNICODE_STRING,
|
||||||
ULONG,PUNICODE_STRING);
|
ULONG,PUNICODE_STRING);
|
||||||
typedef BOOLEAN (NTAPI *PSAM_INIT_NOTIFICATION_ROUTINE)(VOID);
|
typedef BOOLEAN (NTAPI *PSAM_INIT_NOTIFICATION_ROUTINE)(VOID);
|
||||||
|
|
|
@ -23,6 +23,7 @@ typedef enum _LSA_API_NUMBER
|
||||||
LSASS_REQUEST_LOOKUP_AUTHENTICATION_PACKAGE,
|
LSASS_REQUEST_LOOKUP_AUTHENTICATION_PACKAGE,
|
||||||
LSASS_REQUEST_ENUM_LOGON_SESSIONS,
|
LSASS_REQUEST_ENUM_LOGON_SESSIONS,
|
||||||
LSASS_REQUEST_GET_LOGON_SESSION_DATA,
|
LSASS_REQUEST_GET_LOGON_SESSION_DATA,
|
||||||
|
LSASS_REQUEST_POLICY_CHANGE_NOTIFY,
|
||||||
LSASS_REQUEST_MAXIMUM
|
LSASS_REQUEST_MAXIMUM
|
||||||
} LSA_API_NUMBER, *PLSA_API_NUMBER;
|
} LSA_API_NUMBER, *PLSA_API_NUMBER;
|
||||||
|
|
||||||
|
@ -152,6 +153,24 @@ typedef struct _LSA_GET_LOGON_SESSION_DATA_MSG
|
||||||
} LSA_GET_LOGON_SESSION_DATA_MSG, *PLSA_GET_LOGON_SESSION_DATA_MSG;
|
} LSA_GET_LOGON_SESSION_DATA_MSG, *PLSA_GET_LOGON_SESSION_DATA_MSG;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _LSA_POLICY_CHANGE_NOTIFY_MSG
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass;
|
||||||
|
HANDLE NotificationEventHandle;
|
||||||
|
BOOLEAN Register;
|
||||||
|
} Request;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG Dummy;
|
||||||
|
} Reply;
|
||||||
|
};
|
||||||
|
} LSA_POLICY_CHANGE_NOTIFY_MSG, *PLSA_POLICY_CHANGE_NOTIFY_MSG;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _LSA_API_MSG
|
typedef struct _LSA_API_MSG
|
||||||
{
|
{
|
||||||
PORT_MESSAGE h;
|
PORT_MESSAGE h;
|
||||||
|
@ -170,6 +189,7 @@ typedef struct _LSA_API_MSG
|
||||||
LSA_LOOKUP_AUTHENTICATION_PACKAGE_MSG LookupAuthenticationPackage;
|
LSA_LOOKUP_AUTHENTICATION_PACKAGE_MSG LookupAuthenticationPackage;
|
||||||
LSA_ENUM_LOGON_SESSIONS_MSG EnumLogonSessions;
|
LSA_ENUM_LOGON_SESSIONS_MSG EnumLogonSessions;
|
||||||
LSA_GET_LOGON_SESSION_DATA_MSG GetLogonSessionData;
|
LSA_GET_LOGON_SESSION_DATA_MSG GetLogonSessionData;
|
||||||
|
LSA_POLICY_CHANGE_NOTIFY_MSG PolicyChangeNotify;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue