This is an automated email from the ASF dual-hosted git repository.

zrhoffman pushed a commit to branch 6.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit bada02c870cebe397a1a319b513cf506826b6dbf
Author: Zach Hoffman <[email protected]>
AuthorDate: Wed Oct 20 18:40:46 2021 +0000

    TO Postinstall: Check if hashlib.scrypt() exists before calling it (#6286)
---
 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 0d8ef08..3cf6d75 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 ## [6.0.1] - 2021-11-04
 ### Fixed
 - [#6125](https://github.com/apache/trafficcontrol/issues/6125) - Fix 
`/cdns/{name}/federations?id=#` to search for CDN.
+- [#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
 - [#5927](https://github.com/apache/trafficcontrol/issues/5927) Updated 
CDN-in-a-Box to not run a Riak container by default but instead only run it if 
the optional flag is provided.
diff --git a/traffic_ops/install/bin/_postinstall.py 
b/traffic_ops/install/bin/_postinstall.py
index 01a2b4e..35a770e 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()

Reply via email to