samba tool - tests: Fix shell metacharacters in generated password
authorGary Lockyer <gary@catalyst.net.nz>
Wed, 7 Jun 2017 19:21:05 +0000 (07:21 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 9 Jun 2017 07:50:27 +0000 (09:50 +0200)
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

python/samba/tests/samba_tool/user_virtualCryptSHA.py
python/samba/tests/samba_tool/user_wdigest.py

index 31c681dcfba7856331c7d4f4a445df7b0378c635..3ac4661a46e23c122a7a8668879f66a1d2830513 100644 (file)
@@ -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
index ff084200e15b097fbf3d7feac11a6c6f362b5775..b531ad0a33c63e1a0e6809e5e146cd9af7c36744 100644 (file)
@@ -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
 #