[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Wed Jun 20 02:09:04 UTC 2018


The branch, master has been updated
       via  a261a2a python/samba/netcmd: Fix NameError exception
       via  f8ecffb python/samba: enclose map.values with list (py2/py3)
       via  09c2b71 python/samba: Another object.next() to next(object) py2/py3 converstion
       via  b0c9de8 python/samba/emulate: py2/py3 .next usage, replace with next() fn
       via  9e349fe python/samba/tests: py2/py3 port has_keys usage
       via  fd35e53 python/samab: py2/py3 string.upper(astring) -> astring.upper
       via  9650dee python/samba: Py2|Py3 compat, fix more missed exception tuple issues
       via  a3bf30e tests: Increase PSO test timeouts to minimise failures
       via  016fc48 tests: Increase minPwdAge used for PSO tests
      from  e078991 winbind: Fix a typo

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


- Log -----------------------------------------------------------------
commit a261a2a4294a588b07297f3b75ef98cd14984b99
Author: Noel Power <noel.power at suse.com>
Date:   Wed Jun 13 12:51:50 2018 +0100

    python/samba/netcmd: Fix NameError exception
    
    Running make test TEST=samba4.drs.samba_tool_drs.python results in
    
    BlackboxProcessError: Command '/tmp/samba-testbase/b12/samba/bin/samba-tool drs clone-dc-database samba.example.com --server=localdc -USAMBADOMAIN/Administrator%locDCpass1 --targetdir=/tmp/samba-testbase/b12/samba/bin/ab/tmp/tmpWPo8r3'; exit status 255; stdout: ''; stderr: 'ERROR(<type 'exceptions.NameError'>): uncaught exception - global name 'logging' is not defined
      File "bin/python/samba/netcmd/__init__.py", line 177, in _run
        return self.run(*args, **kwargs)
      File "bin/python/samba/netcmd/drs.py", line 697, in run
        logger.setLevel(logging.INFO)
    '
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Wed Jun 20 04:08:53 CEST 2018 on sn-devel-144

commit f8ecffb61a703ebb31ad5c985174c161b44434a4
Author: Noel Power <noel.power at suse.com>
Date:   Thu Jun 14 15:32:03 2018 +0100

    python/samba: enclose map.values with list (py2/py3)
    
    Fix errors in samba.tests.samba_tool.visualize_drs that with python 3
    will generate exception with messages something like
    'can't iterate dict_values'
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 09c2b71e47248543b4b9bde8210af9b6a57ce287
Author: Noel Power <noel.power at suse.com>
Date:   Thu Jun 14 15:48:36 2018 +0100

    python/samba: Another object.next() to next(object) py2/py3 converstion
    
    fix samba.tests.samba_tool.visualize_drs
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b0c9de820c07d77c03b80505cb811ac1dac0808f
Author: Noel Power <noel.power at suse.com>
Date:   Mon May 28 17:01:57 2018 +0100

    python/samba/emulate: py2/py3 .next usage, replace with next() fn

commit 9e349fe82ad622aa856695ba0aa5d61dc2ca0d82
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 11 16:37:44 2018 +0100

    python/samba/tests: py2/py3 port has_keys usage
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit fd35e533f1554c9c8643f62741f25fe7bf8771d5
Author: Noel Power <noel.power at suse.com>
Date:   Mon May 28 16:56:00 2018 +0100

    python/samab: py2/py3 string.upper(astring) -> astring.upper

commit 9650deee03501a4b7f49872ff9917a118de6e7c3
Author: Noel Power <noel.power at suse.com>
Date:   Mon May 28 16:22:25 2018 +0100

    python/samba: Py2|Py3 compat, fix more missed exception tuple issues

commit a3bf30e3a7852e4e0ced9e347363c71b799752f0
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Mon Jun 18 09:52:57 2018 +1200

    tests: Increase PSO test timeouts to minimise failures
    
    When PSOs exist in the DB, there is some extra overhead involved in user
    logins (an extra expand-nested-groups operation for every user login).
    
    Currently password_lockout tests are quite query-intensive - each call
    to _check_account() does ~6 RPC operations/LDB searches (plus sleeps for
    20 millisecs). Plus the actual user login attempt being tested. It looks
    like the current test needs to do 3 login attempts/_check_account()
    calls within a 2-second window. While the PSO test cases usually work
    OK, sometimes they fail (presumably they take slightly longer and fall
    outside this 2-second window). Presumably this is due to the cloud
    instance's CPU being slightly more loaded when the test is run.
    
    Long-term the plan is to refactor the user login so that the extra
    expand-nested-groups operation is unnecessary for PSOs. In the
    short-term, increase the window the test uses from 2 seconds to 3
    seconds.
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 016fc48a30900237205cb60ac9ed5d81c4737cbe
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Mon Jun 18 09:03:40 2018 +1200

    tests: Increase minPwdAge used for PSO tests
    
    The PSO minPwdAge test was using a 1 second timeout. While this seemed
    to work fine most of the time, we did see a rackspace failure that was
    presumably due to the test taking longer than 1-second to execute
    (which resulted in the password not being correctly rejected).
    
    This patch increases the minPwdAge used, to try to avoid this problem
    happening.
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 python/samba/drs_utils.py                      | 2 +-
 python/samba/emulate/traffic.py                | 4 ++--
 python/samba/emulate/traffic_packets.py        | 2 +-
 python/samba/graph.py                          | 8 ++++----
 python/samba/netcmd/drs.py                     | 1 +
 python/samba/provision/__init__.py             | 4 ++--
 python/samba/tests/net_join_no_spnego.py       | 4 ++--
 python/samba/tests/py_credentials.py           | 8 ++++----
 python/samba/tests/upgradeprovisionneeddc.py   | 2 +-
 python/samba/upgradehelpers.py                 | 4 ++--
 source4/dsdb/tests/python/password_lockout.py  | 6 +++++-
 source4/dsdb/tests/python/password_settings.py | 6 +++---
 12 files changed, 28 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/drs_utils.py b/python/samba/drs_utils.py
index 7fab480..aa4605e 100644
--- a/python/samba/drs_utils.py
+++ b/python/samba/drs_utils.py
@@ -319,7 +319,7 @@ class drs_Replicate(object):
                     schema=schema, req_level=req_level, req=req)
             except WERRORError as e:
                 # Check if retrying with the GET_TGT flag set might resolve this error
