[SCM] Samba Shared Repository - branch master updated

Douglas Bagnall dbagnall at samba.org
Fri May 31 01:29:02 UTC 2024


The branch, master has been updated
       via  3a7dbf8b77b examples:winexe: embed Samba version as exe timestamp
       via  e604f757516 examples:winexe: reproducible builds with zero timestamp
       via  3c72f733f45 examples:winexe: more efficient C array generation, no py2
       via  068b366709d buildtools:pidl: avoid hash randomisation in pidl
       via  ea78a5ce830 pidl:python: Exception if unconvertable in ConvertObjectToPythonLevel
       via  f893c100c07 pidl:python: properly raise exception in ConvertObjectFromPythonData
       via  f3433f60b8e pidl:Typelist: resolveType(): don't mistake a reference for a name
       via  72112d4814e script/autobuild.py: Add test for --vendor-name and --vendor-patch-revision
       via  651fb94c374 build: Add --vendor-name --vendor-patch-revision options to ./configure
       via  8331475a183 python:smb tests: remove py2 compatibility code
       via  b4b8f18612a python/common: remove verbiage about old python versions
       via  5a317f7d8ef buildtools: remove Python2 compatibility
       via  564b0a21ceb tdb:pytests: remove unused Py2 test branches
       via  037e7ae9c59 ldb-samba:pytest: remove unused variable
       via  0fcba46957f talloc:pytest: remove tests that only test Python 2
       via  a0a025d9024 tdb:pytdb:_tdb_text: remove Py2 compatibility code
       via  87356b327b8 selftest:dnshub: remove py2 compatibility code
      from  e9eb5810438 ctdb-scripts: Protect against races when starting grace period

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


- Log -----------------------------------------------------------------
commit 3a7dbf8b77b2a9e7cdc55bc5b339b9f501d037aa
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu May 30 10:44:24 2024 +1200

    examples:winexe: embed Samba version as exe timestamp
    
    It turns out the timestamp doesn't need to be real, and it isn't used,
    but it might as well tell you something. So let's make it tell you what
    version of Samba it came from, which could be useful for people who have
    lots of old winexes lying around, the poor souls.
    
    00000040  0e 1f ba 0e 00 b4 09 cd  21 b8 01 4c cd 21 54 68  |........!..L.!Th|
    00000050  69 73 20 70 72 6f 67 72  61 6d 20 63 61 6e 6e 6f  |is program canno|
    00000060  74 20 62 65 20 72 75 6e  20 69 6e 20 44 4f 53 20  |t be run in DOS |
    00000070  6d 6f 64 65 2e 0d 0d 0a  24 00 00 00 00 00 00 00  |mode....$.......|
    00000080  50 45 00 00 64 86 0a 00  00 15 04 00 00 00 00 00  |PE..d...........|
                                        |  |  |
                                        |  |  major  4.
                                        |  minor     21.
                                        release      0
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13213
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Douglas Bagnall <dbagnall at samba.org>
    Autobuild-Date(master): Fri May 31 01:28:06 UTC 2024 on atb-devel-224

