[SCM] Samba Shared Repository - branch v4-12-stable updated

Stefan Metzmacher metze at samba.org
Tue Jan 21 16:09:28 UTC 2020


The branch, v4-12-stable has been updated
       via  773c5de6750 VERSION: Disable GIT_SNAPSHOT for the 4.12.0rc1 release...
       via  e1e55a47419 WHATSNEW: Add release note for Samba 4.12.0rc1.
       via  cf9850b4e06 samba-tool group addmembers: avoid python traceback on member add failure
       via  2697415239d selftest: add test for samba-tool groupmember --member-base-dn option
       via  8c5a266ef3f selftest: add tests for samba-tool group addmembers --object-types option
       via  347c65434ec selftest: add test for new samba-tool group addmembers --member-dn option
       via  557fa1d44b6 samba-tool group addmembers: add --member-base-dn option for group member search
       via  5b129bf12ba samba-tool group {add,remove}members: allow to use --member-dn in combination with listofmembers
       via  47f9ee91ed9 samba-tool group removemembers: adapt functionality to addmembers command
       via  aedcf6a5274 samba-tool group addmembers: add --member-dn option
       via  f2e2579926e samba-tool group addmembers: add new option --object-types
       via  a4d77bfd90d python/samdb: validation of group member types for group member filter
       via  f9bf6b7856e python/samdb: add type "all" to search for all common types of group members
       via  c4e899d6b4b python/samdb: adapt search filter for group object type
       via  45abb4fd4f4 python/samdb: adapt search filter for user object type
       via  2baa301237f python/samdb: add 'computer' to the default group member types for group member filters
       via  2abebee1405 python/samdb: fetch specific error if there are more than one search results
       via  e3099ac4072 python/samdb: add more object types for adding/remove group members
       via  662b7458aed python/samdb: add option to specify types of group members
       via  b081bd977c8 samba-tool tests: add test-case for 'ou list --base-dn'
       via  2186c5a6a4c samba-tool: add -b/--base-dn option to OUs list command
       via  918d91bb843 samba-tool tests: add test-case for 'user list --base-dn'
       via  d4de2e3192e samba-tool: add -b/--base-dn option to users list command
       via  55be0f1d2f7 samba-tool tests: add test-case for 'contact list --base-dn'
       via  8a45adb2b19 samba-tool: add -b/--base-dn option to contacts list command
       via  88f0a1390b8 samba-tool tests: add test-case for 'computer list --base-dn'
       via  b292a266a8d samba-tool: add -b/--base-dn option to computer list command
       via  bced03b0d1a samba-tool tests: add test-case for 'group list --base-dn'
       via  8f68236dc4e samba-tool: add -b/--base-dn option to groups list command
       via  b545ab1a85d samba-tool tests: add test-case for 'user getgrouops --full-dn'
       via  41262d1d66c samba-tool: add --full-dn option for user getgroups command
       via  d2d345103b2 samba-tool tests: add test-case for 'group listmembers --full-dn'
       via  bb66b322546 samba-tool: add --full-dn option to group listmembers command
       via  08207f77f13 samba-tool tests: add test case for 'user list --full-dn'
       via  31060963956 samba-tool: add --full-dn option to user list command
       via  2e767e81be4 samba-tool tests: add test case for 'computer list --full-dn'
       via  29326e32645 samba-tool: add --full-dn option to computer list command
       via  e64f7de31fd samba-tool tests: Add test-case for 'group list --full-dn'
       via  51d4c82f3c5 samba-tool: add --full-dn option to group list command
       via  b813ef6ae7a Revert "vfs_glusterfs: Return fake fd from pipe() during open"
       via  cc4a55d290c vfs_glusterfs: add .fcntl_fn hook
       via  b56c56eecdf vfs_ceph: add .fcntl_fn hook
       via  0a77890bbc9 testenv: No "mktemp" for in_screen
       via  823e4de3094 testenv: Simplify "in_screen"
       via  1ca1c601989 testenv: Properly kill daemons
       via  4f1e4f9ce3f testenv: Be more careful deleting environment tmpfiles
      from  85478847a1f WHATSNEW: Add CTDB changes for 4.12

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


- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 VERSION                                   |   6 +-
 WHATSNEW.txt                              |   2 +-
 python/samba/netcmd/computer.py           |  27 +++++-
 python/samba/netcmd/contact.py            |  11 ++-
 python/samba/netcmd/group.py              | 156 ++++++++++++++++++++++++++----
 python/samba/netcmd/ou.py                 |  19 +++-
 python/samba/netcmd/user.py               |  46 ++++++++-
 python/samba/samdb.py                     | 113 +++++++++++++++++-----
 python/samba/tests/samba_tool/computer.py |  39 ++++++++
 python/samba/tests/samba_tool/contact.py  |  19 ++++
 python/samba/tests/samba_tool/group.py    |  66 +++++++++++++
 python/samba/tests/samba_tool/ou.py       |  19 ++++
 python/samba/tests/samba_tool/user.py     |  46 +++++++++
 selftest/in_screen                        |  33 +++----
 source3/modules/vfs_ceph.c                |  29 ++++++
 source3/modules/vfs_glusterfs.c           |  43 +++++---
 source4/setup/tests/blackbox_group.sh     | 130 ++++++++++++++++++++++++-
 17 files changed, 716 insertions(+), 88 deletions(-)


Changeset truncated at 500 lines:

diff --git a/VERSION b/VERSION
index 3f4e84bf0f4..17bb6b45790 100644
--- a/VERSION
+++ b/VERSION
@@ -77,7 +77,7 @@ SAMBA_VERSION_BETA_RELEASE=
 # e.g. SAMBA_VERSION_PRE_RELEASE=1                     #
 #  ->  "2.2.9pre1"                                     #
 ########################################################
-SAMBA_VERSION_PRE_RELEASE=1
+SAMBA_VERSION_PRE_RELEASE=
 
 ########################################################
 # For 'rc' releases the version will be                #
@@ -87,7 +87,7 @@ SAMBA_VERSION_PRE_RELEASE=1
 # e.g. SAMBA_VERSION_RC_RELEASE=1                      #
 #  ->  "3.0.0rc1"                                      #
 ########################################################
-SAMBA_VERSION_RC_RELEASE=
+SAMBA_VERSION_RC_RELEASE=1
 
 ########################################################
 # To mark SVN snapshots this should be set to 'yes'    #
@@ -99,7 +99,7 @@ SAMBA_VERSION_RC_RELEASE=
 # e.g. SAMBA_VERSION_IS_SVN_SNAPSHOT=yes               #
 #  ->  "3.0.0-SVN-build-199"                           #
 ########################################################
-SAMBA_VERSION_IS_GIT_SNAPSHOT=yes
+SAMBA_VERSION_IS_GIT_SNAPSHOT=no
 
 ########################################################
 # This is for specifying a release nickname            #
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 18c787d3cba..0854a63e1c7 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,7 +1,7 @@
 Release Announcements
 =====================
 
-This is the first preview release of Samba 4.12.  This is *not*
+This is the first release candidate of Samba 4.12.  This is *not*
 intended for production environments and is designed for testing
 purposes only.  Please report any defects via the Samba bug reporting
 system at https://bugzilla.samba.org/.
diff --git a/python/samba/netcmd/computer.py b/python/samba/netcmd/computer.py
index 11b2938464a..d48a3e732fd 100644
--- a/python/samba/netcmd/computer.py
+++ b/python/samba/netcmd/computer.py
@@ -527,6 +527,13 @@ class cmd_computer_list(Command):
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server",
                type=str, metavar="URL", dest="H"),
+        Option("-b", "--base-dn",
+               help="Specify base DN to use",
+               type=str),
+        Option("--full-dn", dest="full_dn",
+               default=False,
+               action="store_true",
+               help="Display DN instead of the sAMAccountName.")
     ]
 
     takes_optiongroups = {
@@ -535,7 +542,13 @@ class cmd_computer_list(Command):
         "versionopts": options.VersionOptions,
     }
 
-    def run(self, sambaopts=None, credopts=None, versionopts=None, H=None):
+    def run(self,
+            sambaopts=None,
+            credopts=None,
+            versionopts=None,
+            H=None,
+            base_dn=None,
+            full_dn=False):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
@@ -544,14 +557,22 @@ class cmd_computer_list(Command):
 
         filter = "(sAMAccountType=%u)" % (dsdb.ATYPE_WORKSTATION_TRUST)
 
-        domain_dn = samdb.domain_dn()
-        res = samdb.search(domain_dn, scope=ldb.SCOPE_SUBTREE,
+        search_dn = samdb.domain_dn()
+        if base_dn:
+            search_dn = samdb.normalize_dn_in_domain(base_dn)
+
+        res = samdb.search(search_dn,
+                           scope=ldb.SCOPE_SUBTREE,
                            expression=filter,
                            attrs=["samaccountname"])
         if (len(res) == 0):
             return
 
         for msg in res:
+            if full_dn:
+                self.outf.write("%s\n" % msg.get("dn"))
+                continue
+
             self.outf.write("%s\n" % msg.get("samaccountname", idx=0))
 
 
diff --git a/python/samba/netcmd/contact.py b/python/samba/netcmd/contact.py
index b35f3f16a88..73b7d141af6 100644
--- a/python/samba/netcmd/contact.py
+++ b/python/samba/netcmd/contact.py
@@ -254,6 +254,9 @@ class cmd_list(Command):
                type=str,
                metavar="URL",
                dest="H"),
