From daeabeb67213942145e28d91eeda85286c598be4 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Thu, 30 Sep 2021 15:24:47 -0600 Subject: [PATCH] TO Postinstall: Check if hashlib.scrypt() exists before calling it --- CHANGELOG.md | 1 + traffic_ops/install/bin/_postinstall.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6784a3754a..c4b3e3bc76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - [#6255](https://github.com/apache/trafficcontrol/issues/6255) - Unreadable Prod Mode CDN Notifications in Traffic Portal - [#6259](https://github.com/apache/trafficcontrol/issues/6259) - Traffic Portal No Longer Allows Spaces in Server Object "Router Port Name" - [#6175](https://github.com/apache/trafficcontrol/issues/6175) - POST request to /api/4.0/phys_locations accepts mismatch values for regionName. +- [#6283](https://github.com/apache/trafficcontrol/issues/6283) - The Traffic Ops Postinstall script will work in CentOS 7, even if Python 3 is installed ### Changed - Updated `t3c` to request less unnecessary deliveryservice-server assignment and invalidation jobs data via new query params supported by Traffic Ops diff --git a/traffic_ops/install/bin/_postinstall.py b/traffic_ops/install/bin/_postinstall.py index 01a2b4e7f3..35a770ea2c 100755 --- a/traffic_ops/install/bin/_postinstall.py +++ b/traffic_ops/install/bin/_postinstall.py @@ -429,7 +429,7 @@ def hash_pass(passwd): # type: (str) -> str p_val = 1 dklen = 64 salt = os.urandom(dklen) - if sys.version_info.major >= 3: + if sys.version_info.major >= 3 and hasattr(hashlib, 'scrypt'): # Python 2.7 and CentOS 7's Python 3.6 do not include hashlib.scrypt() hashed = hashlib.scrypt(passwd.encode(), salt=salt, n=n, r=r_val, p=p_val, dklen=dklen) else: hashed = Scrypt(password=passwd.encode(), salt=salt, cost_factor=n, block_size_factor=r_val, parallelization_factor=p_val, key_length=dklen).derive()