commit e604f7575167d3572e1b67c6e77ab7273508533d
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 11:34:51 2024 +1200

    examples:winexe: reproducible builds with zero timestamp
    
    Windows Portable Executable files have a timestamp field and a
    checksum field. By default the timestamp field is updated to the
    current time, which consequently changes the checksum. This makes the
    build nondeterministic. It looks like this:
    
      --- a/tmp/winexe-1/winexesvc64_exe_binary.c
      +++ b/tmp/winexe-2/winexesvc64_exe_binary.c
      @@ -23,7 +23,7 @@ const DATA_BLOB *winexesvc64_exe_binary(void)
                    0x6D, 0x6F, 0x64, 0x65, 0x2E, 0x0D, 0x0D, 0x0A,
                    0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x50, 0x45, 0x00, 0x00, 0x64, 0x86, 0x0A, 0x00,
      -             0xB2, 0x16, 0x55, 0x66, 0x00, 0x00, 0x00, 0x00,
      +             0xD3, 0x3B, 0x55, 0x66, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x2E, 0x02,
                    0x0B, 0x02, 0x02, 0x26, 0x00, 0x86, 0x00, 0x00,
                    0x00, 0xBA, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00,
      @@ -33,7 +33,7 @@ const DATA_BLOB *winexesvc64_exe_binary(void)
                    0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00,
      -             0x73, 0xD7, 0x00, 0x00, 0x03, 0x00, 0x60, 0x01,
      +             0x94, 0xFC, 0x00, 0x00, 0x03, 0x00, 0x60, 0x01,
                    0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    https://learn.microsoft.com/en-us/windows/win32/debug/pe-format says
    that a timestamp of zero can be used to represent a time that is not
    "real or meaningful", so we do that.
    
    As far as I can tell, the timestamp and checksum are only used in
    DLLs, not directly executed .exe files.
    
    Thanks to Freexian and the Debian LTS project for sponsoring this work.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13213
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 3c72f733f459088c8d506973610f3d8530592bc2
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 11:16:23 2024 +1200

    examples:winexe: more efficient C array generation, no py2
    
    We don't need to recreate the src array every time, and we don't need
    to worry about Python 2 strings.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 068b366709d005275727a0e8929d272c04cb7bd8
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 12:17:06 2024 +1200

    buildtools:pidl: avoid hash randomisation in pidl
    
    Like many languages, Perl uses has randomisation to prevent nasty
    users using crafted values that hash to the same number to effect a
    denial of service. This means the traversal order of perl HASH tables
    is different every time.
    
    The IDL handed to pidl is trusted, so we don't really need
    randomisation, but we do want to be sure the build is the same every
    time.
    
    I am not aware of hash randomisation causing problems, but it seems
    prudent to avoid it.
    
    We do a similar thing with PYTHONHASHSEED for the entire build.
    
    Thanks to Freexian and the Debian LTS project for sponsoring this work.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13213
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ea78a5ce8301ecea3c8901d96944ad06744535e4
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu May 30 10:53:24 2024 +1200

    pidl:python: Exception if unconvertable in ConvertObjectToPythonLevel
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f893c100c0743e52b578d2108222c26321805132
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 16:32:14 2024 +1200

    pidl:python: properly raise exception in ConvertObjectFromPythonData
    
    Without the `$self->pidl("$fail");`, the exception is not raised.
    
    We also try to improve the Python message.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f3433f60b8ee83fc785a6e6838513de31bff5a6a
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Wed May 29 12:14:04 2024 +1200

    pidl:Typelist: resolveType(): don't mistake a reference for a name
    
    This function is only used by Python.pm, and was assuming any argument
    unrecognised by hasType is a name. It sometimes isn't, resulting in
    structures like this:
    
    	{
    	  'DATA' => {
    		      'TYPE' => 'STRUCT'
    		    },
    	  'NAME' => {
    		      'TYPE' => 'STRUCT',
    		      'ALIGN' => undef,
    		      'SURROUNDING_ELEMENT' => undef,
    		      'ORIGINAL' => {
    				      'TYPE' => 'STRUCT',
    				      'FILE' => 'source3/librpc/idl/smbXsrv.idl',
    				      'LINE' => 101,
    				      'NAME' => 'tevent_context'
    				    },
    		      'ELEMENTS' => undef,
    		      'NAME' => 'tevent_context',
    		      'PROPERTIES' => undef
    		    },
    	  'TYPE' => 'TYPEDEF'
          };
    
    The problem with that is we end up with the HASH reference as a name
    in Python bindings, like this
    
          PyErr_SetString(PyExc_TypeError, "Can not convert C Type struct HASH(0x5e2dfe5ee278) from Python");
    
    which makes the build nondeterministic (as well as making the message
    a little mysterious).
    
    I think all the structures for which this happens are marked
    '[ignore]' in IDL, meaning they are not transmitted on the wire. They
    should perhaps also not have useless Python getsetters, but let's call
    that a different problem.
    
    Thanks to Freexian and the Debian LTS project for sponsoring this work.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13213
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 72112d4814eb3872016c1168c477531be835a1f9
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu May 30 21:13:01 2024 +1200

    script/autobuild.py: Add test for --vendor-name and --vendor-patch-revision
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15654
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 651fb94c374c7f84405d960a9e0a0fd7fcb285dd
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu May 30 10:50:12 2024 +1200

    build: Add --vendor-name --vendor-patch-revision options to ./configure
    
    These options are for packagers and vendors to set so that when
    Samba developers are debugging an issue, we know exactly which
    package is in use, and so have an idea if any patches have been
    applied.
    
    This is included in the string that a Samba backtrace gives,
    as part of the PANIC message.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15654
    REF: https://lists.samba.org/archive/samba-technical/2024-May/138992.html
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 8331475a1837e80a5b0b6e330e9c8b9fcac86060
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 19:48:04 2024 +1200

    python:smb tests: remove py2 compatibility code
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b4b8f18612a92370e3b5bd1ccb2232ed51b641e9
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 19:46:33 2024 +1200

    python/common: remove verbiage about old python versions
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 5a317f7d8ef77900586709ea2001e997ba11f7ec
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 19:45:17 2024 +1200

    buildtools: remove Python2 compatibility
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 564b0a21ceb9a8cd478575ec9dd22345708b44d6
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 19:43:53 2024 +1200

    tdb:pytests: remove unused Py2 test branches
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 037e7ae9c5902a9313ae4a04b8c1b8f1aa18f36b
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 19:42:45 2024 +1200

    ldb-samba:pytest: remove unused variable
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 0fcba46957f5974362a2f32b840eb3f96d0affc2
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 19:42:04 2024 +1200

    talloc:pytest: remove tests that only test Python 2
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit a0a025d902454aadeb522ad93a64049f318af55d
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 19:40:39 2024 +1200

    tdb:pytdb:_tdb_text: remove Py2 compatibility code
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 87356b327b89497cdf8066b8aca60bee7bee471c
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue May 28 19:39:33 2024 +1200

    selftest:dnshub: remove py2 compatibility code
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 buildtools/bin/waf                    | 13 ++---------
 buildtools/wafsamba/samba_patterns.py |  6 +----
 buildtools/wafsamba/samba_pidl.py     |  4 +++-
 buildtools/wafsamba/samba_utils.py    | 42 +++++++++--------------------------
 buildtools/wafsamba/samba_version.py  |  7 ++++--
 examples/winexe/wscript               | 21 ++++++++++++++++++
 examples/winexe/wscript_build         | 29 ++++++++----------------
 lib/ldb-samba/tests/index.py          |  1 -
 lib/talloc/test_pytalloc.py           | 36 ------------------------------
 lib/tdb/_tdb_text.py                  |  6 +----
 lib/tdb/python/tests/simple.py        | 16 ++-----------
 pidl/lib/Parse/Pidl/Samba4/Python.pm  |  7 +++++-
 pidl/lib/Parse/Pidl/Typelist.pm       | 14 ++++++++++--
 python/samba/common.py                | 15 ++-----------
 python/samba/tests/smb.py             | 18 ++++++---------
 script/autobuild.py                   |  3 ++-
 selftest/target/dns_hub.py            |  8 ++-----
 wscript                               | 20 +++++++++++++++++
 18 files changed, 105 insertions(+), 161 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/bin/waf b/buildtools/bin/waf
