Bug 15738 - Creation of GPOs applicable to more than one group is impossible with Samba 4.20.0 and later
Summary: Creation of GPOs applicable to more than one group is impossible with Samba 4...
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: 4.20.0
Hardware: x64 All
: P5 critical with 5 votes (vote)
Target Milestone: ---
Assignee: Jule Anger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-14 17:09 UTC by Miguel Medalha
Modified: 2025-03-25 14:43 UTC (History)
9 users (show)

See Also:


Attachments
acls of GPO object in sysvol folder before and after sysvolreset (1.83 KB, application/gzip)
2025-02-12 10:30 UTC, Björn Jacke
no flags Details
patch for 4.20 (36.90 KB, patch)
2025-02-13 23:29 UTC, Douglas Bagnall
vl: review+
Details
patch for 4.21 (36.90 KB, patch)
2025-02-13 23:30 UTC, Douglas Bagnall
vl: review+
Details
patch for 4.22rc (36.90 KB, patch)
2025-02-13 23:32 UTC, Douglas Bagnall
vl: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miguel Medalha 2024-10-14 17:09:54 UTC
Starting with Samba version 4.20.0, when using the Group Policy Management app included with Windows RSAT, under "Delegation", it is not possible to set "Apply group policy" to more than one group, because the app silently quits immediately.

When executed again, the app presents "The specified server cannot perform the requested operation". After a "samba-tool ntacl sysvolreset", this message disappears but the recently created Group Policy Object is corrupt and delegation of permissions cannot be performed, with the error "The security ID structure is invalid". The only solution is to delete the newly created Group Policy Object.

It is thus impossible to create Group Policy Objects applicable to more than one group, which pretty much makes GPOs way less useful.

The same issue is still present in versions 4.21.0 and 4.21.1.

Reverting to Samba 4.19.8 solves the issue and GPOs work correctly again.

I classified this bug as critical because it is critical for our use. GPOs are one of the most useful features of an AD environment, being indispensable in many cases.

Our Samba AD servers are running on AlmaLinux 9.4.

Best regards and thank you.
Comment 1 Björn Jacke 2024-10-15 15:37:20 UTC
seems to be a problem of your samba installation, I can't reproduce this, tested with sernet samba+ 4.20.5 here...
Comment 2 Björn Jacke 2024-10-15 15:43:11 UTC
ah, setting the "Apply group policy" *permission* for delegated group shows the problem that you describe, okay I can confirm that fails here, too.
Comment 3 Caponato 2024-11-18 18:10:48 UTC
Confirmed same exact behavior with different 4.21.1 installations on Debian 12.
Comment 4 Miguel Medalha 2024-12-10 22:32:37 UTC
Are Samba developers aware that the only way to create practically usable GPOs is to use a Samba version (4.19.x) that is two versions behind the current one and that, according to "Samba Release Planning and Supported Release Lifetime", is scheduled for discontinuation in March 2025?

https://wiki.samba.org/index.php/Samba_Release_Planning

Please note that I am not bitching or demanding anything, I am grateful for what we have and I truly appreciate the hard work of the Samba team members. I am just calling attention to this fact. I really wish I could help.
Comment 5 Michael Tokarev 2025-01-04 18:52:00 UTC
Has anyone tried to bisect this?

How to reproduce it easily?  Say, if I configure GPO (applying to two groups) in samba 4.19, install 4.20 and do <what?> in windows?
Comment 6 Miguel Medalha 2025-01-04 19:12:43 UTC
If you configure a GPO applying to two groups in samba 4.19, it will work on Samba 4.20.x and 4.21.x.

If you configure a GPO applying to two groups in samba 4.20.x and 4.21.x, the described behavior can be observed.

In sum, if you use Samba 4.20.0 and newer, you cannot create a GPO applying to more than one group.
Comment 7 Miguel Medalha 2025-01-04 19:22:40 UTC
If you configure a GPO applying to two groups in samba 4.19, it will work on Samba 4.20.x and 4.21.x.

If you configure a GPO applying to two groups in samba 4.20.x and 4.21.x, the described behavior can be observed.

In sum, if you use Samba 4.20.0 and newer, you cannot create a GPO applying to more than one group.

If my AD has lots of groups and I need to apply a particular GPO to a number 
of those groups, it's not really practical having to create a separate GPO 
with the exact same content for each one of those groups. It quickly becomes an unmanageable mess.

I tested all the 4.20.x and 4.21.x versions, and they all exhibit the same behavior. The last version working correctly is 4.19.9.
Comment 8 Miguel Medalha 2025-01-04 19:26:37 UTC
I thought that my comment could be edited, but instead a whole new comment was created. Sorry for the duplicate content.
Comment 9 Andreas Schneider 2025-01-05 08:08:40 UTC
Douglas, can you take a look?
Comment 10 Michael Tokarev 2025-01-05 09:41:18 UTC
This looks like a rather unusual usage of GRO.  I'm definitely not an expert in group policies, but I didn't even know about this permission until now, despite we're using group policies heavily for various things.  At first I thought you can't *link* the same GRO into different places in the forest, which is not the case here.

