From 09931e216cf984a72cc1804c23590bde988c2b02 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Fri, 7 Dec 2012 17:36:02 +0200 Subject: [PATCH] wafsamba: Make sure md5 is really work before using it or overriding the hash function In FIPS mode importing md5 Python module will not cause any error but calling md5.md5() function will throw ValueError since md5 is not available. Make sure md5.md5() actually works and if not, fall back to use hash replacement that we already have in wafsamba. Reviewed-by: Andreas Schneider (cherry picked from commit 4b52de000c91df2f57ccc3d09688d897f8b56e0e) Signed-off-by: Andreas Schneider --- buildtools/wafsamba/samba_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index c1869df..cab87a4 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -388,9 +388,17 @@ def RUN_COMMAND(cmd, # make sure we have md5. some systems don't have it try: from hashlib import md5 + try: + foo = md5.md5('abcd') + except ValueError: + raise except: try: import md5 + try: + foo = md5.md5('abcd') + except ValueError: + raise except: import Constants Constants.SIG_NIL = hash('abcd') -- 1.8.0.1