-                if self._should_retry_with_get_tgt(e[0], req):
+                if self._should_retry_with_get_tgt(e.args[0], req):
 
                     print("Missing target object - retrying with DRS_GET_TGT")
                     req.more_flags |= drsuapi.DRSUAPI_DRS_GET_TGT
diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py
index db0fcf7..dba2c3f 100644
--- a/python/samba/emulate/traffic.py
+++ b/python/samba/emulate/traffic.py
@@ -340,7 +340,7 @@ class ReplayContext(object):
         self.last_netlogon_bad        = False
         self.last_samlogon_bad        = False
         self.generate_ldap_search_tables()
-        self.next_conversation_id = itertools.count().next
+        self.next_conversation_id = next(itertools.count())
 
     def generate_ldap_search_tables(self):
         session = system_session()
@@ -375,7 +375,7 @@ class ReplayContext(object):
         # for k, v in self.dn_map.items():
         #     print >>sys.stderr, k, len(v)
 
-        for k, v in dn_map.items():
+        for k in list(dn_map.keys()):
             if k[-3:] != ',DC':
                 continue
             p = k[:-3]
diff --git a/python/samba/emulate/traffic_packets.py b/python/samba/emulate/traffic_packets.py
index 3f5db43..bc52de0 100644
--- a/python/samba/emulate/traffic_packets.py
+++ b/python/samba/emulate/traffic_packets.py
@@ -47,7 +47,7 @@ def check_runtime_error(runtime, val):
     if runtime is None:
         return False
 
-    err32 = uint32(runtime[0])
+    err32 = uint32(runtime.args[0])
     if err32 == val:
         return True
 
diff --git a/python/samba/graph.py b/python/samba/graph.py
index 0c389a7..e80a882 100644
--- a/python/samba/graph.py
+++ b/python/samba/graph.py
@@ -84,7 +84,7 @@ def shorten_vertex_names(vertices, suffix=',...', aggressive=False):
         # walk backwards along all the strings until we meet a character
         # that is not shared by all.
         i = -1
-        vlist = vmap.values()
+        vlist = list(vmap.values())
         try:
             while True:
                 c = set(x[i] for x in vlist)