index 0f70fa21de2..c103979cc00 100755
--- a/buildtools/bin/waf
+++ b/buildtools/bin/waf
@@ -45,13 +45,9 @@ join = os.path.join
 if sys.hexversion<0x206000f:
 	raise ImportError('Python >= 2.6 is required to create the waf file')
 
-WAF='waf'
+WAF='waf3'
 def b(x):
-	return x
-if sys.hexversion>0x300000f:
-	WAF='waf3'
-	def b(x):
-		return x.encode()
+	return x.encode()
 
 def err(m):
 	print(('\033[91mError: %s\033[0m' % m))
@@ -107,11 +103,6 @@ def unpack_wafdir(dir, src):
 	for x in ('Tools', 'extras'):
 		os.chmod(join('waflib',x), 493)
 
-	if sys.hexversion<0x300000f:
-		sys.path = [join(dir, 'waflib')] + sys.path
-		import fixpy2
-		fixpy2.fixdir(dir)
-
 	os.remove(tmp)
 	os.chdir(cwd)
 
diff --git a/buildtools/wafsamba/samba_patterns.py b/buildtools/wafsamba/samba_patterns.py
index 41296810e13..faaade75ae4 100644
--- a/buildtools/wafsamba/samba_patterns.py
+++ b/buildtools/wafsamba/samba_patterns.py
@@ -187,11 +187,7 @@ def write_build_options(task):
     keys_header_sys = []
     keys_header_other = []
     keys_misc = []
