|
|
1bb595 |
From dce025b882db7247571b135e928afb47f069a60f Mon Sep 17 00:00:00 2001
|
|
|
1bb595 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
1bb595 |
Date: Thu, 27 Feb 2020 06:54:21 +0100
|
|
|
1bb595 |
Subject: [PATCH] GPO: fix link order in a SOM
|
|
|
1bb595 |
|
|
|
1bb595 |
GPOs of the same OU were applied in the wrong order. Details about how
|
|
|
1bb595 |
GPOs should be processed can be found e.g. at
|
|
|
1bb595 |
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn581922(v%3Dws.11)
|
|
|
1bb595 |
|
|
|
1bb595 |
Resolves: https://github.com/SSSD/sssd/issues/5103
|
|
|
1bb595 |
|
|
|
1bb595 |
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
1bb595 |
---
|
|
|
1bb595 |
src/providers/ad/ad_gpo.c | 59 +++++++++++++++++++++++++++++----------
|
|
|
1bb595 |
1 file changed, 45 insertions(+), 14 deletions(-)
|
|
|
1bb595 |
|
|
|
1bb595 |
diff --git a/src/providers/ad/ad_gpo.c b/src/providers/ad/ad_gpo.c
|
|
|
1bb595 |
index bbe8d8a1e..1524c4bfc 100644
|
|
|
1bb595 |
--- a/src/providers/ad/ad_gpo.c
|
|
|
1bb595 |
+++ b/src/providers/ad/ad_gpo.c
|
|
|
1bb595 |
@@ -3511,14 +3511,19 @@ ad_gpo_process_som_recv(struct tevent_req *req,
|
|
|
1bb595 |
* - GPOs linked to an OU will be applied after GPOs linked to a Domain,
|
|
|
1bb595 |
* which will be applied after GPOs linked to a Site.
|
|
|
1bb595 |
* - multiple GPOs linked to a single SOM are applied in their link order
|
|
|
1bb595 |
- * (i.e. 1st GPO linked to SOM is applied after 2nd GPO linked to SOM, etc).
|
|
|
1bb595 |
+ * (i.e. 1st GPO linked to SOM is applied before 2nd GPO linked to SOM, etc).
|
|
|
1bb595 |
* - enforced GPOs are applied after unenforced GPOs.
|
|
|
1bb595 |
*
|
|
|
1bb595 |
* As such, the _candidate_gpos output's dn fields looks like (in link order):
|
|
|
1bb595 |
- * [unenforced {Site, Domain, OU}; enforced {Site, Domain, OU}]
|
|
|
1bb595 |
+ * [unenforced {Site, Domain, OU}; enforced {OU, Domain, Site}]
|
|
|
1bb595 |
*
|
|
|
1bb595 |
* Note that in the case of conflicting policy settings, GPOs appearing later
|
|
|
1bb595 |
- * in the list will trump GPOs appearing earlier in the list.
|
|
|
1bb595 |
+ * in the list will trump GPOs appearing earlier in the list. Therefore the
|
|
|
1bb595 |
+ * enforced GPOs are applied in revers order after the unenforced GPOs to
|
|
|
1bb595 |
+ * make sure the enforced setting form the highest level will be applied.
|
|
|
1bb595 |
+ *
|
|
|
1bb595 |
+ * GPO processing details can be found e.g. at
|
|
|
1bb595 |
+ * https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn581922(v%3Dws.11)
|
|
|
1bb595 |
*/
|
|
|
1bb595 |
static errno_t
|
|
|
1bb595 |
ad_gpo_populate_candidate_gpos(TALLOC_CTX *mem_ctx,
|
|
|
1bb595 |
@@ -3542,6 +3547,7 @@ ad_gpo_populate_candidate_gpos(TALLOC_CTX *mem_ctx,
|
|
|
1bb595 |
int i = 0;
|
|
|
1bb595 |
int j = 0;
|
|
|
1bb595 |
int ret;
|
|
|
1bb595 |
+ size_t som_count = 0;
|
|
|
1bb595 |
|
|
|
1bb595 |
tmp_ctx = talloc_new(NULL);
|
|
|
1bb595 |
if (tmp_ctx == NULL) {
|
|
|
1bb595 |
@@ -3568,6 +3574,7 @@ ad_gpo_populate_candidate_gpos(TALLOC_CTX *mem_ctx,
|
|
|
1bb595 |
}
|
|
|
1bb595 |
i++;
|
|
|
1bb595 |
}
|
|
|
1bb595 |
+ som_count = i;
|
|
|
1bb595 |
|
|
|
1bb595 |
num_candidate_gpos = num_enforced + num_unenforced;
|
|
|
1bb595 |
|
|
|
1bb595 |
@@ -3590,9 +3597,43 @@ ad_gpo_populate_candidate_gpos(TALLOC_CTX *mem_ctx,
|
|
|
1bb595 |
goto done;
|
|
|
1bb595 |
}
|
|
|
1bb595 |
|
|
|
1bb595 |
+ i = som_count -1 ;
|
|
|
1bb595 |
+ while (i >= 0) {
|
|
|
1bb595 |
+ gp_som = som_list[i];
|
|
|
1bb595 |
+
|
|
|
1bb595 |
+ /* For unenforced_gpo_dns the most specific GPOs with the highest
|
|
|
1bb595 |
+ * priority should be the last. We start with the top-level SOM and go
|
|
|
1bb595 |
+ * down to the most specific one and add the unenforced following the
|
|
|
1bb595 |
+ * gplink_list where the GPO with the highest priority comes last. */
|
|
|
1bb595 |
+ j = 0;
|
|
|
1bb595 |
+ while (gp_som && gp_som->gplink_list && gp_som->gplink_list[j]) {
|
|
|
1bb595 |
+ gp_gplink = gp_som->gplink_list[j];
|
|
|
1bb595 |
+
|
|
|
1bb595 |
+ if (!gp_gplink->enforced) {
|
|
|
1bb595 |
+ unenforced_gpo_dns[unenforced_idx] =
|
|
|
1bb595 |
+ talloc_steal(unenforced_gpo_dns, gp_gplink->gpo_dn);
|
|
|
1bb595 |
+
|
|
|
1bb595 |
+ if (unenforced_gpo_dns[unenforced_idx] == NULL) {
|
|
|
1bb595 |
+ ret = ENOMEM;
|
|
|
1bb595 |
+ goto done;
|
|
|
1bb595 |
+ }
|
|
|
1bb595 |
+ unenforced_idx++;
|
|
|
1bb595 |
+ }
|
|
|
1bb595 |
+ j++;
|
|
|
1bb595 |
+ }
|
|
|
1bb595 |
+ i--;
|
|
|
1bb595 |
+ }
|
|
|
1bb595 |
+
|
|
|
1bb595 |
i = 0;
|
|
|
1bb595 |
while (som_list[i]) {
|
|
|
1bb595 |
gp_som = som_list[i];
|
|
|
1bb595 |
+
|
|
|
1bb595 |
+ /* For enforced GPOs we start processing with the most specific SOM to
|
|
|
1bb595 |
+ * make sur enforced GPOs from higher levels override to lower level
|
|
|
1bb595 |
+ * ones. According to the 'Group Policy Inheritance' tab in the
|
|
|
1bb595 |
+ * Windows 'Goup Policy Management' utility in the same SOM the link
|
|
|
1bb595 |
+ * order is still observed and an enforced GPO with a lower link order
|
|
|
1bb595 |
+ * value still overrides an enforced GPO with a higher link order. */
|
|
|
1bb595 |
j = 0;
|
|
|
1bb595 |
while (gp_som && gp_som->gplink_list && gp_som->gplink_list[j]) {
|
|
|
1bb595 |
gp_gplink = gp_som->gplink_list[j];
|
|
|
1bb595 |
@@ -3610,16 +3651,6 @@ ad_gpo_populate_candidate_gpos(TALLOC_CTX *mem_ctx,
|
|
|
1bb595 |
goto done;
|
|
|
1bb595 |
}
|
|
|
1bb595 |
enforced_idx++;
|
|
|
1bb595 |
- } else {
|
|
|
1bb595 |
-
|
|
|
1bb595 |
- unenforced_gpo_dns[unenforced_idx] =
|
|
|
1bb595 |
- talloc_steal(unenforced_gpo_dns, gp_gplink->gpo_dn);
|
|
|
1bb595 |
-
|
|
|
1bb595 |
- if (unenforced_gpo_dns[unenforced_idx] == NULL) {
|
|
|
1bb595 |
- ret = ENOMEM;
|
|
|
1bb595 |
- goto done;
|
|
|
1bb595 |
- }
|
|
|
1bb595 |
- unenforced_idx++;
|
|
|
1bb595 |
}
|
|
|
1bb595 |
j++;
|
|
|
1bb595 |
}
|
|
|
1bb595 |
@@ -3638,7 +3669,7 @@ ad_gpo_populate_candidate_gpos(TALLOC_CTX *mem_ctx,
|
|
|
1bb595 |
}
|
|
|
1bb595 |
|
|
|
1bb595 |
gpo_dn_idx = 0;
|
|
|
1bb595 |
- for (i = num_unenforced - 1; i >= 0; i--) {
|
|
|
1bb595 |
+ for (i = 0; i < num_unenforced; i++) {
|
|
|
1bb595 |
candidate_gpos[gpo_dn_idx] = talloc_zero(candidate_gpos, struct gp_gpo);
|
|
|
1bb595 |
if (candidate_gpos[gpo_dn_idx] == NULL) {
|
|
|
1bb595 |
ret = ENOMEM;
|
|
|
1bb595 |
--
|
|
|
1bb595 |
2.21.3
|
|
|
1bb595 |
|