From 52d5d4ddcd014f5095ceedf34c660338dc4a8914 Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Thu, 7 Aug 2025 16:42:07 +0300 Subject: [PATCH] buildtools: fixed broken build with FIPS-enabled host MD5 is not supported on FIPS-enabled machines, but the current work-around is broken. One the other hand, latest Waf has proper fixup (use sha1 as a replacement to md5) so there is no need for Samba specific code. Tested on CentOS-stream-9 with FIPS (Python-3.9.23). Signed-off-by: Shachar Sharon Reviewed-by: Andreas Schneider Reviewed-by: Alexander Bokovoy --- buildtools/wafsamba/samba_utils.py | 37 ------------------------------ 1 file changed, 37 deletions(-) diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 1776fcee965..548e21b4a26 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -360,43 +360,6 @@ def RUN_PYTHON_TESTS(testfiles, pythonpath=None, extra_env=None): return result -# make sure we have md5. some systems don't have it -try: - from hashlib import md5 - # Even if hashlib.md5 exists, it may be unusable. - # Try to use MD5 function. In FIPS mode this will cause an exception - # and we'll get to the replacement code - foo = md5(b'abcd') -except: - try: - import md5 - # repeat the same check here, mere success of import is not enough. - # Try to use MD5 function. In FIPS mode this will cause an exception - foo = md5.md5(b'abcd') - except: - Context.SIG_NIL = hash('abcd') - class replace_md5(object): - def __init__(self): - self.val = None - def update(self, val): - self.val = hash((self.val, val)) - def digest(self): - return str(self.val) - def hexdigest(self): - return self.digest().encode('hex') - def replace_h_file(filename): - f = open(filename, 'rb') - m = replace_md5() - while (filename): - filename = f.read(100000) - m.update(filename) - f.close() - return m.digest() - Utils.md5 = replace_md5 - Task.md5 = replace_md5 - Utils.h_file = replace_h_file - - def LOAD_ENVIRONMENT(): '''load the configuration environment, allowing access to env vars from new commands''' -- 2.47.3