[PATCH] Fix flapping user_virtualCryptSHA and user_wdigest tests

Jeremy Allison jra at samba.org
Fri Jun 9 00:02:25 UTC 2017


On Fri, Jun 09, 2017 at 07:00:53AM +1200, Gary Lockyer via samba-technical wrote:
> Both tests use "samba-tool user create" to create a user, with a random
> password. If the random password contained shell metacharacters or '-'
> failures like
> https://git.samba.org/autobuild.flakey.sn-devel-144/2017-06-03-1418/samba.stdout
> occurred.
> 
> This patch restricts the generated passwords to [A-Za-z0-9]
> 
> 
> Review and push appreciated

Oh good catch ! LGTM. Reviewed-by: Jeremy Allison <jra at samba.org>

> From 8b8e765672dd272b70d2659e447e391174da0461 Mon Sep 17 00:00:00 2001
> From: Gary Lockyer <gary at catalyst.net.nz>
> Date: Thu, 8 Jun 2017 07:21:05 +1200
> Subject: [PATCH] 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 at catalyst.net.nz>
> ---
>  python/samba/tests/samba_tool/user_virtualCryptSHA.py | 12 +++++++++---
>  python/samba/tests/samba_tool/user_wdigest.py         |  8 +++++++-
>  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 31c681d..3ac4661 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 ff08420..b531ad0 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
>  #
> -- 
> 2.7.4
> 






More information about the samba-technical mailing list