[LSASRV] Implement and call the policy change notification routine

This commit is contained in:
Eric Kohl 2018-08-05 01:05:52 +02:00
parent 620217cec9
commit 4e32ad3623
3 changed files with 60 additions and 7 deletions

View file

@ -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) */

View file

@ -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,

View file

@ -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 */