[SCM] Samba Shared Repository - branch master updated

Douglas Bagnall dbagnall at samba.org
Fri Nov 2 05:57:02 UTC 2018


The branch, master has been updated
       via  537a26d tests/py/rodc_rwdc: Fix py2/py3 .next compat issues
       via  78f5b6e s4/scripting/*: py3 compatible print
       via  1cf142c selftesthelpers: fix py3 tests with extra_path
       via  f17a77a python dbcheck: don't use mutable default args
      from  28826ec WHATSNEW: KDC prefork support

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 537a26d6d1d1c04456ec0f0b28f04a7de86af027
Author: Noel Power <noel.power at suse.com>
Date:   Thu Nov 1 12:53:01 2018 +0000

    tests/py/rodc_rwdc: Fix py2/py3 .next compat issues
    
    Python 3 does not have .next(), which we rely on, change the
    code slightly so it works in py2/py3 (using builtin next function)
    
    Pair-programmed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    
    Autobuild-User(master): Douglas Bagnall <dbagnall at samba.org>
    Autobuild-Date(master): Fri Nov  2 06:56:24 CET 2018 on sn-devel-144

commit 78f5b6e3999a0bf4a118df36a2aabcb696049792
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sun Oct 28 11:12:48 2018 +1300

    s4/scripting/*: py3 compatible print
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit 1cf142c30abaec2e99cebca15ac61685723032ed
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sun Oct 28 10:53:49 2018 +1300

    selftesthelpers: fix py3 tests with extra_path
    
    If a test was supplied with extra_path, a PYTHONPATH= env variable was
    prepended to the args list, but the py3_compatible clause assumed the
    first args element was /usr/bin/python.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit f17a77af4602af02ebb05b8f6d6344c2dadf62f0
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Oct 26 19:33:48 2018 +1300

    python dbcheck: don't use mutable default args
    
    In this code
    
    def f(a, b=[]):
        b.append(a)
        return b
    
    all single argument calls to f() will affect the same copy of b.
    
    In the controls case, controls=None has the same effect as
    controls=[].
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Noel Power <noel.power at suse.com>

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

Summary of changes:
 python/samba/dbchecker.py                    | 14 ++++++++------
 selftest/selftesthelpers.py                  | 15 +++++++++------
 source4/dsdb/tests/python/rodc_rwdc.py       |  5 ++---
 source4/scripting/bin/enablerecyclebin       |  2 +-
 source4/scripting/bin/findprovisionusnranges | 14 ++++++--------
 source4/scripting/bin/fullschema             |  2 +-
 source4/scripting/bin/get-descriptors        |  2 +-
 source4/scripting/bin/minschema              |  2 +-
 source4/scripting/bin/mymachinepw            |  7 +++----
 source4/scripting/bin/rebuildextendeddn      | 12 +++++++-----
 source4/scripting/bin/sambaundoguididx       |  2 +-
 source4/scripting/bin/smbstatus              | 10 ++++++----
 source4/scripting/devel/addlotscontacts      |  2 +-
 source4/scripting/devel/config_base          |  2 +-
 source4/scripting/devel/crackname            |  2 +-
 source4/scripting/devel/enumprivs            |  2 +-
 source4/scripting/devel/getncchanges         |  2 +-
 17 files changed, 51 insertions(+), 46 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index 9af1116..030bea4 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -226,7 +226,8 @@ class dbcheck(object):
                 raise
             pass
 
-    def check_database(self, DN=None, scope=ldb.SCOPE_SUBTREE, controls=[], attrs=['*']):
+    def check_database(self, DN=None, scope=ldb.SCOPE_SUBTREE, controls=None,
+                       attrs=None):
         '''perform a database check, returning the number of errors found'''
         res = self.samdb.search(base=DN, scope=scope, attrs=['dn'], controls=controls)
         self.report('Checking %u objects' % len(res))
@@ -2021,14 +2022,15 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
 
         raise KeyError
 
-    def check_object(self, dn, attrs=['*']):
+    def check_object(self, dn, attrs=None):
         '''check one object'''
         if self.verbose:
             self.report("Checking object %s" % dn)
-
-        # If we modify the pass-by-reference attrs variable, then we get a
-        # replPropertyMetadata for every object that we check.
-        attrs = list(attrs)
+        if attrs is None:
+            attrs = ['*']
+        else:
+            # make a local copy to modify
+            attrs = list(attrs)
         if "dn" in map(str.lower, attrs):
             attrs.append("name")
         if "distinguishedname" in map(str.lower, attrs):
diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py
index 25977ef..b0fc79b 100644
--- a/selftest/selftesthelpers.py
+++ b/selftest/selftesthelpers.py
@@ -136,18 +136,21 @@ def planperltestsuite(name, path):
         skiptestsuite(name, "Test::More not available")
 
 
-def planpythontestsuite(env, module, name=None, extra_path=[], py3_compatible=False):
+def planpythontestsuite(env, module, name=None, extra_path=None,
+                        py3_compatible=False):
     if name is None:
         name = module
-    pypath = list(extra_path)
     args = [python, "-m", "samba.subunit.run", "$LISTOPT", "$LOADLIST", module]
-    if pypath:
-        args.insert(0, "PYTHONPATH=%s" % ":".join(["$PYTHONPATH"] + pypath))
-    plantestsuite_loadlist(name, env, args)
+    if extra_path:
+        pypath = ["PYTHONPATH=$PYTHONPATH:%s" % ":".join(extra_path)]
+    else:
+        pypath = []
+
+    plantestsuite_loadlist(name, env, pypath + args)
     if py3_compatible and extra_python is not None:
         # Plan one more test for Python 3 compatible module
         args[0] = extra_python
-        plantestsuite_loadlist(name + ".python3", env, args)
+        plantestsuite_loadlist(name + ".python3", env, pypath + args)
 
 
 def get_env_torture_options():
diff --git a/source4/dsdb/tests/python/rodc_rwdc.py b/source4/dsdb/tests/python/rodc_rwdc.py
index cc715e6..7a2e3b4 100644
--- a/source4/dsdb/tests/python/rodc_rwdc.py
+++ b/source4/dsdb/tests/python/rodc_rwdc.py
@@ -115,7 +115,6 @@ def get_server_ref_from_samdb(samdb):
 
 
 class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase):
-    counter = itertools.count(1).next
 
     def _check_account_initial(self, dn):
         self.force_replication()
@@ -686,7 +685,7 @@ class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase):
 
 
 class RodcRwdcTests(password_lockout_base.BasePasswordTestCase):
-    counter = itertools.count(1).next
+    counter = itertools.count(1, 1)
 
     def force_replication(self, base=None):
         if base is None:
@@ -982,7 +981,7 @@ class RodcRwdcTests(password_lockout_base.BasePasswordTestCase):
         self._test_add_modify_delete()
 
     def _new_user(self):
-        username = "u%sX%s" % (self.tag[:12], self.counter())
+        username = "u%sX%s" % (self.tag[:12], next(self.counter))
         password = 'password#1'
         dn = 'CN=%s,CN=Users,%s' % (username, self.base_dn)
         o = {
diff --git a/source4/scripting/bin/enablerecyclebin b/source4/scripting/bin/enablerecyclebin
index ab36ead..a179698 100755
--- a/source4/scripting/bin/enablerecyclebin
+++ b/source4/scripting/bin/enablerecyclebin
@@ -50,4 +50,4 @@ msg["enableOptionalFeature"] = ldb.MessageElement(
      ldb.FLAG_MOD_ADD, "enableOptionalFeature")
 res = sam_ldb.modify(msg)
 
-print "Recycle Bin feature enabled"
+print("Recycle Bin feature enabled")
diff --git a/source4/scripting/bin/findprovisionusnranges b/source4/scripting/bin/findprovisionusnranges
index ee9da3d..540869d 100755
--- a/source4/scripting/bin/findprovisionusnranges
+++ b/source4/scripting/bin/findprovisionusnranges
@@ -18,7 +18,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
 import sys
 import optparse
 sys.path.insert(0, "bin/python")
@@ -63,18 +62,17 @@ if res and len(res) == 1 and res[0]["dsServiceName"] != None:
     if res and len(res) == 1 and res[0]["invocationId"]:
         invocation = str(ndr_unpack(misc.GUID, res[0]["invocationId"][0]))   
     else:
-        print "Unable to find invocation ID"
+        print("Unable to find invocation ID")
         sys.exit(1)
 else:
-    print "Unable to find attribute dsServiceName in rootDSE"
+    print("Unable to find attribute dsServiceName in rootDSE")
     sys.exit(1)
 
 minobj = 5
 (hash_id, nb_obj) = findprovisionrange(samdb, basedn)
-print "Here is a list of changes that modified more than %d objects in 1 minute." % minobj
-print "Usually changes made by provision and upgradeprovision are those who affect a couple"\
-        " of hundred of objects or more"
-print "Total number of objects: %d" % nb_obj
-print 
+print("Here is a list of changes that modified more than %d objects in 1 minute." % minobj)
+print("Usually changes made by provision and upgradeprovision are those who affect a couple"
+      " of hundred of objects or more")
+print("Total number of objects: %d\n" % nb_obj)
 
 print_provision_ranges(hash_id, minobj, opts.storedir, str(paths.samdb), invocation)
diff --git a/source4/scripting/bin/fullschema b/source4/scripting/bin/fullschema
index ab0e4e3..596de01 100755
--- a/source4/scripting/bin/fullschema
+++ b/source4/scripting/bin/fullschema
@@ -132,7 +132,7 @@ def fix_dn(dn):
 
 def write_ldif_one(o, attrs):
     """dump an object as ldif"""
-    print "dn: CN=%s,${SCHEMADN}" % o["cn"]
+    print("dn: CN=%s,${SCHEMADN}" % o["cn"])
     for a in attrs:
         if not o.has_key(a):
             continue
diff --git a/source4/scripting/bin/get-descriptors b/source4/scripting/bin/get-descriptors
index f1a919c..70926cd 100755
--- a/source4/scripting/bin/get-descriptors
+++ b/source4/scripting/bin/get-descriptors
@@ -90,7 +90,7 @@ class DescrGetter:
         for line in ldif_entry:
             length = 79
             if len(line) <= length + 1:
-                print line
+                print(line)
             else:
                 for i in range(len(line) / length + 1):
                     if i == 0:
diff --git a/source4/scripting/bin/minschema b/source4/scripting/bin/minschema
index 477c69b..e70d79a 100755
--- a/source4/scripting/bin/minschema
+++ b/source4/scripting/bin/minschema
@@ -191,7 +191,7 @@ def fix_dn(dn):
 
 def write_ldif_one(o, attrs):
     """dump an object as ldif"""
-    print "dn: CN=%s,${SCHEMADN}" % o["cn"]
+    print("dn: CN=%s,${SCHEMADN}" % o["cn"])
     for a in attrs:
         if not o.has_key(a):
             continue
diff --git a/source4/scripting/bin/mymachinepw b/source4/scripting/bin/mymachinepw
index dc85ad1..91dc502 100755
--- a/source4/scripting/bin/mymachinepw
+++ b/source4/scripting/bin/mymachinepw
@@ -19,7 +19,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
 import samba.param as param, ldb, sys, getopt
 
 optlist, args = getopt.getopt(sys.argv[1:], "s:")
@@ -48,9 +47,9 @@ search = ("(&(objectclass=primaryDomain)(samaccountname=" +
 msg = secrets.search(expression=search, attrs=['secret'])
 
 if not msg:
-    print "Error:"
-    print "Password for host[%s] not found in path[%s]." % (netbios, path)
-    print "You may want to pass the smb.conf location via the -s option."
+    print("Error:")
+    print("Password for host[%s] not found in path[%s]." % (netbios, path))
+    print("You may want to pass the smb.conf location via the -s option.")
     exit(1)
 
 password=msg[0]['secret'][0]
diff --git a/source4/scripting/bin/rebuildextendeddn b/source4/scripting/bin/rebuildextendeddn
index 5a0ab12..5f5e05d 100755
--- a/source4/scripting/bin/rebuildextendeddn
+++ b/source4/scripting/bin/rebuildextendeddn
@@ -21,7 +21,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
+from __future__ import print_function
 import optparse
 import os
 import sys
@@ -53,7 +53,7 @@ opts = parser.parse_args()[0]
 def message(text):
     """print a message if quiet is not set."""
     if not opts.quiet:
-        print text
+        print(text)
 
 if len(sys.argv) == 1:
     opts.interactive = True
@@ -77,7 +77,7 @@ def get_paths(targetdir=None,smbconf=None):
             smbconf = param.default_path()
 
     if not os.path.exists(smbconf):
-        print >>sys.stderr, "Unable to find smb.conf .. "+smbconf
+        print("Unable to find smb.conf .. "+smbconf, file=sys.stderr)
         parser.print_usage()
         sys.exit(1)
 
@@ -121,9 +121,11 @@ def rebuild_en_dn(credentials,session_info,paths):
                 sam_ldb.modify(m)
                 res3 = sam_ldb.search(expression="(&(distinguishedName=%s)(%s=*))"%(dn,att),scope=SCOPE_SUBTREE, attrs=[att],controls=["search_options:1:2"])
                 if( len(res3) == 0  or (len(res3[0][att])!= len(saveatt))):
-                    print >>sys.stderr, str(dn) + " has no attr " +att+ " or a wrong value"
+                    print(str(dn) + " has no attr " +att+ " or a wrong value",
+                          file=sys.stderr)
                     for satt in saveatt:
-                        print >>sys.stderr,str(att)+"    =    "+satt
+                        print("%s    =    %s" % (att, satt),
+                              file=sys.stderr)
                     sam_ldb.transaction_cancel()
     sam_ldb.transaction_commit()
 
diff --git a/source4/scripting/bin/sambaundoguididx b/source4/scripting/bin/sambaundoguididx
index 24a95e2..a931601 100755
--- a/source4/scripting/bin/sambaundoguididx
+++ b/source4/scripting/bin/sambaundoguididx
@@ -71,7 +71,7 @@ for db in dbs:
 
 samdb.transaction_commit()
 
-print "Re-opening with the full DB stack"
+print("Re-opening with the full DB stack")
 samdb = SamDB(url=url,
                           lp=lp_ctx)
 print "Re-triggering another re-index"
diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus
index 473dbaf..c2834ab 100755
--- a/source4/scripting/bin/smbstatus
+++ b/source4/scripting/bin/smbstatus
@@ -27,12 +27,14 @@ def show_sessions(conn):
     """show open sessions"""
 
     sessions = next(conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS))
-    print "User                                  Client      Connected at"
-    print "-" * 79
+    print("User                                  Client      Connected at")
+    print("-" * 79)
     for session in sessions:
         fulluser = "%s/%s" % (session.account_name, session.domain_name)
-        print "%-30s %16s   %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time))
-    print ""
+        print("%-30s %16s   %s" % (fulluser,
+                                   session.client_ip,
+                                   sys.httptime(session.connect_time)))
+    print()
 
 def show_tcons(open_connection):
     """show open tree connects"""
diff --git a/source4/scripting/devel/addlotscontacts b/source4/scripting/devel/addlotscontacts
index edf54b0..e8b2c1a 100644
--- a/source4/scripting/devel/addlotscontacts
+++ b/source4/scripting/devel/addlotscontacts
@@ -75,7 +75,7 @@ if __name__ == '__main__':
 
         ldbs.sam.add(msg)
 
-    print "Creating %d contacts" % num_contacts
+    print("Creating %d contacts" % num_contacts)
     count = 0
     increment = num_contacts / 10
     if increment > 5000:
diff --git a/source4/scripting/devel/config_base b/source4/scripting/devel/config_base
index 0d495c5..e74c874 100755
--- a/source4/scripting/devel/config_base
+++ b/source4/scripting/devel/config_base
@@ -37,4 +37,4 @@ for v in vars:
 
 options = options.replace("${PREFIX}", prefix)
 
-print options
+print(options)
diff --git a/source4/scripting/devel/crackname b/source4/scripting/devel/crackname
index 2e17985..0ae177c 100755
--- a/source4/scripting/devel/crackname
+++ b/source4/scripting/devel/crackname
@@ -56,7 +56,7 @@ if __name__ == "__main__":
 
     drs = drsuapi.drsuapi(binding_str, lp, creds)
     drs_handle = do_DsBind(drs)
-    print "DRS Handle: %s" % drs_handle
+    print("DRS Handle: %s" % drs_handle)
 
     req = drsuapi.DsNameRequest1()
     names = drsuapi.DsNameString()
diff --git a/source4/scripting/devel/enumprivs b/source4/scripting/devel/enumprivs
index 6a04040..33597f9 100755
--- a/source4/scripting/devel/enumprivs
+++ b/source4/scripting/devel/enumprivs
@@ -55,4 +55,4 @@ if __name__ == "__main__":
     (handle, privs) = lsaconn.EnumPrivs(pol_handle, 0, 100)
     for p in privs.privs:
         disp_name = get_display_name(lsaconn, pol_handle, p.name.string)
-        print "0x%08x %31s \"%s\"" % (p.luid.low, p.name.string, disp_name)
+        print("0x%08x %31s \"%s\"" % (p.luid.low, p.name.string, disp_name))
diff --git a/source4/scripting/devel/getncchanges b/source4/scripting/devel/getncchanges
index 9b6361b..9c25e39 100755
--- a/source4/scripting/devel/getncchanges
+++ b/source4/scripting/devel/getncchanges
@@ -76,7 +76,7 @@ if __name__ == "__main__":
 
     drs = drsuapi.drsuapi(binding_str, lp, creds)
     drs_handle, supported_extensions = drs_DsBind(drs)
-    print "DRS Handle: %s" % drs_handle
+    print("DRS Handle: %s" % drs_handle)
 
     req8 = drsuapi.DsGetNCChangesRequest8()
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list