-    if sys.hexversion>0x300000f:
-        trans_table = bytes.maketrans(b'.-()', b'____')
-    else:
-        import string
-        trans_table = string.maketrans('.-()', '____')
+    trans_table = bytes.maketrans(b'.-()', b'____')
 
     for key in tbl:
         if key.startswith("HAVE_UT_UT_") or key.find("UTMP") >= 0:
diff --git a/buildtools/wafsamba/samba_pidl.py b/buildtools/wafsamba/samba_pidl.py
index 72997c8bf84..e1010869cdd 100644
--- a/buildtools/wafsamba/samba_pidl.py
+++ b/buildtools/wafsamba/samba_pidl.py
@@ -81,7 +81,9 @@ def SAMBA_PIDL(bld, pname, source,
         else:
             cc = 'CC="%s"' % bld.CONFIG_GET("CC")
 
-    t = bld(rule='cd ${PIDL_LAUNCH_DIR} && %s%s %s ${PERL} ${PIDL} --quiet ${OPTIONS} --outputdir ${OUTPUTDIR} -- "${IDLSRC}"' % (pidl_dev, cpp, cc),
+    t = bld(rule=('cd ${PIDL_LAUNCH_DIR} && PERL_HASH_SEED=0 %s%s %s ${PERL} '
+                  '${PIDL} --quiet ${OPTIONS} --outputdir ${OUTPUTDIR} -- "${IDLSRC}"' %
+                  (pidl_dev, cpp, cc)),
             ext_out    = '.c',
             before     = 'c',
             update_outputs = True,
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index f287e85d838..e45f0ae1a35 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -15,38 +15,16 @@ from waflib.Build import CACHE_SUFFIX
 # TODO: make this a --option
 LIB_PATH="shared"
 
-
-PY3 = sys.version_info[0] == 3
-
-if PY3:
-
-    # 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
-
-else:
-
-    # 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
+# Py3 transition helper function to get a string from a variable that
+# may be 'str' or 'bytes'. If 'bytes' then it is decoded using 'utf8'.
+# If 'str' is passed it is returned unchanged.
+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
 
 # sigh, python octal constants are a mess
 MODE_644 = int('644', 8)
diff --git a/buildtools/wafsamba/samba_version.py b/buildtools/wafsamba/samba_version.py
index 31103e0f8c4..1533e01198f 100644
--- a/buildtools/wafsamba/samba_version.py
+++ b/buildtools/wafsamba/samba_version.py
@@ -200,8 +200,6 @@ also accepted as dictionary entries here
             string+="#define SAMBA_VERSION_%s " % name
             value = self.vcs_fields[name]
             string_types = str
-            if sys.version_info[0] < 3:
-                string_types = basestring
             if isinstance(value, string_types):
                 string += "\"%s\"" % value
             elif type(value) is int:
@@ -253,6 +251,11 @@ def samba_version_file(version_file, path, env=None, is_install=True):
                 print("Failed to parse line %s from %s" % (line, version_file))
                 raise
 
+    if "SAMBA_VERSION_VENDOR_SUFFIX" in env:
+        version_dict["SAMBA_VERSION_VENDOR_SUFFIX"] = env.SAMBA_VERSION_VENDOR_SUFFIX
+    if "SAMBA_VERSION_VENDOR_PATCH" in env:
+        version_dict["SAMBA_VERSION_VENDOR_PATCH"] = str(env.SAMBA_VERSION_VENDOR_PATCH)
+
     return SambaVersion(version_dict, path, env=env, is_install=is_install)
 
 
diff --git a/examples/winexe/wscript b/examples/winexe/wscript
index 6b311b1da41..c4f13b89f01 100644
--- a/examples/winexe/wscript
+++ b/examples/winexe/wscript
@@ -1,4 +1,6 @@
 #!/usr/bin/env python
+import os
+
 
 def configure(conf):
     AR32 = ['i386', 'i586', 'i686']
@@ -27,5 +29,24 @@ def configure(conf):
             conf.DEFINE('HAVE_WINEXE_CC_WIN64', 1);
             break
 
+    source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH')
+    if source_date_epoch is None:
+        # We use the version to make up the timestamp that will be
+        # embedded in winexe.exe, to keep the build reproducible.
+        #
+        # This is less evil than it sounds. According to Raymond Chen in
+        # https://devblogs.microsoft.com/oldnewthing/20180103-00/?p=97705
+        # since Windows 10 the timestamp has been randomised.
+        #
+        # The purpose of the timestamp in Windows PE files seems to be
+        # to make spotting ABI changes in DLLs quicker, for which a
+        # random number is just as good as a real time. The timestamp
+        # in .exe files is not used.
+        import samba_version
+        v = samba_version.load_version(env=conf.env)
+        version = (v.MAJOR << 16) | (v.MINOR << 8) | v.RELEASE
+        source_date_epoch = str(version)
+
+    conf.env.SOURCE_DATE_EPOCH = source_date_epoch
     conf.DEFINE("WINEXE_LDFLAGS",
                 "-s -Wall -Wl,-Bstatic -Wl,-Bdynamic -luserenv")
diff --git a/examples/winexe/wscript_build b/examples/winexe/wscript_build
index 364683405c2..faec560bc88 100644
--- a/examples/winexe/wscript_build
+++ b/examples/winexe/wscript_build
@@ -17,23 +17,12 @@ def generate_winexesvc_c_from_exe(t):
         return -1
 
     def c_array(src):
-        N = 0
-        result = ''
-        while src:
-            l = src[:8]
-            src = src[8:]
-            # Even files opened in binary mode are read as type "str" in
-            # Python 2, so we need to get the integer ordinal of each
-            # character in the string before we try to convert it to hex.
-            if isinstance(l, str):
-                h = ' '.join(["0x%02X," % ord(x) for x in l])
-            # Files opened in binary mode are read as type "bytes" in
-            # Python 3, so we can convert each individual integer in the
-            # array of bytes to hex directly.
-            else:
-                h = ' '.join(["0x%02X," % x for x in l])
-            result += "\t\t%s\n" % (h)
-        return result
+        result = []
+        for i in range(0, len(src), 8):
+            l = src[i:i+8]
+            h = ' '.join(["0x%02X," % x for x in l])
+            result.append(h)
+        return "\n\t\t".join(result)
 
     src_array = c_array(src_blob)
     if len(src_array) <= 0:
@@ -48,7 +37,7 @@ const DATA_BLOB *%s(void);
 const DATA_BLOB *%s(void)
 {
 \tstatic const uint8_t array[] = {
-%s
+\t\t%s
 \t};
 \tstatic const DATA_BLOB blob = {
 \t\t.data = discard_const_p(uint8_t, array),
@@ -69,7 +58,7 @@ bld.SAMBA_GENERATOR(
     'winexesvc32_exe',
     source='winexesvc.c',
     target='winexesvc32.exe',
-    rule='${WINEXE_CC_WIN32} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}',
+    rule='SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} ${WINEXE_CC_WIN32} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}',
     enabled=bld.env.build_winexe and bld.env.WINEXE_CC_WIN32)
 
 vars = {"WINEXE_FN": "winexesvc32_exe_binary"}
@@ -89,7 +78,7 @@ bld.SAMBA_GENERATOR(
     'winexesvc64_exe',
     source='winexesvc.c',
     target='winexesvc64.exe',
-    rule='${WINEXE_CC_WIN64} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}',
+    rule='SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} ${WINEXE_CC_WIN64} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}',
     enabled=bld.env.build_winexe and bld.env.WINEXE_CC_WIN64)
 
 vars = {"WINEXE_FN": "winexesvc64_exe_binary"}
diff --git a/lib/ldb-samba/tests/index.py b/lib/ldb-samba/tests/index.py
index 2256e3eceaa..b637378da1c 100644
--- a/lib/ldb-samba/tests/index.py
+++ b/lib/ldb-samba/tests/index.py
@@ -28,7 +28,6 @@ import shutil
 from ldb import SCOPE_SUBTREE
 from samba.tests.subunitrun import TestProgram
 
-PY3 = sys.version_info > (3, 0)
 
 TDB_PREFIX = "tdb://"
 MDB_PREFIX = "mdb://"
diff --git a/lib/talloc/test_pytalloc.py b/lib/talloc/test_pytalloc.py
index 809510fea8d..655b83f3d31 100644
--- a/lib/talloc/test_pytalloc.py
+++ b/lib/talloc/test_pytalloc.py
@@ -91,24 +91,6 @@ class TallocComparisonTests(unittest.TestCase):
         self.assertFalse(obj1 >= obj2)
         self.assertFalse(obj1 > obj2)
 
-    def test_compare_different_types(self):
-        # object comparison falls back to comparing types
-        if sys.version_info >= (3, 0):
-            # In Python 3, types are unorderable -- nothing to test
-            return
-        if talloc.Object < _test_pytalloc.DObject:
-            obj1 = _test_pytalloc.new()
-            obj2 = _test_pytalloc.DObject(dummy_func)
-        else:
-            obj2 = _test_pytalloc.new()
-            obj1 = _test_pytalloc.DObject(dummy_func)
-        self.assertFalse(obj1 == obj2)
-        self.assertTrue(obj1 != obj2)
-        self.assertTrue(obj1 <= obj2)
-        self.assertTrue(obj1 < obj2)
-        self.assertFalse(obj1 >= obj2)
-        self.assertFalse(obj1 > obj2)
-
 
 class TallocBaseComparisonTests(unittest.TestCase):
 
@@ -133,24 +115,6 @@ class TallocBaseComparisonTests(unittest.TestCase):
         self.assertFalse(obj1 >= obj2)
         self.assertFalse(obj1 > obj2)
 
-    def test_compare_different_types(self):
-        # object comparison falls back to comparing types
-        if sys.version_info >= (3, 0):
-            # In Python 3, types are unorderable -- nothing to test
-            return
-        if talloc.BaseObject < _test_pytalloc.DBaseObject:
-            obj1 = _test_pytalloc.base_new()
-            obj2 = _test_pytalloc.DBaseObject(dummy_func)
-        else:
-            obj2 = _test_pytalloc.base_new()
-            obj1 = _test_pytalloc.DBaseObject(dummy_func)
-        self.assertFalse(obj1 == obj2)
-        self.assertTrue(obj1 != obj2)
-        self.assertTrue(obj1 <= obj2)
-        self.assertTrue(obj1 < obj2)
-        self.assertFalse(obj1 >= obj2)
-        self.assertFalse(obj1 > obj2)
-
 
 class TallocUtilTests(unittest.TestCase):
 
diff --git a/lib/tdb/_tdb_text.py b/lib/tdb/_tdb_text.py
index f3caa5318ec..f19869766d0 100644
--- a/lib/tdb/_tdb_text.py
+++ b/lib/tdb/_tdb_text.py
@@ -74,11 +74,7 @@ class TdbTextWrapper(object):
         key = key.encode('utf-8')
         del self._tdb[key]
 
-    if sys.version_info > (3, 0):
-        keys = __iter__
-    else:
-        iterkeys = __iter__
-        has_key = __contains__
+    keys = __iter__
 
 
 ## Add wrappers for functions and getters that don't deal with text
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index f7ab0243644..ad5bfcdc9fd 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -131,9 +131,6 @@ class SimpleTdbTests(TestCase):
         self.tdb[b"bla"] = b"bloe"
         self.assertTrue(b"bla" in self.tdb)
         self.assertFalse(b"qwertyuiop" in self.tdb)
-        if sys.version_info < (3, 0):
-            self.assertTrue(self.tdb.has_key(b"bla"))
-            self.assertFalse(self.tdb.has_key(b"qwertyuiop"))
 
     def test_keyerror(self):
         self.assertRaises(KeyError, lambda: self.tdb[b"bla"])
@@ -170,10 +167,7 @@ class SimpleTdbTests(TestCase):
     def test_iterkeys(self):
         self.tdb[b"bloe"] = b"2"
         self.tdb[b"bla"] = b"25"
-        if sys.version_info >= (3, 0):
-            i = self.tdb.keys()
-        else:
-            i = self.tdb.iterkeys()
+        i = self.tdb.keys()
         self.assertEqual(set([b"bloe", b"bla"]), set([next(i), next(i)]))
 
     def test_clear(self):
@@ -231,9 +225,6 @@ class TdbTextTests(TestCase):
         self.tdb.text["bla"] = "bloe"
         self.assertTrue("bla" in self.tdb.text)
         self.assertFalse("qwertyuiop" in self.tdb.text)
-        if sys.version_info < (3, 0):
-            self.assertTrue(self.tdb.text.has_key("bla"))
-            self.assertFalse(self.tdb.text.has_key("qwertyuiop"))
 
     def test_keyerror(self):
         self.assertRaises(KeyError, lambda: self.tdb.text["bla"])
@@ -270,10 +261,7 @@ class TdbTextTests(TestCase):
     def test_iterkeys(self):
         self.tdb.text["bloe"] = "2"
         self.tdb.text["bla"] = "25"
-        if sys.version_info >= (3, 0):
-            i = self.tdb.text.keys()
-        else:
-            i = self.tdb.text.iterkeys()
+        i = self.tdb.text.keys()
         self.assertEqual(set(["bloe", "bla"]), set([next(i), next(i)]))
 
     def test_clear(self):
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 65cad3ee221..d7ccf8309e8 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -1829,7 +1829,8 @@ sub ConvertObjectFromPythonData($$$$$$;$$)
 		my $ctype_name = $self->use_type_variable($ctype);
 		unless (defined ($ctype_name)) {
 			error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'");
-			$self->pidl("PyErr_SetString(PyExc_TypeError, \"Can not convert C Type " . mapTypeName($ctype) . " from Python\");");
+			$self->pidl("PyErr_SetString(PyExc_TypeError, \"Cannot convert Python object to NDR $target\");");
+			$self->pidl("$fail");
 			return;
 		}
 		$self->pidl("PY_CHECK_TYPE($ctype_name, $cvar, $fail);");
@@ -2294,6 +2295,10 @@ sub ConvertObjectToPythonLevel($$$$$$$)
 		}
 		my $conv = $self->ConvertObjectToPythonData($mem_ctx, $l->{DATA_TYPE}, $var_name, $e->{ORIGINAL});
 		$self->pidl("$py_var = $conv;");
+		if ($conv eq "NULL") {
+			$self->pidl("PyErr_SetString(PyExc_NotImplementedError, \"Cannot convert NDR $var_name to Python\");");
+			$self->pidl("$fail");
+		}
 	} elsif ($l->{TYPE} eq "SUBCONTEXT") {
 		$self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, $nl, $var_name, $py_var, $fail, $recurse);
 	} else {
diff --git a/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm
index 31ea19e357c..2a98a16b2b5 100644
--- a/pidl/lib/Parse/Pidl/Typelist.pm
+++ b/pidl/lib/Parse/Pidl/Typelist.pm
@@ -138,8 +138,18 @@ sub resolveType($)
 	my ($ctype) = @_;
 
 	if (not hasType($ctype)) {
-		# assume struct typedef
-		return { TYPE => "TYPEDEF", NAME => $ctype, DATA => { TYPE => "STRUCT" } };
+		if (! ref $ctype) {
+			# it looks like a name.
+			# assume struct typedef
+			return { TYPE => "TYPEDEF", NAME => $ctype, DATA => { TYPE => "STRUCT" } };
+		}
+		if ($ctype->{NAME} && ($ctype->{TYPE} eq "STRUCT")) {
+			return {
+				TYPE => "TYPEDEF",
+				NAME => $ctype->{NAME},
+				DATA => $ctype
+			};
+		}
 	} else {
 		return getType($ctype);
 	}
diff --git a/python/samba/common.py b/python/samba/common.py
index c46f6cb1a70..eafc4175b4c 100644
--- a/python/samba/common.py
+++ b/python/samba/common.py
@@ -70,20 +70,12 @@ def normalise_int32(ivalue):
     return str(ivalue)
 
 
-# Sometimes in PY3 we have variables whose content can be 'bytes' or
+# Sometimes 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.
+# api(s) or functions depending on complex conditions or logic.
 # 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):
@@ -95,9 +87,6 @@ def get_bytes(bytesorstring):
 # 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):
diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py
index 89b0acac618..b1c415b041e 100644
--- a/python/samba/tests/smb.py
+++ b/python/samba/tests/smb.py
@@ -25,7 +25,6 @@ from samba.ntstatus import (NT_STATUS_OBJECT_NAME_NOT_FOUND,
 from samba.samba3 import libsmb_samba_internal as libsmb
 from samba.samba3 import param as s3param
 
-PY3 = sys.version_info[0] == 3
 realm = os.environ.get('REALM')
 domain_dir = realm.lower() + '/'
 test_contents = 'abcd' * 256
@@ -204,8 +203,7 @@ class SMBTests(samba.tests.TestCase):
         self.assertEqual(contents.decode('utf8'), new_contents,
                           msg='contents of test file did not match what was written')
 
-    # with python2 this will save/load str type (with embedded nulls)
-    # with python3 this will save/load bytes type
+    # this will save/load bytes type
     def test_save_load_string_bytes(self):
         self.smb_conn.savefile(test_file, test_literal_bytes_embed_nulls)
 
@@ -213,17 +211,15 @@ class SMBTests(samba.tests.TestCase):
         self.assertEqual(contents, test_literal_bytes_embed_nulls,
                           msg='contents of test file did not match what was written')
 
-    # python3 only this will save/load unicode
+    # this will save/load unicode
     def test_save_load_utfcontents(self):
-        if PY3:
-            self.smb_conn.savefile(test_file, utf_contents.encode('utf8'))
+        self.smb_conn.savefile(test_file, utf_contents.encode('utf8'))
 
-            contents = self.smb_conn.loadfile(test_file)
-            self.assertEqual(contents.decode('utf8'), utf_contents,
-                              msg='contents of test file did not match what was written')
+        contents = self.smb_conn.loadfile(test_file)
+        self.assertEqual(contents.decode('utf8'), utf_contents,
+                          msg='contents of test file did not match what was written')
 
-    # with python2 this will save/load str type
-    # with python3 this will save/load bytes type
+    # this will save/load bytes type


-- 
Samba Shared Repository



More information about the samba-cvs mailing list