[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Mon Sep 3 04:15:02 UTC 2018


The branch, master has been updated
       via  74357bf selftest: Split up password_lockout into tests with and without a call to sleep()
       via  a740a61 selftest: Prepare to allow override of lockout duration in password_lockout tests
       via  9eb2606 s4/selftest: enable samba.tests.samba_tool.user_virtualCryptSHA for py3
       via  82408fd python/samba/netcmd: PY2/PY3 changes required for user_virtualCryptSHA test
       via  17290a3 s4/selftest: enable samba.tests.samba_tool.user for py3
       via  c6fd15e python/samba/tests: Adjust teardown so second run of tests succeeds
       via  9df799d python/samba/tests: PY2/PY3 required changes for samba.tests.samba_tool.user
       via  f5726dd s4/selftest: enable samba.tests.dcerpc.raw_protocol for py3
       via  a467dc2 python/samba/test/dcerpc: Py3 port of samba.tests.dcerpc.raw_protocol
       via  c958a04 python/samba/tests: ensure byte content (not strings)
       via  b3a5dac s4/selftest: enable samba.tests.dcerpc.dnsserver(ad_dc) for python3
       via  179cd3d s4/selftest: enable samba.tests.dcerpc.dnsserver for python3
       via  945359b selftest: Update known fail with py3 variant of samba.tests.dcerpc.dnsserver
       via  f304a27 s4/selftest: enable samba.tests.samba_tool.dnscmd for py3
       via  ffdbc4a s4/selftest: Enable samba.tests.samba_tool.sites for py3
       via  9bded41 s4/selftest: enable samba.tests.samba_tool.help for py3
       via  f86693c python/samba/tests: Py2/Py2 enable samba.tests.samba_tool.help to run
       via  4188a02 s4/selftest: Enable samba.tests.samba_tool.provision_password_check for py3
       via  252950a python/samba/netcmd: Fix password usage for py2/py3 compatability
       via  7a2df70 s4/selftest: enable samba.tests.samba_tool.ntacl for Py3
       via  84c890b python/samba/provision: remove use of str() func for binary data
       via  683d51f python/samba/netcmd: changes for samab.tests.samba_tool.computer
       via  4764ac0 s4/selftest: enable samba.tests.samba_tool.ou for py3
       via  a167c44 s4/selftest: enable samba.tests.group for py3
       via  dd1fce7 python/sambe/tests/samba_tool: PY3 port for tests.samba_tool.group
       via  765b176 s4/selftest: enable samba.tests.samba_tool.user_check_password_script py3
       via  d29fdb0 s4/selftest: enable samba.tests.samba_tool.user_wdigest for python3
       via  638476f python/samba: PY3 port for samba.tests.samba_tool.user_wdigest test
       via  210b950 python/samba: Add some helper functions to encode/decode strings
       via  783d856 s4/selftest: enable samba.tests.samba_tool.processes for PY3
       via  f0f1872 s3/selftest: Enable samba.tests.samba_tool.fsmo for python3
       via  a701a25 python/samba/tests: Port fsmo test to python3
       via  e59ed0a enable samba_tool.visualize_drs samba_tool.visualize_drs for py3
       via  471163e python/samba: changes needed for samba.tests.samba_tool.visualize PY2/PY3
       via  bff4d80 s4/selftest: Enable samba.tests.samba_tool.join for py3
       via  c6100d7 python/samba: changes to make samba.tests.samba_tool.join run under py3
       via  94c23ee python/compat: use cStringIO instead of StringIO in compat.py
       via  563c10e python/samba/tests: Use io.StringIO for py3 and StringIO.StrinIO for py2
       via  0e53629 s4/selftest/tests: enable samba.tests.samba_tool.timecmd for python3
       via  5efb5ad s4/selftest: enable samba.tests.dcerpc.unix for python3
       via  48f3801 python/samba/tests: port samba.tests.unix for py3
       via  999b6db s4/selftest: enable samba.tests.dsdb_lock for python3
       via  27df0e8 python/samba: port changes to allow samba.tests.dsdb_lock to work with PY3/PY2
       via  596db3a python/samba: open files in binary mode as appropriate
       via  9688480 python/samba: port open to io.open for PY2/PY3 compat
       via  45c0ec8 python/samba: Fix py2/3 relative module import issue
       via  ac30d7b selftest: Remove excption for NSS_WRAPPER_HOSTS and RESOLV_WRAPPER_HOSTS
       via  85ef059 selftest: Set RESOLV_WRAPPER_CONF/RESOLV_WRAPPER_HOSTS when running dcpromo
       via  cfb19e9 selftest: Set NSS_WRAPPER_HOSTS when creating the trusts
      from  5d95f79 s3:smbd: add a comment stating that file_close_user() is redundant for SMB2

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


- Log -----------------------------------------------------------------
commit 74357bf347348d3a8b7483c58e5250e98f7e8810
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Sep 2 18:03:06 2018 +1200

    selftest: Split up password_lockout into tests with and without a call to sleep()
    
    This means we can have a long observation window for many of the tests and
    so make them much more reliable.  Many of these cause frustrating flapping
    failures in our CI systems.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Mon Sep  3 06:14:55 CEST 2018 on sn-devel-144

commit a740a6131c967f9640b19a6964fd5d6f85ce853a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Sep 2 17:34:03 2018 +1200

    selftest: Prepare to allow override of lockout duration in password_lockout tests
    
    This will make it easier to avoid flapping tests.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit 9eb26065d0c64c21bf09023d0c199445adb7e8a8
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 3 20:31:07 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.user_virtualCryptSHA for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 82408fdc1f6c92baacd207438ffbcf9710e127ac
Author: Noel Power <noel.power at suse.com>
Date:   Wed Aug 15 16:40:16 2018 +0100

    python/samba/netcmd: PY2/PY3 changes required for user_virtualCryptSHA test
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 17290a3770f1dacdded2fe7821a3afe4f523b424
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 3 19:30:06 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.user for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit c6fd15e2337e821cdb102d08cd889aa11336e145
Author: Noel Power <noel.power at suse.com>
Date:   Tue Aug 14 11:43:44 2018 +0100

    python/samba/tests: Adjust teardown so second run of tests succeeds
    
    A second run of this test (e.g. with --extra-python) or even
    an manual re-run and the cache is still there.
    use of '--cache-ldb-initialize'  will fail and so with the test
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 9df799d1b2c0d1d211b105ac43b8f7332622d547
Author: Noel Power <noel.power at suse.com>
Date:   Tue Aug 14 11:25:35 2018 +0100

    python/samba/tests: PY2/PY3 required changes for samba.tests.samba_tool.user
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f5726ddc9da131125d4c6d5598a866fbd225db3c
Author: Noel Power <noel.power at suse.com>
Date:   Tue May 1 12:51:41 2018 +0100

    s4/selftest: enable samba.tests.dcerpc.raw_protocol for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit a467dc2a3135a8140cff7a655bd195f1df0762a1
Author: Noel Power <noel.power at suse.com>
Date:   Tue May 1 12:24:47 2018 +0100

    python/samba/test/dcerpc: Py3 port of samba.tests.dcerpc.raw_protocol
    
    Port code to allow this test run with either py2 or py3
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit c958a04327b4c6598cf8666edfbd44fc5fa15c96
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 30 18:31:36 2018 +0100

    python/samba/tests: ensure byte content (not strings)
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b3a5dac3e3f617bc49fcd33cf56e3ea466cfe6ad
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 30 16:35:59 2018 +0100

    s4/selftest: enable samba.tests.dcerpc.dnsserver(ad_dc) for python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 179cd3dbdb7cb95ea15a93abaf3552d347ade42e
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 30 16:20:05 2018 +0100

    s4/selftest: enable samba.tests.dcerpc.dnsserver for python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 945359bc6fac52339a49ba3e224b02faa823decc
Author: Noel Power <noel.power at suse.com>
Date:   Tue Aug 28 12:05:14 2018 +0100

    selftest: Update known fail with py3 variant of samba.tests.dcerpc.dnsserver
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f304a273d64fb27f5d7de7a3fd2b630b6141bf70
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 30 16:06:12 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.dnscmd for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ffdbc4aa67ceba983f4eb45595a6d0c0eaa00e04
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 30 15:47:05 2018 +0100

    s4/selftest: Enable samba.tests.samba_tool.sites for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 9bded41d2ae0174a40596ffdb8122bc58b2aabb2
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 27 15:49:40 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.help for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f86693c84c51b39e8303d06eb3510e016efaab87
Author: Noel Power <noel.power at suse.com>
Date:   Mon Aug 13 17:25:37 2018 +0100

    python/samba/tests: Py2/Py2 enable samba.tests.samba_tool.help to run
    
    Ensure bytes output is converted to text type for PY3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4188a02bc21dcef37da1e31da731d8473f2becf5
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 27 15:13:49 2018 +0100

    s4/selftest: Enable samba.tests.samba_tool.provision_password_check for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 252950ac08554d7c86a5cfc2c7fbc626c4c5f863
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 27 15:11:54 2018 +0100

    python/samba/netcmd: Fix password usage for py2/py3 compatability
    
    getpass returns str (e.g. bytes) in python2 and str (unicode) in
    py3. Adapt code to so we don't do illegal things (like try and decode)
    a string in python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 7a2df705f6a834194e2e50210bf36a0d425a8fa1
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 27 13:05:15 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.ntacl for Py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 84c890b244c6a72c9be18e91b508e186ae51046c
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 27 13:02:50 2018 +0100

    python/samba/provision: remove use of str() func for binary data
    
    Python 2 code works with str(policy["nTSecurityDescriptor"]) however
    this cannot work with Python 3. One could argue even the str method
    doesn't make sense at all (returning a string) for data.
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 683d51fb5cd7c859cff718d671832247b0a8b3a4
Author: Noel Power <noel.power at suse.com>
Date:   Thu Apr 26 18:22:21 2018 +0100

    python/samba/netcmd: changes for samab.tests.samba_tool.computer
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4764ac05e67dd770894e563fbca31314fb196695
Author: Noel Power <noel.power at suse.com>
Date:   Thu Apr 26 15:47:19 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.ou for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit a167c449d152e232e47ee076b24fd9d7e539af64
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 24 19:08:27 2018 +0100

    s4/selftest: enable samba.tests.group for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit dd1fce7cdb1d1b05c37409fcb185e3bd6ed88d28
Author: Noel Power <noel.power at suse.com>
Date:   Sat Aug 11 14:25:26 2018 +0100

    python/sambe/tests/samba_tool: PY3 port for tests.samba_tool.group
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 765b17627c0b1475ebb206526d2ee5433dcebb18
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 24 16:55:49 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.user_check_password_script py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit d29fdb02e6aeee9d229367dc2133cfaffc3bc8cd
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 23 18:22:08 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.user_wdigest for python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 638476f86d4f8072de186eac562c176bacef68ef
Author: Noel Power <noel.power at suse.com>
Date:   Sat Aug 11 14:02:25 2018 +0100

    python/samba: PY3 port for samba.tests.samba_tool.user_wdigest test
    
    In addition to the attributes that caused some issues specifically
    with the test some other ldb.bytes objects (those seen to be
    used as strings) have been adjusted (with str()) to ensure they should
    work correct in PY3.
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 210b950c81d252c0af0fb82cb9241fad0ead5280
Author: Noel Power <noel.power at suse.com>
Date:   Sat Aug 11 13:54:51 2018 +0100

    python/samba: Add some helper functions to encode/decode strings
    
    Sometimes in PY3 we have variables whose content can be 'bytes' or
    'str' and we can't be sure which. Generally this is because the
    code variable to be used can be initialised (or reassigned) a value
    from different api(s) or functions depending on complex conditions or
    logic. Or another common case is in PY2 the variable is 'type <str>'
    and in PY3 it is 'class <str>' but the function to use e.g. b64encode
    requires 'bytes' in PY3. In such cases in PY3 it would be nice to avoid
    excessive testing in the client code, in PY2 we would like to ensure the
    code runs unchanged. In otherwords we wish to avoid in PY2 unnecessary
    decode() calls which convert otherwise 'str' types to 'unicode'.
    Mixing 'str' and 'unicode' can cause strange and unexpected problems,
    sometimes we can't avoid this but it we should avoid if we can.
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 783d8565b424f5ac8bd640357b11929c944e708f
Author: Noel Power <noel.power at suse.com>
Date:   Fri Aug 10 21:23:35 2018 +0100

    s4/selftest: enable samba.tests.samba_tool.processes for PY3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f0f1872ee129a484641ceff95c253ad90d5e0f92
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 23 12:21:53 2018 +0100

    s3/selftest: Enable samba.tests.samba_tool.fsmo for python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit a701a253269f959c9faa9e4faa888cbecc2dcfe6
Author: Noel Power <noel.power at suse.com>
Date:   Fri Aug 10 20:29:46 2018 +0100

    python/samba/tests: Port fsmo test to python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit e59ed0a375e974ebcea80f5f23cb9b3651a3c651
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 20 17:24:44 2018 +0100

    enable samba_tool.visualize_drs samba_tool.visualize_drs for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 471163e82e1651f9051622be349a5e868db420bd
Author: Noel Power <noel.power at suse.com>
Date:   Fri Aug 10 18:07:11 2018 +0100

    python/samba: changes needed for samba.tests.samba_tool.visualize PY2/PY3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit bff4d80a23dcd7d61f24a7a4b6284ed980ee6a4c
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 17 16:48:56 2018 +0100

    s4/selftest: Enable samba.tests.samba_tool.join for py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit c6100d777bbd73c9e58adb372972f02d7655ee13
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 17 16:48:03 2018 +0100

    python/samba: changes to make samba.tests.samba_tool.join run under py3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 94c23ee046ca9cfa36ab5aedfeb56faf8eee459c
Author: Noel Power <noel.power at suse.com>
Date:   Fri Aug 10 19:54:46 2018 +0100

    python/compat: use cStringIO instead of StringIO in compat.py
    
    Using cStringIO for py2 seems to incur alot less problems and less changes
    to the py2/py3 code then using StringIO.StringIO
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 563c10ee63c401345bed707b9f14b41d5d2799f7
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 4 11:49:23 2018 +0100

    python/samba/tests: Use io.StringIO for py3 and StringIO.StrinIO for py2
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 0e53629ff3f07880dfb2933919c3d913aa0d016d
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 17 13:53:57 2018 +0100

    s4/selftest/tests: enable samba.tests.samba_tool.timecmd for python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 5efb5ad9abc95d9da73f200720316b1e244334eb
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 16 18:58:01 2018 +0100

    s4/selftest: enable samba.tests.dcerpc.unix for python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 48f3801c207e6c172a75f27da29aa0f0001d51b5
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 17 11:56:40 2018 +0100

    python/samba/tests: port samba.tests.unix for py3
    
    L for long literal is no longer valid in Python3, also
    long keyword has been removed. int and long have been unified
    in python3. A duplicated test has been removed (for long and
    int) only the int test remains now.
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 999b6db6e3aa3371a1ed42a92e7b7efebb2514bf
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 10 16:03:37 2018 +0100

    s4/selftest: enable samba.tests.dsdb_lock for python3
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 27df0e81c2b79ff4e2a1f990375a7e2a7d210b07
Author: Noel Power <noel.power at suse.com>
Date:   Wed Aug 8 17:03:48 2018 +0100

    python/samba: port changes to allow samba.tests.dsdb_lock to work with PY3/PY2
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 596db3a5bbca2e93e22a4405d2ad60144bcaf273
Author: Noel Power <noel.power at suse.com>
Date:   Wed Aug 8 16:56:33 2018 +0100

    python/samba: open files in binary mode as appropriate
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 9688480dab2fef7124297e676ec2ea4e1f7a47c7
Author: Noel Power <noel.power at suse.com>
Date:   Wed Aug 8 16:52:35 2018 +0100

    python/samba: port open to io.open for PY2/PY3 compat
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 45c0ec855f80a4e1c61e28ec52a23542caa8a0bc
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 30 15:46:04 2018 +0100

    python/samba: Fix py2/3 relative module import issue
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ac30d7b6c43bd194f029a6d8f34b4bb1bece9953
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 31 20:26:19 2018 +1200

    selftest: Remove excption for NSS_WRAPPER_HOSTS and RESOLV_WRAPPER_HOSTS
    
    These must be set correctly for each command in provision also.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit 85ef0590a544e97f2c800589d05646002c48b95a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 1 23:12:44 2018 +1200

    selftest: Set RESOLV_WRAPPER_CONF/RESOLV_WRAPPER_HOSTS when running dcpromo
    
    Otherwise this relies on the order that tests run to cause the environment variable
    to be left behind.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit cfb19e98b1afe8c23fb65dd3e1448f51cc0ab591
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 31 20:22:54 2018 +1200

    selftest: Set NSS_WRAPPER_HOSTS when creating the trusts
    
    Otherwise this relies on the order that tests run to cause the environment variable
    to be left behind.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

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

Summary of changes:
 python/samba/compat.py                             |  66 +++-
 python/samba/dbchecker.py                          |   4 +-
 python/samba/gpclass.py                            |   2 +-
 python/samba/join.py                               |   6 +-
 python/samba/kcc/kcc_utils.py                      |   2 +-
 python/samba/ms_display_specifiers.py              |   3 +-
 python/samba/ms_schema.py                          |   3 +-
 python/samba/netcmd/computer.py                    |   2 +-
 python/samba/netcmd/domain.py                      |   7 +-
 python/samba/netcmd/domain_backup.py               |   4 +-
 python/samba/netcmd/nettime.py                     |   2 +-
 python/samba/netcmd/user.py                        |  51 ++--
 python/samba/netcmd/visualize.py                   |   6 +-
 python/samba/provision/__init__.py                 |  19 +-
 python/samba/remove_dc.py                          |   2 +-
 python/samba/samdb.py                              |   6 +-
 python/samba/schema.py                             |   4 +-
 python/samba/subnets.py                            |   2 +-
 python/samba/tests/blackbox/samba_dnsupdate.py     |   2 +-
 python/samba/tests/dcerpc/raw_protocol.py          | 339 +++++++++++----------
 python/samba/tests/dcerpc/raw_testcase.py          |  39 +--
 python/samba/tests/dcerpc/unix.py                  |  10 +-
 python/samba/tests/emulate/traffic.py              |   2 +-
 python/samba/tests/netcmd.py                       |   2 +-
 python/samba/tests/samba_tool/base.py              |   2 +-
 python/samba/tests/samba_tool/computer.py          |   4 +-
 python/samba/tests/samba_tool/fsmo.py              |   4 +-
 python/samba/tests/samba_tool/group.py             |   4 +-
 python/samba/tests/samba_tool/help.py              |   5 +-
 python/samba/tests/samba_tool/user.py              |  16 +-
 python/samba/tests/samba_tool/user_wdigest.py      |   2 +-
 selftest/knownfail                                 |   3 +
 selftest/selftest.pl                               |   6 +-
 selftest/target/Samba3.pm                          |  18 +-
 selftest/target/Samba4.pm                          |  36 ++-
 source4/dsdb/tests/python/password_lockout.py      | 300 +++++++++---------
 source4/dsdb/tests/python/password_lockout_base.py |  11 +-
 source4/selftest/tests.py                          |  46 +--
 38 files changed, 582 insertions(+), 460 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/compat.py b/python/samba/compat.py
index aa1ac29..e151d9e 100644
--- a/python/samba/compat.py
+++ b/python/samba/compat.py
@@ -22,6 +22,42 @@ import sys
 PY3 = sys.version_info[0] == 3
 
 if PY3:
+    # Sometimes in PY3 we have variables whose content can be 'bytes' or
+    # 'str' and we can't be sure which. Generally this is because the
+    # code variable can be initialised (or reassigned) a value from different
+    # api(s) or functions depending on complex conditions or logic. Or another
+    # common case is in PY2 the variable is 'type <str>' and in PY3 it is
+    # 'class <str>' and the function to use e.g. b64encode requires 'bytes'
+    # in PY3. In such cases it would be nice to avoid excessive testing in
+    # the client code. Calling such a helper function should be avoided
+    # if possible but sometimes this just isn't possible.
+    # If a 'str' object is passed in it is encoded using 'utf8' or if 'bytes'
+    # is passed in it is returned unchanged.
+    # Using this function is PY2/PY3 code should ensure in most cases
+    # the PY2 code runs unchanged in PY2 whereas the code in PY3 possibly
+    # encodes the variable (see PY2 implementation of this function below)
+    def get_bytes(bytesorstring):
+       tmp = bytesorstring
+       if isinstance(bytesorstring, str):
+           tmp = bytesorstring.encode('utf8')
+       elif not isinstance(bytesorstring, bytes):
+           raise ValueError('Expected byte or string for %s:%s' % (type(bytesorstring), bytesorstring))
+       return tmp
+
+    # helper function to get a string from a variable that maybe 'str' or
+    # 'bytes' if 'bytes' then it is decoded using 'utf8'. If 'str' is passed
+    # it is returned unchanged
+    # Using this function is PY2/PY3 code should ensure in most cases
+    # the PY2 code runs unchanged in PY2 whereas the code in PY3 possibly
+    # decodes the variable (see PY2 implementation of this function below)
+    def get_string(bytesorstring):
+       tmp = bytesorstring
+       if isinstance(bytesorstring, bytes):
+           tmp = bytesorstring.decode('utf8')
+       elif not isinstance(bytesorstring, str):
+           raise ValueError('Expected byte of string for %s:%s' % (type(bytesorstring), bytesorstring))
+       return tmp
+
     def cmp_fn(x, y):
         """
         Replacement for built-in function cmp that was removed in Python 3
@@ -47,6 +83,32 @@ if PY3:
     import io
     StringIO = io.StringIO
 else:
+    # Helper function to return bytes.
+    # if 'unicode' is passed in then it is decoded using 'utf8' and
+    # the result returned. If 'str' is passed then it is returned unchanged.
+    # Using this function is PY2/PY3 code should ensure in most cases
+    # the PY2 code runs unchanged in PY2 whereas the code in PY3 possibly
+    # encodes the variable (see PY3 implementation of this function above)
+    def get_bytes(bytesorstring):
+       tmp = bytesorstring
+       if isinstance(bytesorstring, unicode):
+           tmp = bytesorstring.encode('utf8')
+       elif not isinstance(bytesorstring, str):
+           raise ValueError('Expected string for %s:%s' % (type(bytesorstring), bytesorstring))
+       return tmp
+
+    # Helper function to return string.
+    # if 'str' or 'unicode' passed in they are returned unchanged
+    # otherwise an exception is generated
+    # Using this function is PY2/PY3 code should ensure in most cases
+    # the PY2 code runs unchanged in PY2 whereas the code in PY3 possibly
+    # decodes the variable (see PY3 implementation of this function above)
+    def get_string(bytesorstring):
+       tmp = bytesorstring
+       if not(isinstance(bytesorstring, str) or isinstance(bytesorstring, unicode)):
+           raise ValueError('Expected str or unicode for %s:%s' % (type(bytesorstring), bytesorstring))
+       return tmp
+
 
     if sys.version_info < (2, 7):
         def cmp_to_key_fn(mycmp):
@@ -92,6 +154,6 @@ else:
     binary_type = str
 
     # alias
-    import StringIO
-    StringIO = StringIO.StringIO
+    import cStringIO
+    StringIO = cStringIO.StringIO
     cmp_fn = cmp
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index ae93ed1..beb664d 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -293,7 +293,7 @@ class dbcheck(object):
                     # as the original one, so that on replication we
                     # merge, rather than conflict.
                     proposed_objectguid = dsdb_dn.dn.get_extended_component("GUID")
-                listwko.append(o)
+                listwko.append(str(o))
 
             if proposed_objectguid is not None:
                 guid_suffix = "\nobjectGUID: %s" % str(misc.GUID(proposed_objectguid))
@@ -2223,7 +2223,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
                 values = set()
                 # check for incorrectly normalised attributes
                 for val in obj[attrname]:
-                    values.add(str(val))
+                    values.add(val)
 
                     normalised = self.samdb.dsdb_normalise_attributes(self.samdb_schema, attrname, [val])
                     if len(normalised) != 1 or normalised[0] != val:
diff --git a/python/samba/gpclass.py b/python/samba/gpclass.py
index 8fb2f93..3cf1f10 100644
--- a/python/samba/gpclass.py
+++ b/python/samba/gpclass.py
@@ -22,7 +22,7 @@ import tdb
 sys.path.insert(0, "bin/python")
 from samba import NTSTATUSError
 from ConfigParser import ConfigParser
-from StringIO import StringIO
+from samba.compat import StringIO
 from abc import ABCMeta, abstractmethod
 import xml.etree.ElementTree as etree
 import re
diff --git a/python/samba/join.py b/python/samba/join.py
index 9cab604..e7963eea 100644
--- a/python/samba/join.py
+++ b/python/samba/join.py
@@ -354,21 +354,21 @@ class DCJoinContext(object):
 
     def get_dnsHostName(ctx):
         res = ctx.samdb.search(base="", scope=ldb.SCOPE_BASE, attrs=["dnsHostName"])
-        return res[0]["dnsHostName"][0]
+        return str(res[0]["dnsHostName"][0])
 
     def get_domain_name(ctx):
         '''get netbios name of the domain from the partitions record'''
         partitions_dn = ctx.samdb.get_partitions_dn()
         res = ctx.samdb.search(base=partitions_dn, scope=ldb.SCOPE_ONELEVEL, attrs=["nETBIOSName"],
                                expression='ncName=%s' % ldb.binary_encode(str(ctx.samdb.get_default_basedn())))
-        return res[0]["nETBIOSName"][0]
+        return str(res[0]["nETBIOSName"][0])
 
     def get_forest_domain_name(ctx):
         '''get netbios name of the domain from the partitions record'''
         partitions_dn = ctx.samdb.get_partitions_dn()
         res = ctx.samdb.search(base=partitions_dn, scope=ldb.SCOPE_ONELEVEL, attrs=["nETBIOSName"],
                                expression='ncName=%s' % ldb.binary_encode(str(ctx.samdb.get_root_basedn())))
-        return res[0]["nETBIOSName"][0]
+        return str(res[0]["nETBIOSName"][0])
 
     def get_parent_partition_dn(ctx):
         '''get the parent domain partition DN from parent DNS name'''
diff --git a/python/samba/kcc/kcc_utils.py b/python/samba/kcc/kcc_utils.py
index c099140..9959637 100644
--- a/python/samba/kcc/kcc_utils.py
+++ b/python/samba/kcc/kcc_utils.py
@@ -994,7 +994,7 @@ class NTDSConnection(object):
             self.schedule = ndr_unpack(drsblobs.schedule, msg["schedule"][0])
 
         if "whenCreated" in msg:
-            self.whenCreated = ldb.string_to_time(msg["whenCreated"][0])
+            self.whenCreated = ldb.string_to_time(str(msg["whenCreated"][0]))
 
         if "fromServer" in msg:
             dsdn = dsdb_Dn(samdb, msg["fromServer"][0].decode('utf8'))
diff --git a/python/samba/ms_display_specifiers.py b/python/samba/ms_display_specifiers.py
index 2a81c22..7488b19 100644
--- a/python/samba/ms_display_specifiers.py
+++ b/python/samba/ms_display_specifiers.py
@@ -176,7 +176,8 @@ def read_ms_ldif(filename):
 
     out = []
 
-    f = open(filename, "rU")
+    from io import open
+    f = open(filename, "r", encoding='latin-1')
     for entry in __read_raw_entries(f):
         out.append(__write_ldif_one(__transform_entry(entry)))
 
diff --git a/python/samba/ms_schema.py b/python/samba/ms_schema.py
index 52abe74..4946636 100644
--- a/python/samba/ms_schema.py
+++ b/python/samba/ms_schema.py
@@ -295,7 +295,8 @@ def __parse_schema_file(filename, objectClass):
 
     out = []
 
-    f = open(filename, "rU")
+    from io import open
+    f = open(filename, "r", encoding='latin-1')
     for entry in __read_raw_entries(f):
         out.append(__write_ldif_one(__transform_entry(entry, objectClass)))
 
diff --git a/python/samba/netcmd/computer.py b/python/samba/netcmd/computer.py
index 16e4bf8..ff4c397 100644
--- a/python/samba/netcmd/computer.py
+++ b/python/samba/netcmd/computer.py
@@ -376,7 +376,7 @@ sudo is used so a computer may run the command as root.
             computer_dn = res[0].dn
             computer_ac = int(res[0]["userAccountControl"][0])
             if "dNSHostName" in res[0]:
-                computer_dns_host_name = res[0]["dNSHostName"][0]
+                computer_dns_host_name = str(res[0]["dNSHostName"][0])
             else:
                 computer_dns_host_name = None
         except IndexError:
diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index f3a17ee..56386c5 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -102,6 +102,8 @@ from samba.provision.common import (
 from samba.netcmd.pso import cmd_domain_passwordsettings_pso
 from samba.netcmd.domain_backup import cmd_domain_backup
 
+from samba.compat import binary_type
+
 string_version_to_constant = {
     "2008_R2": DS_DOMAIN_FUNCTION_2008_R2,
     "2012": DS_DOMAIN_FUNCTION_2012,
@@ -570,8 +572,9 @@ class cmd_domain_provision(Command):
     def _adminpass_issue(self, adminpass):
         """Returns error string for a bad administrator password,
         or None if acceptable"""
-
-        if len(adminpass.decode('utf-8')) < DEFAULT_MIN_PWD_LENGTH:
+        if isinstance(adminpass, binary_type):
+            adminpass = adminpass.decode('utf8')
+        if len(adminpass) < DEFAULT_MIN_PWD_LENGTH:
             return "Administrator password does not meet the default minimum" \
                 " password length requirement (%d characters)" \
                 % DEFAULT_MIN_PWD_LENGTH
diff --git a/python/samba/netcmd/domain_backup.py b/python/samba/netcmd/domain_backup.py
index c2571e9..de53c6e 100644
--- a/python/samba/netcmd/domain_backup.py
+++ b/python/samba/netcmd/domain_backup.py
@@ -35,7 +35,7 @@ from samba.dcerpc.security import dom_sid
 from samba.netcmd import Option, CommandError
 from samba.dcerpc import misc, security
 from samba import Ldb
-from fsmo import cmd_fsmo_seize
+from . fsmo import cmd_fsmo_seize
 from samba.provision import make_smbconf
 from samba.upgradehelpers import update_krbtgt_account_password
 from samba.remove_dc import remove_dc
@@ -891,7 +891,7 @@ class cmd_domain_backup_offline(samba.netcmd.Command):
         # If more than one directory is a parent of this path, then at least
         # one configured path is a subdir of another. Use closest match.
         if len(matching_dirs) > 1:
-            arc_path, fs_path = max(matching_dirs, key=lambda (_, p): len(p))
+            arc_path, fs_path = max(matching_dirs, key=lambda p: len(p[1]))
         arc_path += path[len(fs_path):]
 
         return arc_path
diff --git a/python/samba/netcmd/nettime.py b/python/samba/netcmd/nettime.py
index 74e3e16..8d78279 100644
--- a/python/samba/netcmd/nettime.py
+++ b/python/samba/netcmd/nettime.py
@@ -17,7 +17,7 @@
 #
 
 import samba.getopt as options
-import common
+from . import common
 from samba.net import Net
 
 from samba.netcmd import (
diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py
index 7f4c095..00d6b67 100644
--- a/python/samba/netcmd/user.py
+++ b/python/samba/netcmd/user.py
@@ -55,6 +55,8 @@ from samba.netcmd import (
     Option,
 )
 from samba.compat import text_type
+from samba.compat import get_bytes
+from samba.compat import get_string
 
 try:
     import io
@@ -984,11 +986,11 @@ class GetPasswordCommand(Command):
             unicodePwd = obj["unicodePwd"][0]
             if add_unicodePwd:
                 del obj["unicodePwd"]
-        account_name = obj["sAMAccountName"][0]
+        account_name = str(obj["sAMAccountName"][0])
         if add_sAMAcountName:
             del obj["sAMAccountName"]
         if "userPrincipalName" in obj:
-            account_upn = obj["userPrincipalName"][0]
+            account_upn = str(obj["userPrincipalName"][0])
         else:
             realm = self.lp.get("realm")
             account_upn = "%s@%s" % (account_name, realm.lower())
@@ -1058,7 +1060,7 @@ class GetPasswordCommand(Command):
 
         def get_utf8(a, b, username):
             try:
-                u = unicode(b, 'utf-16-le')
+                u = text_type(get_bytes(b), 'utf-16-le')
             except UnicodeDecodeError as e:
                 self.outf.write("WARNING: '%s': CLEARTEXT is invalid UTF-16-LE unable to generate %s\n" % (
                                 username, a))
@@ -1168,7 +1170,7 @@ class GetPasswordCommand(Command):
                                  primary_wdigest)
             try:
                 digest = binascii.hexlify(bytearray(digests.hashes[i - 1].hash))
-                return "%s:%s:%s" % (user, realm, digest)
+                return "%s:%s:%s" % (user, realm, get_string(digest))
             except IndexError:
                 return None
 
@@ -1190,7 +1192,9 @@ class GetPasswordCommand(Command):
                 if b is not None:
                     u8 = get_utf8(a, b, username or account_name)
                     if u8 is not None:
-                        sv = get_crypt_value(str(algorithm), u8, rounds)
+                        # in py2 using get_bytes should ensure u8 is unmodified
+                        # in py3 it will be decoded
+                        sv = get_crypt_value(str(algorithm), get_string(u8), rounds)
                 if sv is None:
                     # Unable to calculate a hash with the specified
                     # number of rounds, fall back to the first hash using
@@ -1217,12 +1221,15 @@ class GetPasswordCommand(Command):
             scheme_match = None
 
             for h in up.hashes:
+                # in PY2 this should just do nothing and in PY3 if bytes
+                # it will decode them
+                h_value = get_string(h.value)
                 if (scheme_match is None and
                     h.scheme == SCHEME and
-                    h.value.startswith(scheme_prefix)):
-                    scheme_match = h.value
-                if h.scheme == SCHEME and h.value.startswith(prefix):
-                    return (h.value, scheme_match)
+                    h_value.startswith(scheme_prefix)):
+                    scheme_match = h_value
+                if h.scheme == SCHEME and h_value.startswith(prefix):
+                    return (h_value, scheme_match)
 
             # No match on the number of rounds, return the value of the
             # first matching scheme
@@ -1852,7 +1859,7 @@ samba-tool user syncpasswords --terminate \\
                                     attrs=cache_attrs)
             if len(res) == 1:
                 try:
-                    self.samdb_url = res[0]["samdbUrl"][0]
+                    self.samdb_url = str(res[0]["samdbUrl"][0])
                 except KeyError as e:
                     self.samdb_url = None
             else:
@@ -1873,13 +1880,13 @@ samba-tool user syncpasswords --terminate \\
                 self.sync_command = sync_command
                 add_ldif  = "dn: %s\n" % self.cache_dn
                 add_ldif += "objectClass: userSyncPasswords\n"
-                add_ldif += "samdbUrl:: %s\n" % base64.b64encode(self.samdb_url).decode('utf8')
-                add_ldif += "dirsyncFilter:: %s\n" % base64.b64encode(self.dirsync_filter).decode('utf8')
+                add_ldif += "samdbUrl:: %s\n" % base64.b64encode(get_bytes(self.samdb_url)).decode('utf8')
+                add_ldif += "dirsyncFilter:: %s\n" % base64.b64encode(get_bytes(self.dirsync_filter)).decode('utf8')
                 for a in self.dirsync_attrs:
-                    add_ldif += "dirsyncAttribute:: %s\n" % base64.b64encode(a).decode('utf8')
+                    add_ldif += "dirsyncAttribute:: %s\n" % base64.b64encode(get_bytes(a)).decode('utf8')
                 add_ldif += "dirsyncControl: %s\n" % self.dirsync_controls[0]
                 for a in self.password_attrs:
-                    add_ldif += "passwordAttribute:: %s\n" % base64.b64encode(a).decode('utf8')
+                    add_ldif += "passwordAttribute:: %s\n" % base64.b64encode(get_bytes(a)).decode('utf8')
                 if self.decrypt_samba_gpg:
                     add_ldif += "decryptSambaGPG: TRUE\n"
                 else:
@@ -1895,22 +1902,22 @@ samba-tool user syncpasswords --terminate \\
                 ldif = self.cache.write_ldif(msg, ldb.CHANGETYPE_NONE)
                 self.outf.write("%s" % ldif)
             else:
-                self.dirsync_filter = res[0]["dirsyncFilter"][0]
+                self.dirsync_filter = str(res[0]["dirsyncFilter"][0])
                 self.dirsync_attrs = []
                 for a in res[0]["dirsyncAttribute"]:
-                    self.dirsync_attrs.append(a)
-                self.dirsync_controls = [res[0]["dirsyncControl"][0], "extended_dn:1:0"]
+                    self.dirsync_attrs.append(str(a))
+                self.dirsync_controls = [str(res[0]["dirsyncControl"][0]), "extended_dn:1:0"]
                 self.password_attrs = []
                 for a in res[0]["passwordAttribute"]:
-                    self.password_attrs.append(a)
-                decrypt_string = res[0]["decryptSambaGPG"][0]
+                    self.password_attrs.append(str(a))
+                decrypt_string = str(res[0]["decryptSambaGPG"][0])
                 assert(decrypt_string in ["TRUE", "FALSE"])
                 if decrypt_string == "TRUE":
                     self.decrypt_samba_gpg = True
                 else:
                     self.decrypt_samba_gpg = False
                 if "syncCommand" in res[0]:
-                    self.sync_command = res[0]["syncCommand"][0]
+                    self.sync_command = str(res[0]["syncCommand"][0])
                 else:
                     self.sync_command = None
                 if "currentPid" in res[0]:
@@ -2065,7 +2072,7 @@ samba-tool user syncpasswords --terminate \\
                 try:
                     os.ftruncate(self.lockfd, 0)
                     if buf is not None:
-                        os.write(self.lockfd, buf)
+                        os.write(self.lockfd, get_bytes(buf))
                 except IOError as e3:
                     (err, msg) = e3.args
                     log_msg("check_current_pid_conflict: failed to write pid to [%s] - %s (%d)" %
@@ -2154,7 +2161,7 @@ samba-tool user syncpasswords --terminate \\
 
         def dirsync_loop():
             while True:
-                res = self.samdb.search(expression=self.dirsync_filter,
+                res = self.samdb.search(expression=str(self.dirsync_filter),
                                         scope=ldb.SCOPE_SUBTREE,
                                         attrs=self.dirsync_attrs,
                                         controls=self.dirsync_controls)
diff --git a/python/samba/netcmd/visualize.py b/python/samba/netcmd/visualize.py
index 93c0929..8292802 100644
--- a/python/samba/netcmd/visualize.py
+++ b/python/samba/netcmd/visualize.py
@@ -275,7 +275,7 @@ class cmd_reps(GraphCommand):
                 res = local_kcc.samdb.search(dsa_dn,
                                              scope=SCOPE_BASE,
                                              attrs=["dNSHostName"])
-                dns_name = res[0]["dNSHostName"][0]
+                dns_name = str(res[0]["dNSHostName"][0])
                 print("Attempting to contact ldap://%s (%s)" %
                       (dns_name, dsa_dn),
                       file=sys.stderr)
@@ -508,7 +508,7 @@ class cmd_ntdsconn(GraphCommand):
             for msg in res:
                 msgdn = str(msg.dn)
                 dest_dn = msgdn[msgdn.index(',') + 1:]
-                attested_edges.append((msg['fromServer'][0],
+                attested_edges.append((str(msg['fromServer'][0]),
                                        dest_dn, ntds_dn))
 
         if importldif and H == self._tmp_fn_to_delete:
@@ -694,7 +694,7 @@ class cmd_uptodateness(GraphCommand):
                                expression=("(&(invocationId=%s)"
                                            "(objectClass=nTDSDSA))" % inv_id),
                                attrs=["distinguishedName", "invocationId"])
-            settings_dn = res[0]["distinguishedName"][0]
+            settings_dn = str(res[0]["distinguishedName"][0])
             prefix, dsa_dn = settings_dn.split(',', 1)
             if prefix != 'CN=NTDS Settings':
                 raise CommandError("Expected NTDS Settings DN, got %s" %
diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py
index 5b0a71f..9ecb201 100644
--- a/python/samba/provision/__init__.py
+++ b/python/samba/provision/__init__.py
@@ -27,6 +27,8 @@
 __docformat__ = "restructuredText"
 
 from samba.compat import urllib_quote
+from samba.compat import string_types
+from samba.compat import binary_type
 from base64 import b64encode
 import errno
 import os
@@ -1082,7 +1084,7 @@ def setup_encrypted_secrets_key(path):
     finally:
         os.umask(umask_original)
 
-    with os.fdopen(fd, 'w') as f:
+    with os.fdopen(fd, 'wb') as f:
         key = samba.generate_random_bytes(16)
         f.write(key)
 
@@ -1573,8 +1575,8 @@ def fill_samdb(samdb, lp, names, logger, policyguid,
 
         ntds_dn = "CN=NTDS Settings,%s" % names.serverdn
         names.ntdsguid = samdb.searchone(basedn=ntds_dn,
-                                         attribute="objectGUID", expression="", scope=ldb.SCOPE_BASE)
-        assert isinstance(names.ntdsguid, str)
+                                         attribute="objectGUID", expression="", scope=ldb.SCOPE_BASE).decode('utf8')
+        assert isinstance(names.ntdsguid, string_types)
 
     return samdb
 
@@ -1618,7 +1620,7 @@ def set_gpos_acl(sysvol, dnsdomain, domainsid, domaindn, samdb, lp, use_ntvfs, p
 
     for policy in res:
         acl = ndr_unpack(security.descriptor,
-                         str(policy["nTSecurityDescriptor"])).as_sddl()
+                         policy["nTSecurityDescriptor"][0]).as_sddl()
         policy_path = getpolicypath(sysvol, dnsdomain, str(policy["cn"]))
         set_dir_acl(policy_path, dsacl2fsacl(acl, domainsid), lp,
                     str(domainsid), use_ntvfs,
@@ -1792,7 +1794,7 @@ def check_gpos_acl(sysvol, dnsdomain, domainsid, domaindn, samdb, lp,
 
     for policy in res:
         acl = ndr_unpack(security.descriptor,
-                         str(policy["nTSecurityDescriptor"])).as_sddl()
+                         policy["nTSecurityDescriptor"][0]).as_sddl()
         policy_path = getpolicypath(sysvol, dnsdomain, str(policy["cn"]))
         check_dir_acl(policy_path, dsacl2fsacl(acl, domainsid), lp,
                       domainsid, direct_db_access)
@@ -1964,8 +1966,8 @@ def provision_fill(samdb, secrets_ldb, logger, names, paths,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list