[SCM] Samba Shared Repository - branch v4-11-test updated

Karolin Seeger kseeger at samba.org
Fri Mar 27 11:55:02 UTC 2020


The branch, v4-11-test has been updated
       via  45fab149767 selftest: test samba-tool group commands with groupnames with brackets and spaces
       via  5608ab2f62d samba-tool group edit: use binary encoded group name
       via  f8525b2aa46 samba-tool group delete: use binary encoded group name
       via  b1d664f9541 samba-tool group move: use binary encoded group name
       via  6122aa423f2 samba-tool group listmembers: use binary encoded group names
       via  0d95ad22384 samba-tool group listmembers: find group members by groups SID
       via  f4fc8a04596 samba-tool group listmembers: handle group-does-not-exist error
       via  496424ebd63 samba-tool group listmembers: hide python backtracke on command error
      from  ab7fe462500 ctdb-tcp: Do not stop outbound connection in ctdb_tcp_node_connect()

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


- Log -----------------------------------------------------------------
commit 45fab149767a951f458514093c12a5238b41c9e7
Author: Björn Baumbach <bb at sernet.de>
Date:   Thu Feb 27 11:06:34 2020 +0100

    selftest: test samba-tool group commands with groupnames with brackets and spaces
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 534809a0f09775390e89fa1cbfae3a1d0fafecb8)
    
    Autobuild-User(v4-11-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-11-test): Fri Mar 27 11:54:17 UTC 2020 on sn-devel-184

commit 5608ab2f62dca919016e3d7cedbd5601fe587d45
Author: Björn Baumbach <bb at sernet.de>
Date:   Wed Feb 26 13:56:14 2020 +0100

    samba-tool group edit: use binary encoded group name
    
    Allows to edit groups with names like e.g. 'group1 (xy)'.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit f3e7ea0405d46ddfbeba9b3a84c13b7878464180)

commit f8525b2aa46edab630e1252bfd912126b365ac97
Author: Björn Baumbach <bb at sernet.de>
Date:   Wed Feb 26 13:55:01 2020 +0100

    samba-tool group delete: use binary encoded group name
    
    Allows to delete groups with names like e.g. 'group1 (xy)'.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 104582b73caf008600e15d76d57424263a0f28d4)

commit b1d664f9541e1949676c4709158f82906d058157
Author: Björn Baumbach <bb at sernet.de>
Date:   Wed Feb 26 13:40:50 2020 +0100

    samba-tool group move: use binary encoded group name
    
    Allows to move groups with names like e.g. 'group1 (xy)'.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 626209beab2fc9b0fdb7e90338cdfec5cfa48dd7)

commit 6122aa423f26d02336547034e920fe1000234599
Author: Björn Baumbach <bb at sernet.de>
Date:   Wed Feb 26 13:38:50 2020 +0100

    samba-tool group listmembers: use binary encoded group names
    
    Allows to find groups with names like e.g. 'group1 (xy)'.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit d0f8e833653df652df01a472c4bbfd256f10f810)

commit 0d95ad22384d069b58b7271fe1e77a9c0e86a5af
Author: Björn Baumbach <bb at sernet.de>
Date:   Wed Feb 26 13:39:44 2020 +0100

    samba-tool group listmembers: find group members by groups SID
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 1d2e9f27fa9cff55245e45a194f696fc9ca4376d)

commit f4fc8a045967ae0b915e2964c60591524e33f56e
Author: Björn Baumbach <bb at sernet.de>
Date:   Wed Feb 26 13:08:43 2020 +0100

    samba-tool group listmembers: handle group-does-not-exist error
    
    Return a error with a proper message instead of just do nothing when
    the target group does not exist.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14296
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 40e498e743e4677a42030373e8d97f6f9763080a)

commit 496424ebd6371c3e1bfac53c184f184c93083087
Author: Björn Baumbach <bb at sernet.de>
Date:   Wed Feb 26 13:05:16 2020 +0100

    samba-tool group listmembers: hide python backtracke on command error
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 789d84c0a9a406f7e0c9ab48cf2f31afdc4d3829)

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

