Bug 15838 - samba-tool group removemembers returns success even if it should fail
Summary: samba-tool group removemembers returns success even if it should fail
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Python (show other bugs)
Version: 4.22.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Douglas Bagnall
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-21 11:26 UTC by Kacper
Modified: 2026-01-28 21:03 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kacper 2025-03-21 11:26:16 UTC
samba-tool group removemembers returns success even if it should fail if the primary group of the member to remove is also the group from which we try to remove the member from.

Steps to Reproduce:
Create a user using samba-tool (eg. samba-tool user add test01), that user will get the group "Domain Users" as it's primary group by default.

Try to remove the user from the "Domain Users" group (eg. samba-tool group removemembers "Domain Users" test01)

Expected Result:
samba-tool should refuse to remove the user from it's primary group with an error message.

Actual Result:
samba-tool claims the user has been removed (eg. "Removed members from group Domain Users") but in fact it has not.
Comment 1 Douglas Bagnall 2026-01-28 04:50:10 UTC
OK.

It look like we don't even consider the primary group here.

I guess we could check for that in the case where nothing has happened (i.e. in SamDB.add_remove_group_members() the group members don't overlap with the listed members, but the group and listed members do exist).
Comment 2 Rowland Penny 2026-01-28 09:29:14 UTC
(In reply to Douglas Bagnall from comment #1)
It is fairly easy:
Get the users primaryGroupID, cat that onto the end of the domain SID and compare with the groups objectSid, if they match, print a message along the lines of 'sorry, you cannot do that'.