I tried to reproduce the issue, - I succeeded after actually finding the "Apply policy" permission.  I don't yet see how this can be used to bisect the thing though, - at least not easily.
Comment 11 Michael Tokarev 2025-01-05 10:26:04 UTC
The first bad commit appears to be

commit 7f338d6119acd5a3129248d4e61df626f4087560
Author: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Date:   Mon Jan 8 15:05:35 2024 +1300

    ndr: ignore trailing bytes in ndr_pull_security_ace()
    
    This returns the behaviour with ordinary ACEs to where it was with 4.19.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet@samba.org>
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15574
    (cherry picked from commit 0c1f421c107be3156b3f1db75aced24a1bca3d2f)
Comment 12 Michael Tokarev 2025-01-05 10:43:26 UTC
Reverting 0c1f421c107 (and 6fb98f70c62) from 4.21.2 fixes that one too.
Comment 13 Miguel Medalha 2025-01-05 13:57:17 UTC
I see that the Release Notes for Samba 4.20.0 contain several references to changes and new functionality pertaining to ACLs/ACEs.

https://www.samba.org/samba/history/samba-4.20.0.html

This is the version that introduced the bug.
Comment 14 Douglas Bagnall 2025-01-06 00:12:55 UTC
Thanks for the diagnostic work. I will look into it later this week.
Comment 15 Douglas Bagnall 2025-01-06 00:28:44 UTC
(In reply to Douglas Bagnall from comment #14)
Notes mostly to myself I suspect:

0c1f421c107be3156b3f1db75aced24a1bca3d2f was in 
https://gitlab.com/samba-team/samba/-/merge_requests/3489 and I think without it we fail some tests.

6fb98f70c62 is from https://bugzilla.samba.org/show_bug.cgi?id=15613

That bug casts aspersions on ndr_subcontext_size_of_ace_coda() which maybe should be looked at.
Comment 16 Douglas Bagnall 2025-01-06 00:30:00 UTC
(In reply to Miguel Medalha from comment #0)
Does anyone have examples of the ACLs that are causing the trouble?
Comment 17 Björn Jacke 2025-02-12 10:30:18 UTC
Created attachment 18553 [details]
acls of GPO object in sysvol folder before and after sysvolreset

here is the output of samba-tool ntacl get of the GPO on sysvol
Comment 18 Douglas Bagnall 2025-02-13 08:38:57 UTC
Thanks Björn.

I think https://gitlab.com/samba-team/samba/-/merge_requests/3958 fixes the issue, and it also adds tests showing the failure.
Comment 19 Douglas Bagnall 2025-02-13 23:29:47 UTC
Created attachment 18557 [details]
patch for 4.20
Comment 20 Douglas Bagnall 2025-02-13 23:30:30 UTC
Created attachment 18558 [details]
patch for 4.21
Comment 21 Douglas Bagnall 2025-02-13 23:32:01 UTC
Created attachment 18559 [details]
patch for 4.22rc

The backports are identical.
Comment 22 Miguel Medalha 2025-02-14 20:30:56 UTC
I applied the patch to version 4.21.3 and rebuilt it. Looks like it is working correctly now.

Thank you, Douglas, for the good work!
Comment 23 Jule Anger 2025-02-17 09:31:03 UTC
Pushed to autobuild-v4-{22,21,20}-test.
Comment 24 Samba QA Contact 2025-02-17 11:05:32 UTC
This bug was referenced in samba v4-21-test:

b222d6ec73af27caa4e946887059096aceaea07e
e3b3db36171954d3ffdf7386f7b61c39a74b8bb9
Comment 25 Samba QA Contact 2025-02-17 15:53:12 UTC
This bug was referenced in samba v4-21-stable (Release samba-4.21.4):

b222d6ec73af27caa4e946887059096aceaea07e
e3b3db36171954d3ffdf7386f7b61c39a74b8bb9
Comment 26 Samba QA Contact 2025-02-17 17:22:15 UTC
This bug was referenced in samba v4-22-test:

c10e71fb00479e0f7fe0933d98b9ce50e720270a
e951675239b6c0071eaf34635ca2beac4d1a5c18
Comment 27 Samba QA Contact 2025-02-17 17:29:31 UTC
This bug was referenced in samba v4-20-test:

a74d5beb2acac863007af1c7bd525b0e1403134a
f3d65a377add30263a4d6cc71feecdfc4eb6009c
Comment 28 Jule Anger 2025-02-17 17:58:32 UTC
Closing out bug report.

Thanks!
Comment 29 Samba QA Contact 2025-02-20 13:03:02 UTC
This bug was referenced in samba v4-22-stable (Release samba-4.22.0rc3):

c10e71fb00479e0f7fe0933d98b9ce50e720270a
e951675239b6c0071eaf34635ca2beac4d1a5c18
Comment 30 Samba QA Contact 2025-03-25 14:43:18 UTC
This bug was referenced in samba v4-20-stable (Release samba-4.20.8):

a74d5beb2acac863007af1c7bd525b0e1403134a
f3d65a377add30263a4d6cc71feecdfc4eb6009c