Summary of changes:
 python/samba/netcmd/group.py           | 41 ++++++++++++++++++----------------
 python/samba/tests/samba_tool/group.py |  3 ++-
 2 files changed, 24 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py
index 536c1cba613..88e666e27dc 100644
--- a/python/samba/netcmd/group.py
+++ b/python/samba/netcmd/group.py
@@ -178,7 +178,7 @@ Example2 deletes group Group2 from the local server.  The command is run under r
                       credentials=creds, lp=lp)
 
         filter = ("(&(sAMAccountName=%s)(objectClass=group))" %
-                  groupname)
+                  ldb.binary_encode(groupname))
 
         try:
             res = samdb.search(base=samdb.domain_dn(),
@@ -401,21 +401,22 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
             samdb = SamDB(url=H, session_info=system_session(),
                           credentials=creds, lp=lp)
 
-            search_filter = "(&(objectClass=group)(samaccountname=%s))" % groupname
-            res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE,
-                               expression=(search_filter),
-                               attrs=["objectSid"])
-
-            if (len(res) != 1):
-                return
-
-            group_dn = res[0].get('dn', idx=0)
-            object_sid = res[0].get('objectSid', idx=0)
-
-            object_sid = ndr_unpack(security.dom_sid, object_sid)
-            (group_dom_sid, rid) = object_sid.split()
-
-            search_filter = "(|(primaryGroupID=%s)(memberOf=%s))" % (rid, group_dn)
+            search_filter = ("(&(objectClass=group)(sAMAccountName=%s))" %
+                             ldb.binary_encode(groupname))
+            try:
+                res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE,
+                                   expression=(search_filter),
+                                   attrs=["objectSid"])
+                group_sid_binary = res[0].get('objectSid', idx=0)
+            except IndexError:
+                raise CommandError('Unable to find group "%s"' % (groupname))
+
+            group_sid = ndr_unpack(security.dom_sid, group_sid_binary)
+            (group_dom_sid, rid) = group_sid.split()
+            group_sid_dn = "<SID=%s>" % (group_sid)
+
+            search_filter = ("(|(primaryGroupID=%s)(memberOf=%s))" %
+                             (rid, group_sid_dn))
             res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE,
                                expression=(search_filter),
                                attrs=["samAccountName", "cn"])
@@ -430,7 +431,8 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
                 self.outf.write("%s\n" % member_name)
 
         except Exception as e:
-            raise CommandError('Failed to list members of "%s" group ' % groupname, e)
+            raise CommandError('Failed to list members of "%s" group - %s' %
+                               (groupname, e))
 
 
 class cmd_group_move(Command):
@@ -486,7 +488,7 @@ class cmd_group_move(Command):
         domain_dn = ldb.Dn(samdb, samdb.domain_dn())
 
         filter = ("(&(sAMAccountName=%s)(objectClass=group))" %
-                  groupname)
+                  ldb.binary_encode(groupname))
         try:
             res = samdb.search(base=domain_dn,
                                expression=filter,
@@ -754,7 +756,8 @@ class cmd_group_edit(Command):
         samdb = SamDB(url=H, session_info=system_session(),
                       credentials=creds, lp=lp)
 
-        filter = ("(&(sAMAccountName=%s)(objectClass=group))" % groupname)
+        filter = ("(&(sAMAccountName=%s)(objectClass=group))" %
+                  ldb.binary_encode(groupname))
 
         domaindn = samdb.domain_dn()
 
diff --git a/python/samba/tests/samba_tool/group.py b/python/samba/tests/samba_tool/group.py
index e521c720b77..864c3876acb 100644
--- a/python/samba/tests/samba_tool/group.py
+++ b/python/samba/tests/samba_tool/group.py
@@ -39,8 +39,9 @@ class GroupCmdTestCase(SambaToolCmdTest):
         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": "testgroup5 (with brackets)"}))
 
-        # setup the 4 groups and ensure they are correct
+        # setup the 5 groups and ensure they are correct
         for group in self.groups:
             (result, out, err) = self._create_group(group)
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list