diff options
author | Noel Power <noel.power@suse.com> | 2018-08-15 16:40:16 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2018-09-03 03:22:25 +0200 |
commit | 82408fdc1f6c92baacd207438ffbcf9710e127ac (patch) | |
tree | 5b8ef6c539f03a3950bd0d07e7e14ab3adada6aa /python | |
parent | 17290a3770f1dacdded2fe7821a3afe4f523b424 (diff) | |
download | samba-82408fdc1f6c92baacd207438ffbcf9710e127ac.tar.gz |
python/samba/netcmd: PY2/PY3 changes required for user_virtualCryptSHA test
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/netcmd/user.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index b1d4b6ce023..00d6b679efd 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -1192,7 +1192,9 @@ class GetPasswordCommand(Command): if b is not None: u8 = get_utf8(a, b, username or account_name) if u8 is not None: - sv = get_crypt_value(str(algorithm), u8, rounds) + # in py2 using get_bytes should ensure u8 is unmodified + # in py3 it will be decoded + sv = get_crypt_value(str(algorithm), get_string(u8), rounds) if sv is None: # Unable to calculate a hash with the specified # number of rounds, fall back to the first hash using @@ -1219,12 +1221,15 @@ class GetPasswordCommand(Command): scheme_match = None for h in up.hashes: + # in PY2 this should just do nothing and in PY3 if bytes + # it will decode them + h_value = get_string(h.value) if (scheme_match is None and h.scheme == SCHEME and - h.value.startswith(scheme_prefix)): - scheme_match = h.value - if h.scheme == SCHEME and h.value.startswith(prefix): - return (h.value, scheme_match) + h_value.startswith(scheme_prefix)): + scheme_match = h_value + if h.scheme == SCHEME and h_value.startswith(prefix): + return (h_value, scheme_match) # No match on the number of rounds, return the value of the # first matching scheme |