summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorGary Lockyer <gary@catalyst.net.nz>2017-06-08 07:21:05 +1200
committerAndrew Bartlett <abartlet@samba.org>2017-06-09 09:50:27 +0200
commit7bce7e150e2ae9adc3e372d65e152062e291cf19 (patch)
tree3d1b65c005b568966326de1e46663f0ea652d0d8 /python
parent0098a7b5564b60b3b29d3f1767adfd538d3ff55d (diff)
downloadsamba-7bce7e150e2ae9adc3e372d65e152062e291cf19.tar.gz
samba tool - tests: Fix shell metacharacters in generated password
Restrict the random password to [A-Za-z0-9] to ensure there are no shell metacharacters in the generated password. The tests use "samba-tool user create" to create the test user. Occasionally the generated password contained shell metachatacters and the command failed. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Jun 9 09:50:28 CEST 2017 on sn-devel-144
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/samba_tool/user_virtualCryptSHA.py12
-rw-r--r--python/samba/tests/samba_tool/user_wdigest.py8
2 files changed, 16 insertions, 4 deletions
diff --git a/python/samba/tests/samba_tool/user_virtualCryptSHA.py b/python/samba/tests/samba_tool/user_virtualCryptSHA.py
index 31c681dcfba..3ac4661a46e 100644
--- a/python/samba/tests/samba_tool/user_virtualCryptSHA.py
+++ b/python/samba/tests/samba_tool/user_virtualCryptSHA.py
@@ -31,9 +31,15 @@ from samba import dsdb
import binascii
import md5
import re
-
-USER_NAME = "CyyptSHATestUser"
-USER_PASS = samba.generate_random_password(32,32)
+import random
+import string
+
+USER_NAME = "CryptSHATestUser"
+# Create a random 32 character password, containing only letters and
+# digits to avoid issues when used on the command line.
+USER_PASS = ''.join(random.choice(string.ascii_uppercase +
+ string.ascii_lowercase +
+ string.digits) for _ in range(32))
HASH_OPTION = "password hash userPassword schemes"
# Get the value of an attribute from the output string
diff --git a/python/samba/tests/samba_tool/user_wdigest.py b/python/samba/tests/samba_tool/user_wdigest.py
index ff084200e15..b531ad0a33c 100644
--- a/python/samba/tests/samba_tool/user_wdigest.py
+++ b/python/samba/tests/samba_tool/user_wdigest.py
@@ -33,9 +33,15 @@ from samba.dcerpc import drsblobs
import binascii
import md5
import re
+import random
+import string
USER_NAME = "WdigestTestUser"
-USER_PASS = samba.generate_random_password(32, 32)
+# Create a random 32 character password, containing only letters and
+# digits to avoid issues when used on the command line.
+USER_PASS = ''.join(random.choice(string.ascii_uppercase +
+ string.ascii_lowercase +
+ string.digits) for _ in range(32))
# Calculate the MD5 password digest from the supplied user, realm and password
#