1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

samba-tool user readpasswords: avoid assert for validation

`assert` can be optimised away if python is run with `-O`.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Jun 11 05:32:28 UTC 2024 on atb-devel-224
This commit is contained in:
Douglas Bagnall
2024-02-02 15:01:21 +13:00
committed by Andrew Bartlett
parent b42c489180
commit db342d86a9

View File

@ -114,7 +114,10 @@ def get_crypt_value(alg, utf8pw, rounds=0):
"5": {"length": 43},
"6": {"length": 86},
}
assert alg in algs
if alg not in algs:
raise ValueError(f"invalid algorithm code: {alg}"
f"(expected one of {','.join(algs.keys())})")
salt = os.urandom(16)
# The salt needs to be in [A-Za-z0-9./]
# base64 is close enough and as we had 16