The branch, master has been updated via 39e06c49aeb docs-xml: fix problamatic quotes from panic action example via 43642316259 python: use os.urandom, which is available in python by definition from a7383889282 lib: free popt context in texpect
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 39e06c49aebddaa208a149233cf35159588ebfdc Author: Björn Jacke <b...@sernet.de> Date: Thu Aug 22 13:51:59 2019 +0200 docs-xml: fix problamatic quotes from panic action example those quotes work for smbd but do not work for the samba binary. Without quotes it works with both. Signed-off-by: Bjoern Jacke <bja...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Autobuild-User(master): Björn Jacke <bja...@samba.org> Autobuild-Date(master): Thu Aug 22 13:46:14 UTC 2019 on sn-devel-184 commit 436423162592a684d52634e6db05f20bce6a5362 Author: Björn Jacke <b...@sernet.de> Date: Thu Jul 4 20:38:50 2019 +0200 python: use os.urandom, which is available in python by definition os.urandom also uses CSPRNG methods like getrandom() when the underlying OS provides those. Signed-off-by: Bjoern Jacke <bja...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> ----------------------------------------------------------------------- Summary of changes: docs-xml/smbdotconf/misc/panicaction.xml | 2 +- python/samba/netcmd/user.py | 41 ++------------------------------ 2 files changed, 3 insertions(+), 40 deletions(-) Changeset truncated at 500 lines: diff --git a/docs-xml/smbdotconf/misc/panicaction.xml b/docs-xml/smbdotconf/misc/panicaction.xml index d6e1517525d..7b7df256388 100644 --- a/docs-xml/smbdotconf/misc/panicaction.xml +++ b/docs-xml/smbdotconf/misc/panicaction.xml @@ -12,5 +12,5 @@ </description> <value type="default"></value> -<value type="example">"/bin/sleep 90000"</value> +<value type="example">/bin/sleep 90000</value> </samba:parameter> diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index 121050a26e6..e9f35f158e3 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -124,33 +124,6 @@ virtual_attributes = { }, } -get_random_bytes_fn = None -if get_random_bytes_fn is None: - try: - import Crypto.Random - get_random_bytes_fn = Crypto.Random.get_random_bytes - except ImportError as e: - pass -if get_random_bytes_fn is None: - try: - import M2Crypto.Rand - get_random_bytes_fn = M2Crypto.Rand.rand_bytes - except ImportError as e: - pass - - -def check_random(): - if get_random_bytes_fn is not None: - return None - return "Crypto.Random or M2Crypto.Rand required" - - -def get_random_bytes(num): - random_reason = check_random() - if random_reason is not None: - raise ImportError(random_reason) - return get_random_bytes_fn(num) - def get_crypt_value(alg, utf8pw, rounds=0): algs = { @@ -158,7 +131,7 @@ def get_crypt_value(alg, utf8pw, rounds=0): "6": {"length": 86}, } assert alg in algs - salt = get_random_bytes(16) + salt = os.urandom(16) # The salt needs to be in [A-Za-z0-9./] # base64 is close enough and as we had 16 # random bytes but only need 16 characters @@ -203,9 +176,6 @@ def get_rounds(options): try: - random_reason = check_random() - if random_reason is not None: - raise ImportError(random_reason) import hashlib h = hashlib.sha1() h = None @@ -213,8 +183,6 @@ try: } except ImportError as e: reason = "hashlib.sha1()" - if random_reason: - reason += " and " + random_reason reason += " required" disabled_virtual_attributes["virtualSSHA"] = { "reason": reason, @@ -222,9 +190,6 @@ except ImportError as e: for (alg, attr) in [("5", "virtualCryptSHA256"), ("6", "virtualCryptSHA512")]: try: - random_reason = check_random() - if random_reason is not None: - raise ImportError(random_reason) import crypt v = get_crypt_value(alg, "") v = None @@ -232,8 +197,6 @@ for (alg, attr) in [("5", "virtualCryptSHA256"), ("6", "virtualCryptSHA512")]: } except ImportError as e: reason = "crypt" - if random_reason: - reason += " and " + random_reason reason += " required" disabled_virtual_attributes[attr] = { "reason": reason, @@ -1307,7 +1270,7 @@ class GetPasswordCommand(Command): u8 = get_utf8(a, b, username or account_name) if u8 is None: continue - salt = get_random_bytes(4) + salt = os.urandom(4) h = hashlib.sha1() h.update(u8) h.update(salt) -- Samba Shared Repository