+        Option("-b", "--base-dn",
+               help="Specify base DN to use.",
+               type=str),
         Option("--full-dn",
                dest="full_dn",
                default=False,
@@ -272,6 +275,7 @@ class cmd_list(Command):
             credopts=None,
             versionopts=None,
             H=None,
+            base_dn=None,
             full_dn=False):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
@@ -281,8 +285,11 @@ class cmd_list(Command):
                       credentials=creds,
                       lp=lp)
 
-        domain_dn = samdb.domain_dn()
-        res = samdb.search(domain_dn,
+        search_dn = samdb.domain_dn()
+        if base_dn:
+            search_dn = samdb.normalize_dn_in_domain(base_dn)
+
+        res = samdb.search(search_dn,
                            scope=ldb.SCOPE_SUBTREE,
                            expression="(objectClass=contact)",
                            attrs=["name"])
diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py
index 95843eecea4..6e5ed1def28 100644
--- a/python/samba/netcmd/group.py
+++ b/python/samba/netcmd/group.py
@@ -218,7 +218,7 @@ sudo samba-tool group addmembers supergroup User2
 Example2 shows how to add a single user account, User2, to the supergroup AD group.  It uses the sudo command to run as root when issuing the command.
 """
 
-    synopsis = "%prog <groupname> <listofmembers> [options]"
+    synopsis = "%prog <groupname> (<listofmembers>]|--member-dn=<member-dn>) [options]"
 
     takes_optiongroups = {
         "sambaopts": options.SambaOptions,
@@ -229,26 +229,68 @@ Example2 shows how to add a single user account, User2, to the supergroup AD gro
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
+        Option("--member-dn",
+               help=("DN of the new group member to be added.\n"
+                     "The --object-types option will be ignored."),
+               type=str,
+               action="append"),
+        Option("--object-types",
+               help=("Comma separated list of object types.\n"
+                     "The types are used to filter the search for the "
+                     "specified members.\n"
+                     "Valid values are: user, group, computer, serviceaccount, "
+                     "contact and all.\n"
+                     "Default: user,group,computer"),
+               default="user,group,computer",
+               type=str),
+        Option("--member-base-dn",
+               help=("Base DN for group member search.\n"
+                     "Default is the domain DN."),
+               type=str),
     ]
 
-    takes_args = ["groupname", "listofmembers"]
+    takes_args = ["groupname", "listofmembers?"]
 
-    def run(self, groupname, listofmembers, credopts=None, sambaopts=None,
-            versionopts=None, H=None):
+    def run(self,
+            groupname,
+            listofmembers=None,
+            credopts=None,
+            sambaopts=None,
+            versionopts=None,
+            H=None,
+            member_base_dn=None,
+            member_dn=None,
+            object_types="user,group,computer"):
 
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
+        if member_dn is None and listofmembers is None:
+            self.usage()
+            raise CommandError(
+                'Either listofmembers or --member-dn must be specified.')
+
         try:
             samdb = SamDB(url=H, session_info=system_session(),
                           credentials=creds, lp=lp)
-            groupmembers = listofmembers.split(',')
+            groupmembers = []
+            if member_dn is not None:
+                groupmembers += member_dn
+            if listofmembers is not None:
+                groupmembers += listofmembers.split(',')
+            group_member_types = object_types.split(',')
+
+            if member_base_dn is not None:
+                member_base_dn = samdb.normalize_dn_in_domain(member_base_dn)
+
             samdb.add_remove_group_members(groupname, groupmembers,
-                                           add_members_operation=True)
+                                           add_members_operation=True,
+                                           member_types=group_member_types,
+                                           member_base_dn=member_base_dn)
         except Exception as e:
             # FIXME: catch more specific exception
-            raise CommandError('Failed to add members "%s" to group "%s"' % (
-                listofmembers, groupname), e)
+            raise CommandError('Failed to add members %r to group "%s" - %s' % (
+                groupmembers, groupname, e))
         self.outf.write("Added members to group %s\n" % groupname)
 
 
@@ -270,7 +312,7 @@ sudo samba-tool group removemembers supergroup User1
 Example2 shows how to remove a single user account, User2, from the supergroup AD group.  It uses the sudo command to run as root when issuing the command.
 """
 
-    synopsis = "%prog <groupname> <listofmembers> [options]"
+    synopsis = "%prog <groupname> (<listofmembers>]|--member-dn=<member-dn>) [options]"
 
     takes_optiongroups = {
         "sambaopts": options.SambaOptions,
@@ -281,24 +323,68 @@ Example2 shows how to remove a single user account, User2, from the supergroup A
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
+        Option("--member-dn",
+               help=("DN of the group member to be removed.\n"
+                     "The --object-types option will be ignored."),
+               type=str,
+               action="append"),
+        Option("--object-types",
+               help=("Comma separated list of object types.\n"
+                     "The types are used to filter the search for the "
+                     "specified members.\n"
+                     "Valid values are: user, group, computer, serviceaccount, "
+                     "contact and all.\n"
+                     "Default: user,group,computer"),
+               default="user,group,computer",
+               type=str),
+        Option("--member-base-dn",
+               help=("Base DN for group member search.\n"
+                     "Default is the domain DN."),
+               type=str),
     ]
 
-    takes_args = ["groupname", "listofmembers"]
+    takes_args = ["groupname", "listofmembers?"]
 
-    def run(self, groupname, listofmembers, credopts=None, sambaopts=None,
-            versionopts=None, H=None):
+    def run(self,
+            groupname,
+            listofmembers=None,
+            credopts=None,
+            sambaopts=None,
+            versionopts=None,
+            H=None,
+            member_base_dn=None,
+            member_dn=None,
+            object_types="user,group,computer"):
 
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
+        if member_dn is None and listofmembers is None:
+            self.usage()
+            raise CommandError(
+                'Either listofmembers or --member-dn must be specified.')
+
         try:
             samdb = SamDB(url=H, session_info=system_session(),
                           credentials=creds, lp=lp)
-            samdb.add_remove_group_members(groupname, listofmembers.split(","),
-                                           add_members_operation=False)
+            groupmembers = []
+            if member_dn is not None:
+                groupmembers += member_dn
+            if listofmembers is not None:
+                groupmembers += listofmembers.split(',')
+            group_member_types = object_types.split(',')
+
+            if member_base_dn is not None:
+                member_base_dn = samdb.normalize_dn_in_domain(member_base_dn)
+
+            samdb.add_remove_group_members(groupname,
+                                           groupmembers,
+                                           add_members_operation=False,
+                                           member_types=group_member_types,
+                                           member_base_dn=member_base_dn)
         except Exception as e:
             # FIXME: Catch more specific exception
-            raise CommandError('Failed to remove members "%s" from group "%s"' % (listofmembers, groupname), e)
+            raise CommandError('Failed to remove members %r from group "%s"' % (listofmembers, groupname), e)
         self.outf.write("Removed members from group %s\n" % groupname)
 
 
@@ -313,7 +399,13 @@ class cmd_group_list(Command):
         Option("-v", "--verbose",
                help="Verbose output, showing group type and group scope.",
                action="store_true"),
-
+        Option("-b", "--base-dn",
+               help="Specify base DN to use.",
+               type=str),
+        Option("--full-dn", dest="full_dn",
+               default=False,
+               action='store_true',
+               help="Display DN instead of the sAMAccountName."),
     ]
 
     takes_optiongroups = {
@@ -322,8 +414,14 @@ class cmd_group_list(Command):
         "versionopts": options.VersionOptions,
     }
 
