https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4e32ad36235ac8608c8f0…
commit 4e32ad36235ac8608c8f0ea302cea7243737db24
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Aug 5 01:05:52 2018 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Aug 5 01:05:52 2018 +0200
[LSASRV] Implement and call the policy change notification routine
---
dll/win32/lsasrv/lsarpc.c | 10 +++++++++
dll/win32/lsasrv/lsasrv.h | 4 ++++
dll/win32/lsasrv/notify.c | 53 ++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/dll/win32/lsasrv/lsarpc.c b/dll/win32/lsasrv/lsarpc.c
index 5f314e8c2b..987d9701c6 100644
--- a/dll/win32/lsasrv/lsarpc.c
+++ b/dll/win32/lsasrv/lsarpc.c
@@ -707,21 +707,29 @@ NTSTATUS WINAPI LsarSetInformationPolicy(
case PolicyAuditEventsInformation: /* 2 */
Status = LsarSetAuditEvents(PolicyObject,
(PLSAPR_POLICY_AUDIT_EVENTS_INFO)PolicyInformation);
+ if (NT_SUCCESS(Status))
+ LsapNotifyPolicyChange(PolicyNotifyAuditEventsInformation);
break;
case PolicyPrimaryDomainInformation: /* 3 */
Status = LsarSetPrimaryDomain(PolicyObject,
(PLSAPR_POLICY_PRIMARY_DOM_INFO)PolicyInformation);
+ if (NT_SUCCESS(Status))
+ LsapNotifyPolicyChange(PolicyNotifyDnsDomainInformation);
break;
case PolicyAccountDomainInformation: /* 5 */
Status = LsarSetAccountDomain(PolicyObject,
(PLSAPR_POLICY_ACCOUNT_DOM_INFO)PolicyInformation);
+ if (NT_SUCCESS(Status))
+ LsapNotifyPolicyChange(PolicyNotifyAccountDomainInformation);
break;
case PolicyLsaServerRoleInformation: /* 6 */
Status = LsarSetServerRole(PolicyObject,
(PPOLICY_LSA_SERVER_ROLE_INFO)PolicyInformation);
+ if (NT_SUCCESS(Status))
+ LsapNotifyPolicyChange(PolicyNotifyServerRoleInformation);
break;
case PolicyReplicaSourceInformation: /* 7 */
@@ -747,6 +755,8 @@ NTSTATUS WINAPI LsarSetInformationPolicy(
case PolicyDnsDomainInformation: /* 12 (0xC) */
Status = LsarSetDnsDomain(PolicyObject,
(PLSAPR_POLICY_DNS_DOMAIN_INFO)PolicyInformation);
+ if (NT_SUCCESS(Status))
+ LsapNotifyPolicyChange(PolicyNotifyDnsDomainInformation);
break;
case PolicyDnsDomainInformationInt: /* 13 (0xD) */
diff --git a/dll/win32/lsasrv/lsasrv.h b/dll/win32/lsasrv/lsasrv.h
index cbff5e2b86..174a8fb6f4 100644
--- a/dll/win32/lsasrv/lsasrv.h
+++ b/dll/win32/lsasrv/lsasrv.h
@@ -217,6 +217,10 @@ NTSTATUS
LsapRegisterNotification(
PLSA_API_MSG RequestMsg);
+VOID
+LsapNotifyPolicyChange(
+ POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass);
+
/* policy.c */
NTSTATUS
LsarQueryAuditLog(PLSA_DB_OBJECT PolicyObject,
diff --git a/dll/win32/lsasrv/notify.c b/dll/win32/lsasrv/notify.c
index 48f09c7ecf..c5233ce0bc 100644
--- a/dll/win32/lsasrv/notify.c
+++ b/dll/win32/lsasrv/notify.c
@@ -32,8 +32,9 @@ LsapInitNotificationList(VOID)
static
PLSA_NOTIFICATION_ENTRY
-LsapGetNotificationEntryByHandle(
- HANDLE EventHandle)
+LsapGetNotificationEntry(
+ HANDLE EventHandle,
+ POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass)
{
PLIST_ENTRY NotificationEntry;
PLSA_NOTIFICATION_ENTRY CurrentNotification;
@@ -43,7 +44,8 @@ LsapGetNotificationEntryByHandle(
{
CurrentNotification = CONTAINING_RECORD(NotificationEntry,
LSA_NOTIFICATION_ENTRY, Entry);
- if (CurrentNotification->EventHandle == EventHandle)
+ if ((CurrentNotification->EventHandle == EventHandle) &&
+ (CurrentNotification->InformationClass == InformationClass))
return CurrentNotification;
NotificationEntry = NotificationEntry->Flink;
@@ -67,6 +69,7 @@ LsapRegisterNotification(
if (pRequestMsg->PolicyChangeNotify.Request.Register)
{
+ /* Register the notification event */
pEntry = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(LSA_NOTIFICATION_ENTRY));
@@ -84,12 +87,17 @@ LsapRegisterNotification(
}
else
{
- pEntry =
LsapGetNotificationEntryByHandle(pRequestMsg->PolicyChangeNotify.Request.NotificationEventHandle);
- if (pEntry)
+ /* Unregister the notification event */
+ pEntry =
LsapGetNotificationEntry(pRequestMsg->PolicyChangeNotify.Request.NotificationEventHandle,
+
pRequestMsg->PolicyChangeNotify.Request.InformationClass);
+ if (pEntry == NULL)
{
- RemoveEntryList(&pEntry->Entry);
- RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry);
+ Status = STATUS_INVALID_HANDLE;
+ goto done;
}
+
+ RemoveEntryList(&pEntry->Entry);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry);
}
done:
@@ -99,4 +107,35 @@ done:
return Status;
}
+
+VOID
+LsapNotifyPolicyChange(
+ POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass)
+{
+ PLIST_ENTRY NotificationEntry;
+ PLSA_NOTIFICATION_ENTRY CurrentNotification;
+
+ FIXME("LsapNotifyPolicyChange(%lu)\n", InformationClass);
+
+ /* Acquire the notification list lock shared */
+ RtlAcquireResourceShared(&NotificationListLock, TRUE);
+
+ NotificationEntry = NotificationListHead.Flink;
+ while (NotificationEntry != &NotificationListHead)
+ {
+ CurrentNotification = CONTAINING_RECORD(NotificationEntry,
LSA_NOTIFICATION_ENTRY, Entry);
+
+ if (CurrentNotification->InformationClass == InformationClass)
+ {
+ FIXME("Notify event %p\n", CurrentNotification->EventHandle);
+
+ }
+
+ NotificationEntry = NotificationEntry->Flink;
+ }
+
+ /* Release the notification list lock */
+ RtlReleaseResource(&NotificationListLock);
+}
+
/* EOF */