[LSASRV] Implement and call the policy change notification routine
authorEric Kohl <eric.kohl@reactos.org>
Sat, 4 Aug 2018 23:05:52 +0000 (01:05 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 4 Aug 2018 23:05:52 +0000 (01:05 +0200)
dll/win32/lsasrv/lsarpc.c
dll/win32/lsasrv/lsasrv.h
dll/win32/lsasrv/notify.c

index 5f314e8..987d970 100644 (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) */
index cbff5e2..174a8fb 100644 (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,
index 48f09c7..c5233ce 100644 (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 */