-    def run(self, sambaopts=None, credopts=None, versionopts=None, H=None,
-            verbose=False):
+    def run(self,
+            sambaopts=None,
+            credopts=None,
+            versionopts=None,
+            H=None,
+            verbose=False,
+            base_dn=None,
+            full_dn=False):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
@@ -334,6 +432,8 @@ class cmd_group_list(Command):
         if verbose:
             attrs += ["grouptype", "member"]
         domain_dn = samdb.domain_dn()
+        if base_dn:
+            domain_dn = samdb.normalize_dn_in_domain(base_dn)
         res = samdb.search(domain_dn, scope=ldb.SCOPE_SUBTREE,
                            expression=("(objectClass=group)"),
                            attrs=attrs)
@@ -367,6 +467,10 @@ class cmd_group_list(Command):
                 self.outf.write("    %6u\n" % num_members)
         else:
             for msg in res:
+                if full_dn:
+                    self.outf.write("%s\n" % msg.get("dn"))
+                    continue
+
                 self.outf.write("%s\n" % msg.get("samaccountname", idx=0))
 
 
@@ -384,6 +488,10 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
+        Option("--full-dn", dest="full_dn",
+               default=False,
+               action='store_true',
+               help="Display DN instead of the sAMAccountName.")
     ]
 
     takes_optiongroups = {
@@ -394,7 +502,13 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
 
     takes_args = ["groupname"]
 
-    def run(self, groupname, credopts=None, sambaopts=None, versionopts=None, H=None):
+    def run(self,
+            groupname,
+            credopts=None,
+            sambaopts=None,
+            versionopts=None,
+            H=None,
+            full_dn=False):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
@@ -425,6 +539,10 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
                 return
 
             for msg in res:
+                if full_dn:
+                    self.outf.write("%s\n" % msg.get("dn"))
+                    continue
+
                 member_name = msg.get("samAccountName", idx=0)
                 if member_name is None:
                     member_name = msg.get("cn", idx=0)
diff --git a/python/samba/netcmd/ou.py b/python/samba/netcmd/ou.py
index a715a5bee13..f68cd2f7af2 100644
--- a/python/samba/netcmd/ou.py
+++ b/python/samba/netcmd/ou.py
@@ -298,6 +298,9 @@ class cmd_list(Command):
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server",
                type=str, metavar="URL", dest="H"),
