The branch, v4-22-test has been updated
       via  76d1b6b1807 python: Do not interpret 16 character group names as 
GUIDs
       via  de43d8e305d pytest: samba-tool group: test with 16 character name
       via  d80ff2e1e58 pytest:samba-tool group: test addmembers
      from  de600282aaf VERSION: Bump version up to Samba 4.22.3...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-22-test


- Log -----------------------------------------------------------------
commit 76d1b6b180790b20b54265e4798e8cbaf899b405
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Fri Jun 13 12:29:02 2025 +1200

    python: Do not interpret 16 character group names as GUIDs
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15854
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Björn Baumbach <b...@samba.org>
    
    Autobuild-User(master): Douglas Bagnall <dbagn...@samba.org>
    Autobuild-Date(master): Mon Jun 16 22:22:27 UTC 2025 on atb-devel-224
    
    (cherry picked from commit 7c99658e22c6761ccf9abbdea588553a46af7453)
    
    Autobuild-User(v4-22-test): Jule Anger <jan...@samba.org>
    Autobuild-Date(v4-22-test): Thu Jun 19 08:49:44 UTC 2025 on atb-devel-224

commit de43d8e305da2a87792ee4dbd807895c039e4e14
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Fri Jun 13 11:38:22 2025 +1200

    pytest: samba-tool group: test with 16 character name
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15854
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Björn Baumbach <b...@samba.org>
    (cherry picked from commit f545a77a3c466e2be37e0c453861566d42b1a01d)

commit d80ff2e1e58dab4ee1c7de7f05fb3275c2a25239
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Fri Jun 13 12:23:30 2025 +1200

    pytest:samba-tool group: test addmembers
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15854
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Björn Baumbach <b...@samba.org>
    (cherry picked from commit 3150d103bb2990e005d70c90f3f9c316c5353005)

-----------------------------------------------------------------------

Summary of changes:
 python/samba/samdb.py                  | 10 +++++++++-
 python/samba/tests/samba_tool/group.py | 17 ++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/samdb.py b/python/samba/samdb.py
index 0545aed98eb..7a1cee1e108 100644
--- a/python/samba/samdb.py
+++ b/python/samba/samdb.py
@@ -35,6 +35,7 @@ from samba.common import normalise_int32
 from samba.common import get_bytes, cmp
 from samba.dcerpc import security
 from samba import is_ad_dc_built
+from samba import string_is_guid
 from samba import NTSTATUSError, ntstatus
 import binascii
 
@@ -388,6 +389,13 @@ lockoutTime: 0
 
         partial_groupfilter = None
 
+        # If <group> looks like a SID, GUID, or DN, we use it
+        # accordingly, otherwise as a name.
+        #
+        # Because misc.GUID() will read any 16 byte sequence as a
+        # binary guid, we need to be careful not to read 16 character
+        # names as GUIDs.
+
         group_sid = None
         try:
             group_sid = security.dom_sid(group)
@@ -397,7 +405,7 @@ lockoutTime: 0
             partial_groupfilter = "(objectClass=*)"
 
         group_guid = None
-        if partial_groupfilter is None:
+        if partial_groupfilter is None and string_is_guid(group):
             try:
                 group_guid = misc.GUID(group)
             except NTSTATUSError as e:
diff --git a/python/samba/tests/samba_tool/group.py 
b/python/samba/tests/samba_tool/group.py
index e8c0960849f..1c5bc9690f9 100644
--- a/python/samba/tests/samba_tool/group.py
+++ b/python/samba/tests/samba_tool/group.py
@@ -38,7 +38,8 @@ class GroupCmdTestCase(SambaToolCmdTest):
         self.groups.append(self._randomGroup({"name": "testgroup1"}))
         self.groups.append(self._randomGroup({"name": "testgroup2"}))
         self.groups.append(self._randomGroup({"name": "testgroup3"}))
-        self.groups.append(self._randomGroup({"name": "testgroup4"}))
+        self.groups.append(self._randomGroup(
+            {"name": "16 character name for bug 15854"[:16]}))
         self.groups.append(self._randomGroup({"name": "testgroup5 (with 
brackets)"}))
         self.groups.append(self._randomPosixGroup({"name": "posixgroup1"}))
         self.groups.append(self._randomPosixGroup({"name": "posixgroup2"}))
@@ -334,6 +335,20 @@ class GroupCmdTestCase(SambaToolCmdTest):
             name = str(groupobj.get("dn", idx=0))
             self.assertMatch(out, name, "group '%s' not found" % name)
 
+    def test_addmember(self):
+        groups = [g['name'] for g in self.groups]
+        for parent, child in zip(groups, groups[1:]):
+            (result, out, err) = self.runsubcmd(
+                "group", "addmembers", parent, child)
+            self.assertCmdSuccess(result, out, err)
+
+        (result, out, err) = self.runsubcmd(
+            "group", "addmembers", groups[-1], ','.join(groups[:-1]))
+        self.assertCmdSuccess(result, out, err)
+
+        (result, out, err) = self.runsubcmd(
+            "group", "addmembers", groups[0], "alice,bob")
+        self.assertCmdSuccess(result, out, err)
 
     def test_move(self):
         full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest_grp"))


-- 
Samba Shared Repository

Reply via email to