[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Wed Jun 12 09:17:02 UTC 2024
The branch, master has been updated
via 43802f1bedd python: remove string_to_byte_array()
via 982dab89326 samba-tool ldapcmp: remove a dodgy unused method
via 6347b0c3736 pytest: simplify and fix HEXDUMP_FILTER used in hexdumps
via 300bb809ab7 samba-tool domain trust: avoid useless use of string_to_byte_array
via f8fb9f19bca python:lsa_utils: avoid useless use of py2-compat string_to_byte_array
via 3b349c29b59 python:join: avoid useless use of py2-compat string_to_byte_array
via 46933bc25de py:emulate: remove py2 str/bytes workaround in traffic_packets
via 25e6d7c6a33 py:emulate: remove py2 str/bytes workaround in traffic
via f0cf1879681 pytest: remove py2 str/bytes workaround in auth_log_samlogon
via bd3792005ba pytest: remove py2 str/bytes workaround in samr_change_password
via 2dc111b4c18 pytest: remove py2 str/bytes workaround in lsa_utils
via b253b4e0eda pytest: remove py2 str/bytes workaround in dns_base
via 5d2ea6908b1 pytest: remove py2 str/bytes workaround in py_credentials
via de19f4d6753 s4/pytest: remove py2 str/bytes workaround in getnc_exop
from 788ef8f07c7 s3/smbd: fix nested chdir into msdfs links on (widelinks = yes) share
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 43802f1beddc875d1f4fc15babdbadf7615705c9
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 12:16:46 2024 +1200
python: remove string_to_byte_array()
This was a useful function during the Python 2 -> 3 migration, but it
is not used any more. In all the cases it was used, we knew we already
had a bytes object, and this was just an inefficient way of confirming
that.
In cases where we actually want to cast a string into a mutable list
of byte-sized ints, the builtin bytearray() function will do a better
job than this, because it will encode high unicode characters as utf-8
bytes, rather than adding them as out-of-range values in the list.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
Autobuild-Date(master): Wed Jun 12 09:16:39 UTC 2024 on atb-devel-224
commit 982dab893263b60609bf47a7138c91aefb41a038
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:42:27 2024 +1200
samba-tool ldapcmp: remove a dodgy unused method
We have bindings for stringifying GUIDs, so I intended to replace this
rather complicated code with that, but it turns out that this method
has been unused since 5d42260eecfd4f26cc82637ce1bc989083c9eb9d in 2013.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 6347b0c3736e1208d09f94e2b67f1b4234205374
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:34:36 2024 +1200
pytest: simplify and fix HEXDUMP_FILTER used in hexdumps
The old test
x if ((len(repr(chr(x))) == 3) and (x < 127)) else ord('.')
went through some contortions to see if the character was printable, and
it got it slightly wrong. The idea was that `repr(chr(97)` is "'a'",
while `repr(chr(167)` is "'\xa7'", which we can distinguish using the
length. But that miscategorised the backslash character, which is
represented as "'\\'", a string of length 4, so it was show as '.'
instead.
Instead we notice that the characters we want to print in a hexdump
are exactly those between 32 and 126, inclusive.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 300bb809ab7c06eb6abef91a313dbdb8edad7c83
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:21:59 2024 +1200
samba-tool domain trust: avoid useless use of string_to_byte_array
`pw.encode('utf-16-le')` is always bytes.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit f8fb9f19bca909fe4d29378f255bad33ccb1d778
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:21:09 2024 +1200
python:lsa_utils: avoid useless use of py2-compat string_to_byte_array
`pw.encode('utf-16-le')` is always bytes.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 3b349c29b59ebe7e1e389dc0d51b2063c657b210
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:19:55 2024 +1200
python:join: avoid useless use of py2-compat string_to_byte_array
This was a workaround for the migration to Python 3, but is now just
extra work for the computer and cognitive load for us.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 46933bc25de6515866c6b9d1ae76fad6701fb252
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:17:22 2024 +1200
py:emulate: remove py2 str/bytes workaround in traffic_packets
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 25e6d7c6a339f389cd13628e30b09a892e1a4144
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:16:48 2024 +1200
py:emulate: remove py2 str/bytes workaround in traffic
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit f0cf1879681c6275e2633cc370b57c91dbc5fa53
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:15:50 2024 +1200
pytest: remove py2 str/bytes workaround in auth_log_samlogon
It is likely not necessary to cast to list() in most cases.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit bd3792005ba907cf43310c1b0cd75fb7a8818630
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:15:23 2024 +1200
pytest: remove py2 str/bytes workaround in samr_change_password
It is likely not necessary to cast to list().
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 2dc111b4c186d102b6b4ebdc50778ccb1cf58e36
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:14:42 2024 +1200
pytest: remove py2 str/bytes workaround in lsa_utils
It is likely not necessary to cast to list() in most cases.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit b253b4e0edac16aeb4d04b82b5332e36b6ff4149
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:14:07 2024 +1200
pytest: remove py2 str/bytes workaround in dns_base
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 5d2ea6908b1ea4d02bbe4b9b8e6325785a84e9ae
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:13:24 2024 +1200
pytest: remove py2 str/bytes workaround in py_credentials
It is likely not necessary to cast to list() in most cases.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit de19f4d6753aa891a7d55d041f89341b109b9937
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Jun 12 11:11:27 2024 +1200
s4/pytest: remove py2 str/bytes workaround in getnc_exop
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
python/samba/__init__.py | 4 ----
python/samba/emulate/traffic.py | 3 +--
python/samba/emulate/traffic_packets.py | 8 +++----
python/samba/join.py | 6 +++---
python/samba/lsa_utils.py | 11 +++++-----
python/samba/netcmd/domain/trust.py | 8 +++----
python/samba/netcmd/ldapcmp.py | 26 -----------------------
python/samba/tests/__init__.py | 3 ++-
python/samba/tests/auth_log_samlogon.py | 8 ++-----
python/samba/tests/core.py | 10 +--------
python/samba/tests/dcerpc/lsa_utils.py | 8 ++-----
python/samba/tests/dcerpc/samr_change_password.py | 2 +-
python/samba/tests/dns_base.py | 4 ++--
python/samba/tests/py_credentials.py | 10 ++++-----
source4/torture/drs/python/getnc_exop.py | 4 ++--
15 files changed, 34 insertions(+), 81 deletions(-)
Changeset truncated at 500 lines:
diff --git a/python/samba/__init__.py b/python/samba/__init__.py
index 5b1a3f91ba8..d0e797e94c3 100644
--- a/python/samba/__init__.py
+++ b/python/samba/__init__.py
@@ -348,10 +348,6 @@ def current_unix_time():
return int(time.time())
-def string_to_byte_array(string):
- return [c if isinstance(c, int) else ord(c) for c in string]
-
-
def arcfour_encrypt(key, data):
from samba.crypto import arcfour_crypt_blob
return arcfour_crypt_blob(data, key)
diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py
index 4811fe8bd08..bb32a778bb5 100644
--- a/python/samba/emulate/traffic.py
+++ b/python/samba/emulate/traffic.py
@@ -807,8 +807,7 @@ class ReplayContext(object):
def get_authenticator(self):
auth = self.machine_creds.new_client_authenticator()
current = netr_Authenticator()
- current.cred.data = [x if isinstance(x, int) else ord(x)
- for x in auth["credential"]]
+ current.cred.data = list(auth["credential"])
current.timestamp = auth["timestamp"]
subsequent = netr_Authenticator()
diff --git a/python/samba/emulate/traffic_packets.py b/python/samba/emulate/traffic_packets.py
index 95c7465d2fc..2fca6234a6a 100644
--- a/python/samba/emulate/traffic_packets.py
+++ b/python/samba/emulate/traffic_packets.py
@@ -569,10 +569,10 @@ def packet_rpc_netlogon_30(packet, conversation, context):
# subsequent runs
newpass = context.machine_creds.get_password().encode('utf-16-le')
pwd_len = len(newpass)
- filler = [x if isinstance(x, int) else ord(x) for x in os.urandom(DATA_LEN - pwd_len)]
+ filler = list(os.urandom(DATA_LEN - pwd_len))
pwd = netlogon.netr_CryptPassword()
pwd.length = pwd_len
- pwd.data = filler + [x if isinstance(x, int) else ord(x) for x in newpass]
+ pwd.data = filler + list(newpass)
context.machine_creds.encrypt_netr_crypt_password(pwd)
c.netr_ServerPasswordSet2(context.server,
# must ends with $, so use get_username instead
@@ -650,10 +650,10 @@ def samlogon_logon_info(domain_name, computer_name, creds):
logon = netlogon.netr_NetworkInfo()
- logon.challenge = [x if isinstance(x, int) else ord(x) for x in challenge]
+ logon.challenge = list(challenge)
logon.nt = netlogon.netr_ChallengeResponse()
logon.nt.length = len(response["nt_response"])
- logon.nt.data = [x if isinstance(x, int) else ord(x) for x in response["nt_response"]]
+ logon.nt.data = list(response["nt_response"])
logon.identity_info = netlogon.netr_IdentityInfo()
diff --git a/python/samba/join.py b/python/samba/join.py
index 724dd6e258e..7b09445a52a 100644
--- a/python/samba/join.py
+++ b/python/samba/join.py
@@ -20,7 +20,7 @@
from samba.auth import system_session
from samba.samdb import SamDB
-from samba import gensec, Ldb, drs_utils, arcfour_encrypt, string_to_byte_array
+from samba import gensec, Ldb, drs_utils, arcfour_encrypt
import ldb
import samba
import uuid
@@ -1407,7 +1407,7 @@ class DCJoinContext(object):
except RuntimeError:
pass
- password_blob = string_to_byte_array(ctx.trustdom_pass.encode('utf-16-le'))
+ password_blob = list(ctx.trustdom_pass.encode('utf-16-le'))
clear_value = drsblobs.AuthInfoClear()
clear_value.size = len(password_blob)
@@ -1443,7 +1443,7 @@ class DCJoinContext(object):
auth_blob = lsa.DATA_BUF2()
auth_blob.size = len(encrypted_trustpass)
- auth_blob.data = string_to_byte_array(encrypted_trustpass)
+ auth_blob.data = list(encrypted_trustpass)
auth_info = lsa.TrustDomainInfoAuthInfoInternal()
auth_info.auth_blob = auth_blob
diff --git a/python/samba/lsa_utils.py b/python/samba/lsa_utils.py
index a56675d6b63..043e65f3341 100644
--- a/python/samba/lsa_utils.py
+++ b/python/samba/lsa_utils.py
@@ -22,7 +22,6 @@ from samba import (
NTSTATUSError,
aead_aes_256_cbc_hmac_sha512,
arcfour_encrypt,
- string_to_byte_array
)
from samba.ntstatus import (
NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE
@@ -81,7 +80,7 @@ def CreateTrustedDomainRelax(
):
def generate_AuthInfoInternal(session_key, incoming=None, outgoing=None):
- confounder = string_to_byte_array(token_bytes(512))
+ confounder = list(token_bytes(512))
trustpass = drsblobs.trustDomainPasswords()
@@ -95,7 +94,7 @@ def CreateTrustedDomainRelax(
auth_blob = lsa.DATA_BUF2()
auth_blob.size = len(encrypted_trustpass)
- auth_blob.data = string_to_byte_array(encrypted_trustpass)
+ auth_blob.data = list(encrypted_trustpass)
auth_info = lsa.TrustDomainInfoAuthInfoInternal()
auth_info.auth_blob = auth_blob
@@ -169,12 +168,12 @@ def CreateTrustedDomainFallback(
auth_blob = lsa.DATA_BUF2()
auth_blob.size = len(ciphertext)
- auth_blob.data = string_to_byte_array(ciphertext)
+ auth_blob.data = list(ciphertext)
auth_info = lsa.TrustDomainInfoAuthInfoInternalAES()
auth_info.cipher = auth_blob
- auth_info.salt = string_to_byte_array(iv)
- auth_info.auth_data = string_to_byte_array(auth_data)
+ auth_info.salt = list(iv)
+ auth_info.auth_data = list(auth_data)
return conn.CreateTrustedDomainEx3(
policy_handle,
diff --git a/python/samba/netcmd/domain/trust.py b/python/samba/netcmd/domain/trust.py
index 20c4ffb9787..0784fa5e282 100644
--- a/python/samba/netcmd/domain/trust.py
+++ b/python/samba/netcmd/domain/trust.py
@@ -28,7 +28,7 @@ from getpass import getpass
import ldb
import samba.getopt as options
import samba.ntacls
-from samba import NTSTATUSError, ntstatus, string_to_byte_array, werror
+from samba import NTSTATUSError, ntstatus, werror
from samba.auth import system_session
from samba.dcerpc import drsblobs, lsa, nbt, netlogon, security
from samba.net import Net
@@ -855,10 +855,10 @@ class cmd_domain_trust_create(DomainTrustCommand):
if create_location == "local":
if local_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_INBOUND:
incoming_password = get_password("Incoming Trust")
- incoming_secret = string_to_byte_array(incoming_password.encode('utf-16-le'))
+ incoming_secret = list(incoming_password.encode('utf-16-le'))
if local_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_OUTBOUND:
outgoing_password = get_password("Outgoing Trust")
- outgoing_secret = string_to_byte_array(outgoing_password.encode('utf-16-le'))
+ outgoing_secret = list(outgoing_password.encode('utf-16-le'))
remote_trust_info = None
else:
@@ -874,7 +874,7 @@ class cmd_domain_trust_create(DomainTrustCommand):
#
def random_trust_secret(length):
pw = samba.generate_random_machine_password(length // 2, length // 2)
- return string_to_byte_array(pw.encode('utf-16-le'))
+ return list(pw.encode('utf-16-le'))
if local_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_INBOUND:
incoming_secret = random_trust_secret(240)
diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py
index ff7d8be780e..b074c642128 100644
--- a/python/samba/netcmd/ldapcmp.py
+++ b/python/samba/netcmd/ldapcmp.py
@@ -227,32 +227,6 @@ class LDAPBase(object):
desc = ndr_unpack(security.descriptor, desc)
return desc.as_sddl(self.domain_sid)
- def guid_as_string(self, guid_blob):
- """ Translate binary representation of schemaIDGUID to standard string representation.
- @gid_blob: binary schemaIDGUID
- """
- blob = "%s" % guid_blob
- stops = [4, 2, 2, 2, 6]
- index = 0
- res = ""
- x = 0
- while x < len(stops):
- tmp = ""
- y = 0
- while y < stops[x]:
- c = hex(ord(blob[index])).replace("0x", "")
- c = [None, "0" + c, c][len(c)]
- if 2 * index < len(blob):
- tmp = c + tmp
- else:
- tmp += c
- index += 1
- y += 1
- res += tmp + " "
- x += 1
- assert index == len(blob)
- return res.strip().replace(" ", "-")
-
def get_sid_map(self):
""" Build dictionary that maps GUID to 'name' attribute found in Schema or Extended-Rights.
"""
diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py
index 136dd2fc316..ef57309ab70 100644
--- a/python/samba/tests/__init__.py
+++ b/python/samba/tests/__init__.py
@@ -57,7 +57,8 @@ from unittest import SkipTest
BINDIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
"../../../../bin"))
-HEXDUMP_FILTER = bytearray([x if ((len(repr(chr(x))) == 3) and (x < 127)) else ord('.') for x in range(256)])
+# HEXDUMP_FILTER maps ASCII control characters to '.', printables to themselves
+HEXDUMP_FILTER = bytearray(x if (x > 31 and x < 127) else 46 for x in range(256))
LDB_ERR_LUT = {v: k for k, v in vars(ldb).items() if k.startswith('ERR_')}
diff --git a/python/samba/tests/auth_log_samlogon.py b/python/samba/tests/auth_log_samlogon.py
index f3dfebab0cc..8ccf9b12e95 100644
--- a/python/samba/tests/auth_log_samlogon.py
+++ b/python/samba/tests/auth_log_samlogon.py
@@ -126,14 +126,10 @@ class AuthLogTestsSamLogon(samba.tests.auth_log_base.AuthLogTestBase):
logon_level = netlogon.NetlogonNetworkTransitiveInformation
logon = samba.dcerpc.netlogon.netr_NetworkInfo()
- logon.challenge = [
- x if isinstance(x, int) else ord(x) for x in challenge]
+ logon.challenge = list(challenge)
logon.nt = netlogon.netr_ChallengeResponse()
logon.nt.length = len(response["nt_response"])
- logon.nt.data = [
- x if isinstance(x, int) else ord(x) for
- x in response["nt_response"]
- ]
+ logon.nt.data = list(response["nt_response"])
logon.identity_info = samba.dcerpc.netlogon.netr_IdentityInfo()
(username, domain) = creds.get_ntlm_username_domain()
diff --git a/python/samba/tests/core.py b/python/samba/tests/core.py
index 9f53473d4f6..eaed4f9bf84 100644
--- a/python/samba/tests/core.py
+++ b/python/samba/tests/core.py
@@ -20,7 +20,7 @@
import ldb
import os
import samba
-from samba import arcfour_encrypt, string_to_byte_array
+from samba import arcfour_encrypt
from samba.tests import TestCase, TestCaseInTempDir
@@ -61,14 +61,6 @@ class ArcfourTestCase(TestCase):
self.assertEqual(crypt_expected, crypt_calculated)
-class StringToByteArrayTestCase(TestCase):
-
- def test_byte_array(self):
- expected = [218, 145, 90, 176, 108, 215, 185, 207, 153]
- calculated = string_to_byte_array('\xda\x91Z\xb0l\xd7\xb9\xcf\x99')
- self.assertEqual(expected, calculated)
-
-
class LdbExtensionTests(TestCaseInTempDir):
def test_searchone(self):
diff --git a/python/samba/tests/dcerpc/lsa_utils.py b/python/samba/tests/dcerpc/lsa_utils.py
index d6da5eb60bd..229f57ec546 100644
--- a/python/samba/tests/dcerpc/lsa_utils.py
+++ b/python/samba/tests/dcerpc/lsa_utils.py
@@ -107,9 +107,7 @@ class CreateTrustedDomain(TestCase):
info.trust_type = lsa.LSA_TRUST_TYPE_UPLEVEL
info.trust_attributes = lsa.LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE
- password_blob = samba.string_to_byte_array(
- "password".encode('utf-16-le')
- )
+ password_blob = list("password".encode('utf-16-le'))
clear_value = drsblobs.AuthInfoClear()
clear_value.size = len(password_blob)
@@ -198,9 +196,7 @@ class CreateTrustedDomain(TestCase):
info.trust_type = lsa.LSA_TRUST_TYPE_UPLEVEL
info.trust_attributes = lsa.LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE
- password_blob = samba.string_to_byte_array(
- "password".encode('utf-16-le')
- )
+ password_blob = list("password".encode('utf-16-le'))
clear_value = drsblobs.AuthInfoClear()
clear_value.size = len(password_blob)
diff --git a/python/samba/tests/dcerpc/samr_change_password.py b/python/samba/tests/dcerpc/samr_change_password.py
index f872bba128c..4270522c582 100644
--- a/python/samba/tests/dcerpc/samr_change_password.py
+++ b/python/samba/tests/dcerpc/samr_change_password.py
@@ -114,7 +114,7 @@ class SamrPasswordTests(RpcInterfaceTestCase):
def encode_pw_buffer(password):
data = bytearray([0] * 516)
- p = samba.string_to_byte_array(password.encode('utf-16-le'))
+ p = list(password.encode('utf-16-le'))
plen = len(p)
b = generate_random_bytes(512 - plen)
diff --git a/python/samba/tests/dns_base.py b/python/samba/tests/dns_base.py
index 43a62b1ac57..5fd33ff54dc 100644
--- a/python/samba/tests/dns_base.py
+++ b/python/samba/tests/dns_base.py
@@ -335,7 +335,7 @@ class DNSTKeyTest(DNSTest):
(finished, server_to_client) = tkey['gensec'].update(client_to_server)
self.assertFalse(finished)
- data = [x if isinstance(x, int) else ord(x) for x in list(server_to_client)]
+ data = list(server_to_client)
rdata.key_data = data
rdata.key_size = len(data)
r.rdata = rdata
@@ -428,7 +428,7 @@ class DNSTKeyTest(DNSTest):
data = packet_data + fake_tsig_packet
mac = self.tkey['gensec'].sign_packet(data, data)
- mac_list = [x if isinstance(x, int) else ord(x) for x in list(mac)]
+ mac_list = list(mac)
if bad_sig:
if len(mac) > 8:
mac_list[-8] = mac_list[-8] ^ 0xff
diff --git a/python/samba/tests/py_credentials.py b/python/samba/tests/py_credentials.py
index 767fba28e95..7d473b19a39 100644
--- a/python/samba/tests/py_credentials.py
+++ b/python/samba/tests/py_credentials.py
@@ -511,10 +511,10 @@ class PyCredentialsTests(TestCase):
newpass = samba.generate_random_password(PWD_LEN, PWD_LEN)
encoded = newpass.encode('utf-16-le')
pwd_len = len(encoded)
- filler = [x if isinstance(x, int) else ord(x) for x in os.urandom(DATA_LEN - pwd_len)]
+ filler = list(os.urandom(DATA_LEN - pwd_len))
pwd = netlogon.netr_CryptPassword()
pwd.length = pwd_len
- pwd.data = filler + [x if isinstance(x, int) else ord(x) for x in encoded]
+ pwd.data = filler + list(encoded)
self.machine_creds.encrypt_netr_crypt_password(pwd)
c.netr_ServerPasswordSet2(self.server,
f'{self.machine_name}$',
@@ -591,7 +591,7 @@ class PyCredentialsTests(TestCase):
def get_authenticator(self):
auth = self.machine_creds.new_client_authenticator()
current = netr_Authenticator()
- current.cred.data = [x if isinstance(x, int) else ord(x) for x in auth["credential"]]
+ current.cred.data = list(auth["credential"])
current.timestamp = auth["timestamp"]
subsequent = netr_Authenticator()
@@ -641,10 +641,10 @@ def samlogon_logon_info(domain_name, computer_name, creds,
logon = netlogon.netr_NetworkInfo()
- logon.challenge = [x if isinstance(x, int) else ord(x) for x in challenge]
+ logon.challenge = list(challenge)
logon.nt = netlogon.netr_ChallengeResponse()
logon.nt.length = len(response["nt_response"])
- logon.nt.data = [x if isinstance(x, int) else ord(x) for x in response["nt_response"]]
+ logon.nt.data = list(response["nt_response"])
logon.identity_info = netlogon.netr_IdentityInfo()
(username, domain) = creds.get_ntlm_username_domain()
diff --git a/source4/torture/drs/python/getnc_exop.py b/source4/torture/drs/python/getnc_exop.py
index 0f12d9b27d7..03b93657458 100644
--- a/source4/torture/drs/python/getnc_exop.py
+++ b/source4/torture/drs/python/getnc_exop.py
@@ -1093,7 +1093,7 @@ class DrsReplicaPrefixMapTestCase(drs_base.DrsBaseTestCase):
schi = drsuapi.DsReplicaOIDMapping()
schi.id_prefix = 0
if 'schemaInfo' in res[0]:
- binary_oid = [x if isinstance(x, int) else ord(x) for x in res[0]['schemaInfo'][0]]
+ binary_oid = list(res[0]['schemaInfo'][0])
schi.oid.length = len(binary_oid)
schi.oid.binary_oid = binary_oid
else:
@@ -1102,7 +1102,7 @@ class DrsReplicaPrefixMapTestCase(drs_base.DrsBaseTestCase):
schema_info.marker = 0xFF
schema_info.invocation_id = misc.GUID(samdb.get_invocation_id())
- binary_oid = [x if isinstance(x, int) else ord(x) for x in ndr_pack(schema_info)]
+ binary_oid = list(ndr_pack(schema_info))
# you have to set the length before setting binary_oid
schi.oid.length = len(binary_oid)
schi.oid.binary_oid = binary_oid
--
Samba Shared Repository
More information about the samba-cvs
mailing list