+        Option("-b", "--base-dn",
+               help="Specify base DN to use.",
+               type=str),
         Option("--full-dn", dest="full_dn", default=False, action='store_true',
                help="Display DNs including the base DN."),
     ]
@@ -308,15 +311,24 @@ class cmd_list(Command):
         "versionopts": options.VersionOptions,
     }
 
-    def run(self, sambaopts=None, credopts=None, versionopts=None, H=None,
+    def run(self,
+            sambaopts=None,
+            credopts=None,
+            versionopts=None,
+            H=None,
+            base_dn=None,
             full_dn=False):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
         samdb = SamDB(url=H, session_info=system_session(),
                       credentials=creds, lp=lp)
 
-        domain_dn = ldb.Dn(samdb, samdb.domain_dn())
-        res = samdb.search(domain_dn, scope=ldb.SCOPE_SUBTREE,
+        search_dn = ldb.Dn(samdb, samdb.domain_dn())
+        if base_dn:
+            search_dn = samdb.normalize_dn_in_domain(base_dn)
+
+        res = samdb.search(search_dn,
+                           scope=ldb.SCOPE_SUBTREE,
                            expression="(objectClass=organizationalUnit)",
                            attrs=[])
         if (len(res) == 0):
@@ -324,6 +336,7 @@ class cmd_list(Command):
 
         for msg in sorted(res, key=attrgetter('dn')):
             if not full_dn:
+                domain_dn = ldb.Dn(samdb, samdb.domain_dn())
                 msg.dn.remove_base_components(len(domain_dn))
             self.outf.write("%s\n" % str(msg.dn))
 
diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py
index c66fd98139c..26db3105da0 100644
--- a/python/samba/netcmd/user.py
+++ b/python/samba/netcmd/user.py
@@ -481,6 +481,13 @@ class cmd_user_list(Command):
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
+        Option("-b", "--base-dn",
+               help="Specify base DN to use",
+               type=str),
+        Option("--full-dn", dest="full_dn",
+               default=False,
+               action='store_true',
+               help="Display DN instead of the sAMAccountName.")
     ]
 
     takes_optiongroups = {
@@ -489,15 +496,25 @@ class cmd_user_list(Command):
         "versionopts": options.VersionOptions,
     }
 
-    def run(self, sambaopts=None, credopts=None, versionopts=None, H=None):
+    def run(self,
+            sambaopts=None,
+            credopts=None,
+            versionopts=None,
+            H=None,
+            base_dn=None,
+            full_dn=False):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
         samdb = SamDB(url=H, session_info=system_session(),
                       credentials=creds, lp=lp)
 
-        domain_dn = samdb.domain_dn()
-        res = samdb.search(domain_dn, scope=ldb.SCOPE_SUBTREE,
+        search_dn = samdb.domain_dn()
+        if base_dn:
+            search_dn = samdb.normalize_dn_in_domain(base_dn)
+
+        res = samdb.search(search_dn,
+                           scope=ldb.SCOPE_SUBTREE,
                            expression=("(&(objectClass=user)(userAccountControl:%s:=%u))"
                                        % (ldb.OID_COMPARATOR_AND, dsdb.UF_NORMAL_ACCOUNT)),
                            attrs=["samaccountname"])
@@ -505,6 +522,10 @@ class cmd_user_list(Command):
             return
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list