Bug 1792956
Summary: | python-passlib fails to build with Python 3.9: imports abc from collections + _crypt.crypt [Errno 22] Invalid argument | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Miro Hrončok <mhroncok> |
Component: | python-passlib | Assignee: | Alan Pevec (Fedora) <apevec> |
Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | high | Docs Contact: | |
Priority: | unspecified | ||
Version: | rawhide | CC: | apevec, apevec, cstratak, mhroncok, thomas.andrejak, tir.karthi |
Target Milestone: | --- | Keywords: | Reopened |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | python-passlib-1.7.2-1.fc33 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2020-02-28 15:23:34 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 1785415 |
Description
Miro Hrončok
2020-01-20 12:52:43 UTC
collections import seems to fixed with https://bitbucket.org/ecollins/passlib/commits/ff226f9dd5d892546973802ae45004bb88f1efc8 . Thanks. Alan, could you please backport the fix? This is blocking the rebuild of ansible. This bug appears to have been reported against 'rawhide' during the Fedora 32 development cycle. Changing version to 32. Please? ff226f9 is included in 1.7.2 *** This bug has been marked as a duplicate of bug 1775827 *** 1.7.2 does not solve ERROR: sha1_crypt (os_crypt backend): test hash() / genconfig() honors min_salt_size ... File "/usr/lib64/python3.9/crypt.py", line 82, in crypt return _crypt.crypt(word, salt) OSError: [Errno 22] Invalid argument library docs don't show changes in 3.9: https://docs.python.org/3.9/library/crypt.html#crypt.crypt but it is more strict in 3.9, I could reproduce this error with empty salt Python 3.7.6 (default, Jan 30 2020, 09:44:41) [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import crypt >>> crypt.crypt("sikrit","") >>> Python 3.9.0a3 (default, Jan 27 2020, 00:00:00) [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import crypt >>> crypt.crypt("sikrit","") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.9/crypt.py", line 82, in crypt return _crypt.crypt(word, salt) OSError: [Errno 22] Invalid argument While at it, 3.9 breaks nose, passlib master branch python ./setup.py test in py39 venv fails with ... File "/home/apevec/src/passlib/.eggs/nose-1.3.7-py3.9.egg/nose/suite.py", line 106, in _set_tests if isinstance(tests, collections.Callable) and not is_suite: AttributeError: module 'collections' has no attribute 'Callable' Fedora's nose is patched. Upstream nose is broken for ages, dead and you should run away form it fast. See also: https://fedoraproject.org/wiki/Changes/DeprecateNose As a side note, the collections.abc thing was reverted for 3.9.0a4 (but will hit again in 3.10 and this time, they made it pretty clear that there will be no more delaying). ack for Nose - it's up to upstream to decide re. crypt: in 3.9 it errors with some salt values e.g. Python 3.9.0a3 (default, Jan 27 2020, 00:00:00) ... >>> crypt.crypt('stub','$sha1$60000$') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.9/crypt.py", line 83, in crypt return _crypt.crypt(word, salt) OSError: [Errno 22] Invalid argument which silently returns nothing in 3.8 and earlier: Python 3.8.1 (default, Dec 19 2019, 00:00:00) ... >>> crypt.crypt('stub','$sha1$60000$') >>> $ git log -p v3.8.1..v3.9.0a3 -- Modules/_cryptmodule.c commit 0d3fe8ae4961bf551e7d5e42559e2ede1a08fd7c Author: Antonio Gutierrez <chibby0ne> Date: Tue Oct 8 06:22:17 2019 +0200 closes bpo-38402: Check error of primitive crypt/crypt_r. (GH-16599) Checks also for encryption algorithms methods not supported in different OSs. Signed-off-by: Antonio Gutierrez <chibby0ne> diff --git a/Modules/_cryptmodule.c b/Modules/_cryptmodule.c index 5d03f45f64..00c1f4f698 100644 --- a/Modules/_cryptmodule.c +++ b/Modules/_cryptmodule.c @@ -42,6 +42,9 @@ crypt_crypt_impl(PyObject *module, const char *word, const char *salt) #else crypt_result = crypt(word, salt); #endif + if (crypt_result == NULL) { + return PyErr_SetFromErrno(PyExc_OSError); + } return Py_BuildValue("s", crypt_result); } With this patch test suite passes with Python 3.9: diff -r bd0da1bdf0fd passlib/utils/__init__.py --- a/passlib/utils/__init__.py Sun Feb 16 10:56:06 2020 -0500 +++ b/passlib/utils/__init__.py Fri Feb 28 02:01:08 2020 +0100 @@ -791,7 +791,10 @@ raise ValueError("null character in secret") if isinstance(hash, bytes): hash = hash.decode("ascii") - result = _crypt(secret, hash) + try: + result = _crypt(secret, hash) + except OSError: + result = None # NOTE: per issue 113, crypt() may return bytes in some odd cases. # assuming it should still return an ASCII hash though, # or there's a bigger issue at hand. rebased to 1.7.2 diff -r 48058c4309dd passlib/utils/__init__.py --- a/passlib/utils/__init__.py Fri Nov 22 16:08:33 2019 -0500 +++ b/passlib/utils/__init__.py Fri Feb 28 02:10:14 2020 +0100 @@ -791,7 +791,10 @@ raise ValueError("null character in secret") if isinstance(hash, bytes): hash = hash.decode("ascii") - result = _crypt(secret, hash) + try: + result = _crypt(secret, hash) + except OSError: + result = None if not result or result[0] in _invalid_prefixes: return None return result Reported upstream https://bitbucket.org/ecollins/passlib/issues/115 |