@@ -716,10 +716,10 @@ def full_matrix(rows,
         vertices.sort(key=grouping_function)
         colour_list = []
         for k, v in groupby(vertices, key=grouping_function):
-            c = colour_cycle.next()
+            c = next(colour_cycle)
             colour_list.extend(c for x in v)
     else:
-        colour_list = [colour_cycle.next() for v in vertices]
+        colour_list = [next(colour_cycle) for v in vertices]
 
     if shorten_names:
         vmap, replacements = shorten_vertex_names(vertices, '+',
@@ -812,7 +812,7 @@ def full_matrix(rows,
                    10 ** digits - 1))
 
     if shorten_names:
-        example_c = colour_cycle.next()
+        example_c = next(colour_cycle)
         for substitute, original in reversed(replacements):
             write("'%s%s%s' stands for '%s%s%s'" % (example_c,
                                                     substitute,
diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py
index 45ec8f5..235d82b 100644
--- a/python/samba/netcmd/drs.py
+++ b/python/samba/netcmd/drs.py
@@ -38,6 +38,7 @@ from samba.dcerpc import drsuapi, misc
 from samba.join import join_clone
 from samba.ndr import ndr_unpack
 from samba.dcerpc import drsblobs
+import logging
 
 def drsuapi_connect(ctx):
     '''make a DRSUAPI connection to the server'''
diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py
index d9df425..36f50f2 100644
--- a/python/samba/provision/__init__.py
+++ b/python/samba/provision/__init__.py
@@ -195,11 +195,11 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf,
     names.adminpass = None
 
     # NT domain, kerberos realm, root dn, domain dn, domain dns name
-    names.domain = string.upper(lp.get("workgroup"))
+    names.domain = lp.get("workgroup").upper()
     names.realm = lp.get("realm")
     names.dnsdomain = names.realm.lower()
     basedn = samba.dn_from_dns_name(names.dnsdomain)
-    names.realm = string.upper(names.realm)
+    names.realm = names.realm.upper()
     # netbiosname
     # Get the netbiosname first (could be obtained from smb.conf in theory)
     res = secretsdb.search(expression="(flatname=%s)" %
diff --git a/python/samba/tests/net_join_no_spnego.py b/python/samba/tests/net_join_no_spnego.py
index 09a2856..85c6f88 100644
--- a/python/samba/tests/net_join_no_spnego.py
+++ b/python/samba/tests/net_join_no_spnego.py
@@ -55,7 +55,7 @@ class NetJoinNoSpnegoTests(samba.tests.TestCaseInTempDir):
                 self.domain, netbios_name, LIBNET_JOIN_AUTOMATIC,
                 machinepass=machinepass)
         except NTSTATUSError as e:
-            code = ctypes.c_uint32(e[0]).value
+            code = ctypes.c_uint32(e.args[0]).value
             if code == ntstatus.NT_STATUS_CONNECTION_DISCONNECTED:
                 self.fail("Connection failure")
             elif code == ntstatus.NT_STATUS_ACCESS_DENIED:
@@ -82,7 +82,7 @@ class NetJoinNoSpnegoTests(samba.tests.TestCaseInTempDir):
                 self.domain, netbios_name, LIBNET_JOIN_AUTOMATIC,
                 machinepass=machinepass)
         except NTSTATUSError as e:
-            code = ctypes.c_uint32(e[0]).value
+            code = ctypes.c_uint32(e.args[0]).value
             if code == ntstatus.NT_STATUS_CONNECTION_DISCONNECTED:
                 self.fail("Connection failure")
             raise
diff --git a/python/samba/tests/py_credentials.py b/python/samba/tests/py_credentials.py
index 2f5a7d6..c29afd1 100644
--- a/python/samba/tests/py_credentials.py
+++ b/python/samba/tests/py_credentials.py
@@ -123,7 +123,7 @@ class PyCredentialsTests(TestCase):
                                    validation_level,
                                    netr_flags)
         except NTSTATUSError as e:
-            enum = ctypes.c_uint32(e[0]).value
+            enum = ctypes.c_uint32(e.args[0]).value
             if enum == ntstatus.NT_STATUS_WRONG_PASSWORD:
                 self.fail("got wrong password error")
             else:
@@ -150,7 +150,7 @@ class PyCredentialsTests(TestCase):
                                    validation_level,
                                    netr_flags)
         except NTSTATUSError as e:
-            enum = ctypes.c_uint32(e[0]).value
+            enum = ctypes.c_uint32(e.args[0]).value
             if enum == ntstatus.NT_STATUS_WRONG_PASSWORD:
                 self.fail("got wrong password error")
             else:
@@ -176,7 +176,7 @@ class PyCredentialsTests(TestCase):
                                    validation_level,
                                    netr_flags)
         except NTSTATUSError as e:
-            enum = ctypes.c_uint32(e[0]).value
+            enum = ctypes.c_uint32(e.args[0]).value
             if enum == ntstatus.NT_STATUS_WRONG_PASSWORD:
                 self.fail("got wrong password error")
             else:
@@ -204,7 +204,7 @@ class PyCredentialsTests(TestCase):
                                    validation_level,
                                    netr_flags)
         except NTSTATUSError as e:
-            enum = ctypes.c_uint32(e[0]).value
+            enum = ctypes.c_uint32(e.args[0]).value
             if enum == ntstatus.NT_STATUS_WRONG_PASSWORD:
                 self.fail("got wrong password error")
             else:
diff --git a/python/samba/tests/upgradeprovisionneeddc.py b/python/samba/tests/upgradeprovisionneeddc.py
index bf25453..21c08ab 100644
--- a/python/samba/tests/upgradeprovisionneeddc.py
+++ b/python/samba/tests/upgradeprovisionneeddc.py
@@ -91,7 +91,7 @@ class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
         hashAtt = search_constructed_attrs_stored(self.ldbs.sam,
                                                   self.names.rootdn,
                                                   ["msds-KeyVersionNumber"])
-        self.assertFalse(hashAtt.has_key("msds-KeyVersionNumber"))
+        self.assertFalse("msds-KeyVersionNumber" in hashAtt)
 
     def test_increment_calculated_keyversion_number(self):
         dn = "CN=Administrator,CN=Users,%s" % self.names.rootdn
diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py
index 14fe3e0..5e5655d 100644
--- a/python/samba/upgradehelpers.py
+++ b/python/samba/upgradehelpers.py
@@ -489,7 +489,7 @@ def increment_calculated_keyversion_number(samdb, rootdn, hashDns):
         raise ProvisioningError("Unable to find msDs-KeyVersionNumber")
     else:
         for e in entry:
-            if hashDns.has_key(str(e.dn).lower()):
+            if str(e.dn).lower() in hashDns:
                 val = e.get("msDs-KeyVersionNumber")
                 if not val:
                     val = "0"
@@ -689,7 +689,7 @@ def search_constructed_attrs_stored(samdb, rootdn, attrs):
     for ent in entry:
         for att in attrs:
             if ent.get(att):
-                if hashAtt.has_key(att):
+                if att in hashAtt:
                     hashAtt[att][str(ent.dn).lower()] = str(ent[att])
                 else:
                     hashAtt[att] = {}
diff --git a/source4/dsdb/tests/python/password_lockout.py b/source4/dsdb/tests/python/password_lockout.py
index 26decf6..ec6cf13 100755
--- a/source4/dsdb/tests/python/password_lockout.py
+++ b/source4/dsdb/tests/python/password_lockout.py
@@ -618,9 +618,13 @@ userPassword: thatsAcomplPASS2XYZ
     def use_pso_lockout_settings(self, creds):
         # create a PSO with the lockout settings the test cases normally expect
         pso = PasswordSettings("lockout-PSO", self.ldb, lockout_attempts=3,
-                               lockout_duration=2)
+                               lockout_duration=3)
         self.addCleanup(self.ldb.delete, pso.dn)
 
+        # the test cases should sleep() for the PSO's lockoutDuration/obsvWindow
+        self.account_lockout_duration = 3
+        self.lockout_observation_window = 3
+
         userdn = "cn=%s,cn=users,%s" % (creds.get_username(), self.base_dn)
         pso.apply_to(userdn)
 
diff --git a/source4/dsdb/tests/python/password_settings.py b/source4/dsdb/tests/python/password_settings.py
index d072a8f..12779a0 100644
--- a/source4/dsdb/tests/python/password_settings.py
+++ b/source4/dsdb/tests/python/password_settings.py
@@ -451,7 +451,7 @@ class PasswordSettingsTestCase(PasswordTestCase):
     def test_pso_min_age(self):
         """Tests that a PSO's min-age is enforced"""
         pso = PasswordSettings("min-age-PSO", self.ldb, password_len=10,
-                               password_age_min=1, complexity=False)
+                               password_age_min=2, complexity=False)
         self.add_obj_cleanup([pso.dn])
 
         # create a user and apply the PSO
@@ -462,8 +462,8 @@ class PasswordSettingsTestCase(PasswordTestCase):
         # changing the password immediately should fail, even if password is valid
         valid_password = "min-age-passwd"
         self.assert_password_invalid(user, valid_password)
-        # then trying the same password later (min-age=1sec) should succeed
-        time.sleep(1.5)
+        # then trying the same password later should succeed
+        time.sleep(pso.password_age_min + 0.5)
         self.assert_password_valid(user, valid_password)
 
     def test_pso_max_age(self):


-- 
Samba Shared Repository



More information about the samba-cvs mailing list