commit
331a1f4f36
@ -0,0 +1 @@
|
||||
SOURCES/Python-3.12.6.tar.xz
|
@ -0,0 +1 @@
|
||||
6d2bbe1603b01764c541608938766233bf56f780 SOURCES/Python-3.12.6.tar.xz
|
@ -0,0 +1,173 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||
Date: Mon, 15 Feb 2021 12:19:27 +0100
|
||||
Subject: [PATCH] 00251: Change user install location
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Set values of base and platbase in sysconfig from /usr
|
||||
to /usr/local when RPM build is not detected
|
||||
to make pip and similar tools install into separate location.
|
||||
|
||||
Fedora Change: https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||
Downstream only.
|
||||
|
||||
We've tried to rework in Fedora 36/Python 3.10 to follow https://bugs.python.org/issue43976
|
||||
but we have identified serious problems with that approach,
|
||||
see https://bugzilla.redhat.com/2026979 or https://bugzilla.redhat.com/2097183
|
||||
|
||||
pypa/distutils integration: https://github.com/pypa/distutils/pull/70
|
||||
|
||||
Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
||||
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
|
||||
Co-authored-by: Michal Cyprian <m.cyprian@gmail.com>
|
||||
Co-authored-by: Lumír Balhar <frenzy.madness@gmail.com>
|
||||
---
|
||||
Lib/site.py | 9 ++++++-
|
||||
Lib/sysconfig.py | 49 +++++++++++++++++++++++++++++++++++++-
|
||||
Lib/test/test_sysconfig.py | 17 +++++++++++--
|
||||
3 files changed, 71 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Lib/site.py b/Lib/site.py
|
||||
index 924cfbecec..e2871ecc89 100644
|
||||
--- a/Lib/site.py
|
||||
+++ b/Lib/site.py
|
||||
@@ -398,8 +398,15 @@ def getsitepackages(prefixes=None):
|
||||
return sitepackages
|
||||
|
||||
def addsitepackages(known_paths, prefixes=None):
|
||||
- """Add site-packages to sys.path"""
|
||||
+ """Add site-packages to sys.path
|
||||
+
|
||||
+ '/usr/local' is included in PREFIXES if RPM build is not detected
|
||||
+ to make packages installed into this location visible.
|
||||
+
|
||||
+ """
|
||||
_trace("Processing global site-packages")
|
||||
+ if ENABLE_USER_SITE and 'RPM_BUILD_ROOT' not in os.environ:
|
||||
+ PREFIXES.insert(0, "/usr/local")
|
||||
for sitedir in getsitepackages(prefixes):
|
||||
if os.path.isdir(sitedir):
|
||||
addsitedir(sitedir, known_paths)
|
||||
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
|
||||
index 122d441bd1..2d354a11da 100644
|
||||
--- a/Lib/sysconfig.py
|
||||
+++ b/Lib/sysconfig.py
|
||||
@@ -104,6 +104,11 @@
|
||||
else:
|
||||
_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_venv']
|
||||
|
||||
+# For a brief period of time in the Fedora 36 life cycle,
|
||||
+# this installation scheme existed and was documented in the release notes.
|
||||
+# For backwards compatibility, we keep it here (at least on 3.10 and 3.11).
|
||||
+_INSTALL_SCHEMES['rpm_prefix'] = _INSTALL_SCHEMES['posix_prefix']
|
||||
+
|
||||
|
||||
# NOTE: site.py has copy of this function.
|
||||
# Sync it when modify this function.
|
||||
@@ -163,6 +168,19 @@ def joinuser(*args):
|
||||
},
|
||||
}
|
||||
|
||||
+# This is used by distutils.command.install in the stdlib
|
||||
+# as well as pypa/distutils (e.g. bundled in setuptools).
|
||||
+# The self.prefix value is set to sys.prefix + /local/
|
||||
+# if neither RPM build nor virtual environment is
|
||||
+# detected to make distutils install packages
|
||||
+# into the separate location.
|
||||
+# https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||
+if (not (hasattr(sys, 'real_prefix') or
|
||||
+ sys.prefix != sys.base_prefix) and
|
||||
+ 'RPM_BUILD_ROOT' not in os.environ):
|
||||
+ _prefix_addition = '/local'
|
||||
+
|
||||
+
|
||||
_SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include',
|
||||
'scripts', 'data')
|
||||
|
||||
@@ -263,11 +281,40 @@ def _extend_dict(target_dict, other_dict):
|
||||
target_dict[key] = value
|
||||
|
||||
|
||||
+_CONFIG_VARS_LOCAL = None
|
||||
+
|
||||
+
|
||||
+def _config_vars_local():
|
||||
+ # This function returns the config vars with prefixes amended to /usr/local
|
||||
+ # https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||
+ global _CONFIG_VARS_LOCAL
|
||||
+ if _CONFIG_VARS_LOCAL is None:
|
||||
+ _CONFIG_VARS_LOCAL = dict(get_config_vars())
|
||||
+ _CONFIG_VARS_LOCAL['base'] = '/usr/local'
|
||||
+ _CONFIG_VARS_LOCAL['platbase'] = '/usr/local'
|
||||
+ return _CONFIG_VARS_LOCAL
|
||||
+
|
||||
+
|
||||
def _expand_vars(scheme, vars):
|
||||
res = {}
|
||||
if vars is None:
|
||||
vars = {}
|
||||
- _extend_dict(vars, get_config_vars())
|
||||
+
|
||||
+ # when we are not in a virtual environment or an RPM build
|
||||
+ # we change '/usr' to '/usr/local'
|
||||
+ # to avoid surprises, we explicitly check for the /usr/ prefix
|
||||
+ # Python virtual environments have different prefixes
|
||||
+ # we only do this for posix_prefix, not to mangle the venv scheme
|
||||
+ # posix_prefix is used by sudo pip install
|
||||
+ # we only change the defaults here, so explicit --prefix will take precedence
|
||||
+ # https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||
+ if (scheme == 'posix_prefix' and
|
||||
+ _PREFIX == '/usr' and
|
||||
+ 'RPM_BUILD_ROOT' not in os.environ):
|
||||
+ _extend_dict(vars, _config_vars_local())
|
||||
+ else:
|
||||
+ _extend_dict(vars, get_config_vars())
|
||||
+
|
||||
if os.name == 'nt':
|
||||
# On Windows we want to substitute 'lib' for schemes rather
|
||||
# than the native value (without modifying vars, in case it
|
||||
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
|
||||
index 1137c2032b..8fc2b84f52 100644
|
||||
--- a/Lib/test/test_sysconfig.py
|
||||
+++ b/Lib/test/test_sysconfig.py
|
||||
@@ -110,8 +110,19 @@ def test_get_path(self):
|
||||
for scheme in _INSTALL_SCHEMES:
|
||||
for name in _INSTALL_SCHEMES[scheme]:
|
||||
expected = _INSTALL_SCHEMES[scheme][name].format(**config_vars)
|
||||
+ tested = get_path(name, scheme)
|
||||
+ # https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||
+ if tested.startswith('/usr/local'):
|
||||
+ # /usr/local should only be used in posix_prefix
|
||||
+ self.assertEqual(scheme, 'posix_prefix')
|
||||
+ # Fedora CI runs tests for venv and virtualenv that check for other prefixes
|
||||
+ self.assertEqual(sys.prefix, '/usr')
|
||||
+ # When building the RPM of Python, %check runs this with RPM_BUILD_ROOT set
|
||||
+ # Fedora CI runs this with RPM_BUILD_ROOT unset
|
||||
+ self.assertNotIn('RPM_BUILD_ROOT', os.environ)
|
||||
+ tested = tested.replace('/usr/local', '/usr')
|
||||
self.assertEqual(
|
||||
- os.path.normpath(get_path(name, scheme)),
|
||||
+ os.path.normpath(tested),
|
||||
os.path.normpath(expected),
|
||||
)
|
||||
|
||||
@@ -344,7 +355,7 @@ def test_get_config_h_filename(self):
|
||||
self.assertTrue(os.path.isfile(config_h), config_h)
|
||||
|
||||
def test_get_scheme_names(self):
|
||||
- wanted = ['nt', 'posix_home', 'posix_prefix', 'posix_venv', 'nt_venv', 'venv']
|
||||
+ wanted = ['nt', 'posix_home', 'posix_prefix', 'posix_venv', 'nt_venv', 'venv', 'rpm_prefix']
|
||||
if HAS_USER_BASE:
|
||||
wanted.extend(['nt_user', 'osx_framework_user', 'posix_user'])
|
||||
self.assertEqual(get_scheme_names(), tuple(sorted(wanted)))
|
||||
@@ -356,6 +367,8 @@ def test_symlink(self): # Issue 7880
|
||||
cmd = "-c", "import sysconfig; print(sysconfig.get_platform())"
|
||||
self.assertEqual(py.call_real(*cmd), py.call_link(*cmd))
|
||||
|
||||
+ @unittest.skipIf('RPM_BUILD_ROOT' not in os.environ,
|
||||
+ "Test doesn't expect Fedora's paths")
|
||||
def test_user_similar(self):
|
||||
# Issue #8759: make sure the posix scheme for the users
|
||||
# is similar to the global posix_prefix one
|
@ -0,0 +1,826 @@
|
||||
From d307f5706434e0cb445fb48291852bd7ec46ddbd Mon Sep 17 00:00:00 2001
|
||||
From: Charalampos Stratakis <cstratak@redhat.com>
|
||||
Date: Thu, 12 Dec 2019 16:58:31 +0100
|
||||
Subject: [PATCH 1/5] Expose blake2b and blake2s hashes from OpenSSL
|
||||
|
||||
These aren't as powerful as Python's own implementation, but they can be
|
||||
used under FIPS.
|
||||
---
|
||||
Lib/test/test_hashlib.py | 6 ++
|
||||
Modules/_hashopenssl.c | 37 ++++++++
|
||||
Modules/clinic/_hashopenssl.c.h | 152 +++++++++++++++++++++++++++++++-
|
||||
3 files changed, 194 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
|
||||
index 73d758a..5921360 100644
|
||||
--- a/Lib/test/test_hashlib.py
|
||||
+++ b/Lib/test/test_hashlib.py
|
||||
@@ -375,6 +375,12 @@ class HashLibTestCase(unittest.TestCase):
|
||||
# 2 is for hashlib.name(...) and hashlib.new(name, ...)
|
||||
self.assertGreaterEqual(len(constructors), 2)
|
||||
for hash_object_constructor in constructors:
|
||||
+
|
||||
+ # OpenSSL's blake2s & blake2d don't support `key`
|
||||
+ _name = hash_object_constructor.__name__
|
||||
+ if 'key' in kwargs and _name.startswith('openssl_blake2'):
|
||||
+ return
|
||||
+
|
||||
m = hash_object_constructor(data, **kwargs)
|
||||
computed = m.hexdigest() if not shake else m.hexdigest(length)
|
||||
self.assertEqual(
|
||||
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
|
||||
index af6d1b2..980712f 100644
|
||||
--- a/Modules/_hashopenssl.c
|
||||
+++ b/Modules/_hashopenssl.c
|
||||
@@ -1079,6 +1079,41 @@ _hashlib_openssl_sha512_impl(PyObject *module, PyObject *data_obj,
|
||||
}
|
||||
|
||||
|
||||
+/*[clinic input]
|
||||
+_hashlib.openssl_blake2b
|
||||
+ string as data_obj: object(py_default="b''") = NULL
|
||||
+ *
|
||||
+ usedforsecurity: bool = True
|
||||
+Returns a blake2b hash object; optionally initialized with a string
|
||||
+[clinic start generated code]*/
|
||||
+
|
||||
+static PyObject *
|
||||
+_hashlib_openssl_blake2b_impl(PyObject *module, PyObject *data_obj,
|
||||
+ int usedforsecurity)
|
||||
+/*[clinic end generated code: output=7a838b1643cde13e input=4ad7fd54268f3689]*/
|
||||
+
|
||||
+{
|
||||
+ return py_evp_fromname(module, Py_hash_blake2b, data_obj, usedforsecurity);
|
||||
+}
|
||||
+
|
||||
+/*[clinic input]
|
||||
+_hashlib.openssl_blake2s
|
||||
+ string as data_obj: object(py_default="b''") = NULL
|
||||
+ *
|
||||
+ usedforsecurity: bool = True
|
||||
+Returns a blake2s hash object; optionally initialized with a string
|
||||
+[clinic start generated code]*/
|
||||
+
|
||||
+static PyObject *
|
||||
+_hashlib_openssl_blake2s_impl(PyObject *module, PyObject *data_obj,
|
||||
+ int usedforsecurity)
|
||||
+/*[clinic end generated code: output=4eda6b40757471da input=1ed39481ffa4e26a]*/
|
||||
+
|
||||
+{
|
||||
+ return py_evp_fromname(module, Py_hash_blake2s, data_obj, usedforsecurity);
|
||||
+}
|
||||
+
|
||||
+
|
||||
#ifdef PY_OPENSSL_HAS_SHA3
|
||||
|
||||
/*[clinic input]
|
||||
@@ -2067,6 +2102,8 @@ static struct PyMethodDef EVP_functions[] = {
|
||||
_HASHLIB_OPENSSL_SHA256_METHODDEF
|
||||
_HASHLIB_OPENSSL_SHA384_METHODDEF
|
||||
_HASHLIB_OPENSSL_SHA512_METHODDEF
|
||||
+ _HASHLIB_OPENSSL_BLAKE2B_METHODDEF
|
||||
+ _HASHLIB_OPENSSL_BLAKE2S_METHODDEF
|
||||
_HASHLIB_OPENSSL_SHA3_224_METHODDEF
|
||||
_HASHLIB_OPENSSL_SHA3_256_METHODDEF
|
||||
_HASHLIB_OPENSSL_SHA3_384_METHODDEF
|
||||
diff --git a/Modules/clinic/_hashopenssl.c.h b/Modules/clinic/_hashopenssl.c.h
|
||||
index fb61a44..1e42b87 100644
|
||||
--- a/Modules/clinic/_hashopenssl.c.h
|
||||
+++ b/Modules/clinic/_hashopenssl.c.h
|
||||
@@ -743,6 +743,156 @@ exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
+PyDoc_STRVAR(_hashlib_openssl_blake2b__doc__,
|
||||
+"openssl_blake2b($module, /, string=b\'\', *, usedforsecurity=True)\n"
|
||||
+"--\n"
|
||||
+"\n"
|
||||
+"Returns a blake2b hash object; optionally initialized with a string");
|
||||
+
|
||||
+#define _HASHLIB_OPENSSL_BLAKE2B_METHODDEF \
|
||||
+ {"openssl_blake2b", _PyCFunction_CAST(_hashlib_openssl_blake2b), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_blake2b__doc__},
|
||||
+
|
||||
+static PyObject *
|
||||
+_hashlib_openssl_blake2b_impl(PyObject *module, PyObject *data_obj,
|
||||
+ int usedforsecurity);
|
||||
+
|
||||
+static PyObject *
|
||||
+_hashlib_openssl_blake2b(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
+{
|
||||
+ PyObject *return_value = NULL;
|
||||
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
+
|
||||
+ #define NUM_KEYWORDS 2
|
||||
+ static struct {
|
||||
+ PyGC_Head _this_is_not_used;
|
||||
+ PyObject_VAR_HEAD
|
||||
+ PyObject *ob_item[NUM_KEYWORDS];
|
||||
+ } _kwtuple = {
|
||||
+ .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
||||
+ .ob_item = { &_Py_ID(string), &_Py_ID(usedforsecurity), },
|
||||
+ };
|
||||
+ #undef NUM_KEYWORDS
|
||||
+ #define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
||||
+
|
||||
+ #else // !Py_BUILD_CORE
|
||||
+ # define KWTUPLE NULL
|
||||
+ #endif // !Py_BUILD_CORE
|
||||
+
|
||||
+ static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
|
||||
+ static _PyArg_Parser _parser = {
|
||||
+ .keywords = _keywords,
|
||||
+ .fname = "openssl_blake2b",
|
||||
+ .kwtuple = KWTUPLE,
|
||||
+ };
|
||||
+ #undef KWTUPLE
|
||||
+ PyObject *argsbuf[2];
|
||||
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
|
||||
+ PyObject *data_obj = NULL;
|
||||
+ int usedforsecurity = 1;
|
||||
+
|
||||
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
|
||||
+ if (!args) {
|
||||
+ goto exit;
|
||||
+ }
|
||||
+ if (!noptargs) {
|
||||
+ goto skip_optional_pos;
|
||||
+ }
|
||||
+ if (args[0]) {
|
||||
+ data_obj = args[0];
|
||||
+ if (!--noptargs) {
|
||||
+ goto skip_optional_pos;
|
||||
+ }
|
||||
+ }
|
||||
+skip_optional_pos:
|
||||
+ if (!noptargs) {
|
||||
+ goto skip_optional_kwonly;
|
||||
+ }
|
||||
+ usedforsecurity = PyObject_IsTrue(args[1]);
|
||||
+ if (usedforsecurity < 0) {
|
||||
+ goto exit;
|
||||
+ }
|
||||
+skip_optional_kwonly:
|
||||
+ return_value = _hashlib_openssl_blake2b_impl(module, data_obj, usedforsecurity);
|
||||
+
|
||||
+exit:
|
||||
+ return return_value;
|
||||
+}
|
||||
+
|
||||
+PyDoc_STRVAR(_hashlib_openssl_blake2s__doc__,
|
||||
+"openssl_blake2s($module, /, string=b\'\', *, usedforsecurity=True)\n"
|
||||
+"--\n"
|
||||
+"\n"
|
||||
+"Returns a blake2s hash object; optionally initialized with a string");
|
||||
+
|
||||
+#define _HASHLIB_OPENSSL_BLAKE2S_METHODDEF \
|
||||
+ {"openssl_blake2s", _PyCFunction_CAST(_hashlib_openssl_blake2s), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_blake2s__doc__},
|
||||
+
|
||||
+static PyObject *
|
||||
+_hashlib_openssl_blake2s_impl(PyObject *module, PyObject *data_obj,
|
||||
+ int usedforsecurity);
|
||||
+
|
||||
+static PyObject *
|
||||
+_hashlib_openssl_blake2s(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
+{
|
||||
+ PyObject *return_value = NULL;
|
||||
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
+
|
||||
+ #define NUM_KEYWORDS 2
|
||||
+ static struct {
|
||||
+ PyGC_Head _this_is_not_used;
|
||||
+ PyObject_VAR_HEAD
|
||||
+ PyObject *ob_item[NUM_KEYWORDS];
|
||||
+ } _kwtuple = {
|
||||
+ .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
||||
+ .ob_item = { &_Py_ID(string), &_Py_ID(usedforsecurity), },
|
||||
+ };
|
||||
+ #undef NUM_KEYWORDS
|
||||
+ #define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
||||
+
|
||||
+ #else // !Py_BUILD_CORE
|
||||
+ # define KWTUPLE NULL
|
||||
+ #endif // !Py_BUILD_CORE
|
||||
+
|
||||
+ static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
|
||||
+ static _PyArg_Parser _parser = {
|
||||
+ .keywords = _keywords,
|
||||
+ .fname = "openssl_blake2s",
|
||||
+ .kwtuple = KWTUPLE,
|
||||
+ };
|
||||
+ #undef KWTUPLE
|
||||
+ PyObject *argsbuf[2];
|
||||
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
|
||||
+ PyObject *data_obj = NULL;
|
||||
+ int usedforsecurity = 1;
|
||||
+
|
||||
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
|
||||
+ if (!args) {
|
||||
+ goto exit;
|
||||
+ }
|
||||
+ if (!noptargs) {
|
||||
+ goto skip_optional_pos;
|
||||
+ }
|
||||
+ if (args[0]) {
|
||||
+ data_obj = args[0];
|
||||
+ if (!--noptargs) {
|
||||
+ goto skip_optional_pos;
|
||||
+ }
|
||||
+ }
|
||||
+skip_optional_pos:
|
||||
+ if (!noptargs) {
|
||||
+ goto skip_optional_kwonly;
|
||||
+ }
|
||||
+ usedforsecurity = PyObject_IsTrue(args[1]);
|
||||
+ if (usedforsecurity < 0) {
|
||||
+ goto exit;
|
||||
+ }
|
||||
+skip_optional_kwonly:
|
||||
+ return_value = _hashlib_openssl_blake2s_impl(module, data_obj, usedforsecurity);
|
||||
+
|
||||
+exit:
|
||||
+ return return_value;
|
||||
+}
|
||||
+
|
||||
#if defined(PY_OPENSSL_HAS_SHA3)
|
||||
|
||||
PyDoc_STRVAR(_hashlib_openssl_sha3_224__doc__,
|
||||
@@ -1851,4 +2001,4 @@ exit:
|
||||
#ifndef _HASHLIB_SCRYPT_METHODDEF
|
||||
#define _HASHLIB_SCRYPT_METHODDEF
|
||||
#endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */
|
||||
-/*[clinic end generated code: output=b339e255db698147 input=a9049054013a1b77]*/
|
||||
+/*[clinic end generated code: output=1d988d457a8beebe input=a9049054013a1b77]*/
|
||||
--
|
||||
2.45.0
|
||||
|
||||
|
||||
From c247ff164269fb68236a79a1359cc37c1a8a0004 Mon Sep 17 00:00:00 2001
|
||||
From: Petr Viktorin <pviktori@redhat.com>
|
||||
Date: Thu, 25 Jul 2019 17:19:06 +0200
|
||||
Subject: [PATCH 2/5] Disable Python's hash implementations in FIPS mode,
|
||||
forcing OpenSSL
|
||||
|
||||
---
|
||||
Lib/hashlib.py | 11 +++++++----
|
||||
Lib/test/test_hashlib.py | 17 ++++++++++++-----
|
||||
Modules/_blake2/blake2b_impl.c | 4 ++++
|
||||
Modules/_blake2/blake2module.c | 5 ++++-
|
||||
Modules/_blake2/blake2s_impl.c | 4 ++++
|
||||
Modules/hashlib.h | 23 +++++++++++++++++++++++
|
||||
configure.ac | 3 ++-
|
||||
7 files changed, 56 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
|
||||
index 1b16441..9897402 100644
|
||||
--- a/Lib/hashlib.py
|
||||
+++ b/Lib/hashlib.py
|
||||
@@ -70,14 +70,17 @@ __all__ = __always_supported + ('new', 'algorithms_guaranteed',
|
||||
|
||||
__builtin_constructor_cache = {}
|
||||
|
||||
-# Prefer our blake2 implementation
|
||||
+# Prefer our blake2 implementation (unless in FIPS mode)
|
||||
# OpenSSL 1.1.0 comes with a limited implementation of blake2b/s. The OpenSSL
|
||||
# implementations neither support keyed blake2 (blake2 MAC) nor advanced
|
||||
# features like salt, personalization, or tree hashing. OpenSSL hash-only
|
||||
# variants are available as 'blake2b512' and 'blake2s256', though.
|
||||
-__block_openssl_constructor = {
|
||||
- 'blake2b', 'blake2s',
|
||||
-}
|
||||
+import _hashlib
|
||||
+if _hashlib.get_fips_mode():
|
||||
+ __block_openssl_constructor = set()
|
||||
+else:
|
||||
+ __block_openssl_constructor = {'blake2b', 'blake2s'}
|
||||
+
|
||||
|
||||
def __get_builtin_constructor(name):
|
||||
cache = __builtin_constructor_cache
|
||||
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
|
||||
index 5921360..dd61a9a 100644
|
||||
--- a/Lib/test/test_hashlib.py
|
||||
+++ b/Lib/test/test_hashlib.py
|
||||
@@ -35,14 +35,15 @@ else:
|
||||
m.strip() for m in builtin_hashes.strip('"').lower().split(",")
|
||||
}
|
||||
|
||||
-# hashlib with and without OpenSSL backend for PBKDF2
|
||||
-# only import builtin_hashlib when all builtin hashes are available.
|
||||
-# Otherwise import prints noise on stderr
|
||||
+# RHEL: `_hashlib` is always importable and `hashlib` can't be imported
|
||||
+# without it.
|
||||
openssl_hashlib = import_fresh_module('hashlib', fresh=['_hashlib'])
|
||||
-if builtin_hashes == default_builtin_hashes:
|
||||
+try:
|
||||
builtin_hashlib = import_fresh_module('hashlib', blocked=['_hashlib'])
|
||||
-else:
|
||||
+except ImportError:
|
||||
builtin_hashlib = None
|
||||
+else:
|
||||
+ raise AssertionError('hashlib is importable without _hashlib')
|
||||
|
||||
try:
|
||||
from _hashlib import HASH, HASHXOF, openssl_md_meth_names, get_fips_mode
|
||||
@@ -114,6 +115,12 @@ class HashLibTestCase(unittest.TestCase):
|
||||
except ModuleNotFoundError as error:
|
||||
if self._warn_on_extension_import and module_name in builtin_hashes:
|
||||
warnings.warn(f'Did a C extension fail to compile? {error}')
|
||||
+ except ImportError:
|
||||
+ if get_fips_mode() and module_name == '_blake2':
|
||||
+ # blake2b & blake2s disabled under FIPS
|
||||
+ return None
|
||||
+ else:
|
||||
+ raise
|
||||
return None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c
|
||||
index c2cac98..55b1677 100644
|
||||
--- a/Modules/_blake2/blake2b_impl.c
|
||||
+++ b/Modules/_blake2/blake2b_impl.c
|
||||
@@ -98,6 +98,8 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
||||
BLAKE2bObject *self = NULL;
|
||||
Py_buffer buf;
|
||||
|
||||
+ FAIL_RETURN_IN_FIPS_MODE(PyExc_ValueError, "_blake2");
|
||||
+
|
||||
self = new_BLAKE2bObject(type);
|
||||
if (self == NULL) {
|
||||
goto error;
|
||||
@@ -276,6 +278,8 @@ _blake2_blake2b_update(BLAKE2bObject *self, PyObject *data)
|
||||
{
|
||||
Py_buffer buf;
|
||||
|
||||
+ FAIL_RETURN_IN_FIPS_MODE(PyExc_ValueError, "_blake2");
|
||||
+
|
||||
GET_BUFFER_VIEW_OR_ERROUT(data, &buf);
|
||||
|
||||
if (self->lock == NULL && buf.len >= HASHLIB_GIL_MINSIZE)
|
||||
diff --git a/Modules/_blake2/blake2module.c b/Modules/_blake2/blake2module.c
|
||||
index 5df9fd3..10736c2 100644
|
||||
--- a/Modules/_blake2/blake2module.c
|
||||
+++ b/Modules/_blake2/blake2module.c
|
||||
@@ -13,6 +13,7 @@
|
||||
#endif
|
||||
|
||||
#include "Python.h"
|
||||
+#include "../hashlib.h"
|
||||
#include "blake2module.h"
|
||||
|
||||
extern PyType_Spec blake2b_type_spec;
|
||||
@@ -83,6 +84,7 @@ _blake2_free(void *module)
|
||||
static int
|
||||
blake2_exec(PyObject *m)
|
||||
{
|
||||
+
|
||||
Blake2State* st = blake2_get_state(m);
|
||||
|
||||
st->blake2b_type = (PyTypeObject *)PyType_FromModuleAndSpec(
|
||||
@@ -155,5 +157,6 @@ static struct PyModuleDef blake2_module = {
|
||||
PyMODINIT_FUNC
|
||||
PyInit__blake2(void)
|
||||
{
|
||||
+ FAIL_RETURN_IN_FIPS_MODE(PyExc_ImportError, "blake2");
|
||||
return PyModuleDef_Init(&blake2_module);
|
||||
-}
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c
|
||||
index 1c47328..cd4a202 100644
|
||||
--- a/Modules/_blake2/blake2s_impl.c
|
||||
+++ b/Modules/_blake2/blake2s_impl.c
|
||||
@@ -98,6 +98,8 @@ py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
||||
BLAKE2sObject *self = NULL;
|
||||
Py_buffer buf;
|
||||
|
||||
+ FAIL_RETURN_IN_FIPS_MODE(PyExc_ValueError, "_blake2");
|
||||
+
|
||||
self = new_BLAKE2sObject(type);
|
||||
if (self == NULL) {
|
||||
goto error;
|
||||
@@ -276,6 +278,8 @@ _blake2_blake2s_update(BLAKE2sObject *self, PyObject *data)
|
||||
{
|
||||
Py_buffer buf;
|
||||
|
||||
+ FAIL_RETURN_IN_FIPS_MODE(PyExc_ValueError, "_blake2");
|
||||
+
|
||||
GET_BUFFER_VIEW_OR_ERROUT(data, &buf);
|
||||
|
||||
if (self->lock == NULL && buf.len >= HASHLIB_GIL_MINSIZE)
|
||||
diff --git a/Modules/hashlib.h b/Modules/hashlib.h
|
||||
index a8bad9d..1b1d937 100644
|
||||
--- a/Modules/hashlib.h
|
||||
+++ b/Modules/hashlib.h
|
||||
@@ -1,5 +1,11 @@
|
||||
/* Common code for use by all hashlib related modules. */
|
||||
|
||||
+// RHEL: use OpenSSL to turn off unsupported modules under FIPS mode
|
||||
+// EVP_default_properties_is_fips_enabled() on OpenSSL >= 3.0.0
|
||||
+#include <openssl/evp.h>
|
||||
+// FIPS_mode() on OpenSSL < 3.0.0
|
||||
+#include <openssl/crypto.h>
|
||||
+
|
||||
/*
|
||||
* Given a PyObject* obj, fill in the Py_buffer* viewp with the result
|
||||
* of PyObject_GetBuffer. Sets an exception and issues the erraction
|
||||
@@ -64,3 +70,20 @@
|
||||
* to allow the user to optimize based on the platform they're using. */
|
||||
#define HASHLIB_GIL_MINSIZE 2048
|
||||
|
||||
+__attribute__((__unused__))
|
||||
+static int
|
||||
+_Py_hashlib_fips_error(PyObject *exc, char *name) {
|
||||
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
+ if (EVP_default_properties_is_fips_enabled(NULL)) {
|
||||
+#else
|
||||
+ if (FIPS_mode()) {
|
||||
+#endif
|
||||
+ PyErr_Format(exc, "%s is not available in FIPS mode", name);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#define FAIL_RETURN_IN_FIPS_MODE(exc, name) do { \
|
||||
+ if (_Py_hashlib_fips_error(exc, name)) return NULL; \
|
||||
+} while (0)
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 384718d..c4a1198 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -7445,7 +7445,8 @@ PY_STDLIB_MOD([_sha2],
|
||||
PY_STDLIB_MOD([_sha3], [test "$with_builtin_sha3" = yes])
|
||||
PY_STDLIB_MOD([_blake2],
|
||||
[test "$with_builtin_blake2" = yes], [],
|
||||
- [$LIBB2_CFLAGS], [$LIBB2_LIBS])
|
||||
+ [$LIBB2_CFLAGS $OPENSSL_INCLUDES],
|
||||
+ [$LIBB2_LIBS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS])
|
||||
|
||||
PY_STDLIB_MOD([_crypt],
|
||||
[], [test "$ac_cv_crypt_crypt" = yes],
|
||||
--
|
||||
2.45.0
|
||||
|
||||
|
||||
From e58b32f238f1d4503248f3a8b1489f7567bdbd6d Mon Sep 17 00:00:00 2001
|
||||
From: Charalampos Stratakis <cstratak@redhat.com>
|
||||
Date: Fri, 29 Jan 2021 14:16:21 +0100
|
||||
Subject: [PATCH 3/5] Use python's fall back crypto implementations only if we
|
||||
are not in FIPS mode
|
||||
|
||||
---
|
||||
Lib/hashlib.py | 8 +++++---
|
||||
Lib/test/test_hashlib.py | 22 +++++++++++++++++++++-
|
||||
2 files changed, 26 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
|
||||
index 9897402..159215a 100644
|
||||
--- a/Lib/hashlib.py
|
||||
+++ b/Lib/hashlib.py
|
||||
@@ -83,6 +83,8 @@ else:
|
||||
|
||||
|
||||
def __get_builtin_constructor(name):
|
||||
+ if _hashlib.get_fips_mode():
|
||||
+ raise ValueError('unsupported hash type ' + name + '(in FIPS mode)')
|
||||
cache = __builtin_constructor_cache
|
||||
constructor = cache.get(name)
|
||||
if constructor is not None:
|
||||
@@ -178,21 +180,21 @@ try:
|
||||
except ImportError:
|
||||
_hashlib = None
|
||||
new = __py_new
|
||||
- __get_hash = __get_builtin_constructor
|
||||
+ raise # importing _hashlib should never fail on RHEL
|
||||
|
||||
try:
|
||||
# OpenSSL's PKCS5_PBKDF2_HMAC requires OpenSSL 1.0+ with HMAC and SHA
|
||||
from _hashlib import pbkdf2_hmac
|
||||
__all__ += ('pbkdf2_hmac',)
|
||||
except ImportError:
|
||||
- pass
|
||||
+ raise # importing _hashlib should never fail on RHEL
|
||||
|
||||
|
||||
try:
|
||||
# OpenSSL's scrypt requires OpenSSL 1.1+
|
||||
from _hashlib import scrypt
|
||||
except ImportError:
|
||||
- pass
|
||||
+ raise # importing _hashlib should never fail on RHEL
|
||||
|
||||
|
||||
def file_digest(fileobj, digest, /, *, _bufsize=2**18):
|
||||
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
|
||||
index dd61a9a..6031b02 100644
|
||||
--- a/Lib/test/test_hashlib.py
|
||||
+++ b/Lib/test/test_hashlib.py
|
||||
@@ -167,7 +167,13 @@ class HashLibTestCase(unittest.TestCase):
|
||||
constructors.add(constructor)
|
||||
|
||||
def add_builtin_constructor(name):
|
||||
- constructor = getattr(hashlib, "__get_builtin_constructor")(name)
|
||||
+ try:
|
||||
+ constructor = getattr(hashlib, "__get_builtin_constructor")(name)
|
||||
+ except ValueError:
|
||||
+ if get_fips_mode():
|
||||
+ return
|
||||
+ else:
|
||||
+ raise
|
||||
self.constructors_to_test[name].add(constructor)
|
||||
|
||||
_md5 = self._conditional_import_module('_md5')
|
||||
@@ -260,6 +266,20 @@ class HashLibTestCase(unittest.TestCase):
|
||||
def test_new_upper_to_lower(self):
|
||||
self.assertEqual(hashlib.new("SHA256").name, "sha256")
|
||||
|
||||
+ @unittest.skipUnless(get_fips_mode(), "Builtin constructor only usable in FIPS mode")
|
||||
+ def test_get_builtin_constructor_fips(self):
|
||||
+ get_builtin_constructor = getattr(hashlib,
|
||||
+ '__get_builtin_constructor')
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ get_builtin_constructor('md5')
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ get_builtin_constructor('sha256')
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ get_builtin_constructor('blake2s')
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ get_builtin_constructor('test')
|
||||
+
|
||||
+ @unittest.skipIf(get_fips_mode(), "No builtin constructors in FIPS mode")
|
||||
def test_get_builtin_constructor(self):
|
||||
get_builtin_constructor = getattr(hashlib,
|
||||
'__get_builtin_constructor')
|
||||
--
|
||||
2.45.0
|
||||
|
||||
|
||||
From 2b14d347948dc01af587b9e21cd448833a38c7b5 Mon Sep 17 00:00:00 2001
|
||||
From: Charalampos Stratakis <cstratak@redhat.com>
|
||||
Date: Wed, 31 Jul 2019 15:43:43 +0200
|
||||
Subject: [PATCH 4/5] Test equivalence of hashes for the various digests with
|
||||
usedforsecurity=True/False
|
||||
|
||||
---
|
||||
Lib/test/test_fips.py | 24 ++++++++++++++++++++
|
||||
Lib/test/test_hashlib.py | 47 ++++++++++++++++++++++++++++++----------
|
||||
2 files changed, 60 insertions(+), 11 deletions(-)
|
||||
create mode 100644 Lib/test/test_fips.py
|
||||
|
||||
diff --git a/Lib/test/test_fips.py b/Lib/test/test_fips.py
|
||||
new file mode 100644
|
||||
index 0000000..1f99dd7
|
||||
--- /dev/null
|
||||
+++ b/Lib/test/test_fips.py
|
||||
@@ -0,0 +1,24 @@
|
||||
+import unittest
|
||||
+import hashlib, _hashlib
|
||||
+
|
||||
+
|
||||
+
|
||||
+class HashlibFipsTests(unittest.TestCase):
|
||||
+
|
||||
+ @unittest.skipUnless(_hashlib.get_fips_mode(), "Test only when FIPS is enabled")
|
||||
+ def test_fips_imports(self):
|
||||
+ """blake2s and blake2b should fail to import in FIPS mode
|
||||
+ """
|
||||
+ with self.assertRaises(ValueError, msg='blake2s not available in FIPS'):
|
||||
+ m = hashlib.blake2s()
|
||||
+ with self.assertRaises(ValueError, msg='blake2b not available in FIPS'):
|
||||
+ m = hashlib.blake2b()
|
||||
+
|
||||
+ @unittest.skipIf(_hashlib.get_fips_mode(), "blake2 hashes are not available under FIPS")
|
||||
+ def test_blake2_hashes(self):
|
||||
+ self.assertEqual(hashlib.blake2b(b'abc').hexdigest(), _hashlib.openssl_blake2b(b'abc').hexdigest())
|
||||
+ self.assertEqual(hashlib.blake2s(b'abc').hexdigest(), _hashlib.openssl_blake2s(b'abc').hexdigest())
|
||||
+
|
||||
+
|
||||
+if __name__ == "__main__":
|
||||
+ unittest.main()
|
||||
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
|
||||
index 6031b02..5bd5297 100644
|
||||
--- a/Lib/test/test_hashlib.py
|
||||
+++ b/Lib/test/test_hashlib.py
|
||||
@@ -23,6 +23,7 @@ from test.support import os_helper
|
||||
from test.support import requires_resource
|
||||
from test.support import threading_helper
|
||||
from http.client import HTTPException
|
||||
+from functools import partial
|
||||
|
||||
|
||||
default_builtin_hashes = {'md5', 'sha1', 'sha256', 'sha512', 'sha3', 'blake2'}
|
||||
@@ -55,6 +56,11 @@ except ImportError:
|
||||
def get_fips_mode():
|
||||
return 0
|
||||
|
||||
+if get_fips_mode():
|
||||
+ FIPS_DISABLED = {'md5'}
|
||||
+else:
|
||||
+ FIPS_DISABLED = set()
|
||||
+
|
||||
try:
|
||||
import _blake2
|
||||
except ImportError:
|
||||
@@ -94,6 +100,11 @@ def read_vectors(hash_name):
|
||||
parts[0] = bytes.fromhex(parts[0])
|
||||
yield parts
|
||||
|
||||
+def _is_blake2_constructor(constructor):
|
||||
+ if isinstance(constructor, partial):
|
||||
+ constructor = constructor.func
|
||||
+ return getattr(constructor, '__name__', '').startswith('openssl_blake2')
|
||||
+
|
||||
|
||||
class HashLibTestCase(unittest.TestCase):
|
||||
supported_hash_names = ( 'md5', 'MD5', 'sha1', 'SHA1',
|
||||
@@ -138,15 +149,21 @@ class HashLibTestCase(unittest.TestCase):
|
||||
continue
|
||||
self.constructors_to_test[algorithm] = set()
|
||||
|
||||
+ def _add_constructor(algorithm, constructor):
|
||||
+ constructors.add(partial(constructor, usedforsecurity=False))
|
||||
+ if algorithm not in FIPS_DISABLED:
|
||||
+ constructors.add(constructor)
|
||||
+ constructors.add(partial(constructor, usedforsecurity=True))
|
||||
+
|
||||
# For each algorithm, test the direct constructor and the use
|
||||
# of hashlib.new given the algorithm name.
|
||||
for algorithm, constructors in self.constructors_to_test.items():
|
||||
- constructors.add(getattr(hashlib, algorithm))
|
||||
+ _add_constructor(algorithm, getattr(hashlib, algorithm))
|
||||
def _test_algorithm_via_hashlib_new(data=None, _alg=algorithm, **kwargs):
|
||||
if data is None:
|
||||
return hashlib.new(_alg, **kwargs)
|
||||
return hashlib.new(_alg, data, **kwargs)
|
||||
- constructors.add(_test_algorithm_via_hashlib_new)
|
||||
+ _add_constructor(algorithm, _test_algorithm_via_hashlib_new)
|
||||
|
||||
_hashlib = self._conditional_import_module('_hashlib')
|
||||
self._hashlib = _hashlib
|
||||
@@ -158,13 +175,7 @@ class HashLibTestCase(unittest.TestCase):
|
||||
for algorithm, constructors in self.constructors_to_test.items():
|
||||
constructor = getattr(_hashlib, 'openssl_'+algorithm, None)
|
||||
if constructor:
|
||||
- try:
|
||||
- constructor()
|
||||
- except ValueError:
|
||||
- # default constructor blocked by crypto policy
|
||||
- pass
|
||||
- else:
|
||||
- constructors.add(constructor)
|
||||
+ _add_constructor(algorithm, constructor)
|
||||
|
||||
def add_builtin_constructor(name):
|
||||
try:
|
||||
@@ -340,6 +351,8 @@ class HashLibTestCase(unittest.TestCase):
|
||||
self.assertIn(h.name, self.supported_hash_names)
|
||||
else:
|
||||
self.assertNotIn(h.name, self.supported_hash_names)
|
||||
+ if not h.name.startswith('blake2') and h.name not in FIPS_DISABLED:
|
||||
+ self.assertEqual(h.name, hashlib.new(h.name).name)
|
||||
self.assertEqual(
|
||||
h.name,
|
||||
hashlib.new(h.name, usedforsecurity=False).name
|
||||
@@ -404,8 +417,10 @@ class HashLibTestCase(unittest.TestCase):
|
||||
for hash_object_constructor in constructors:
|
||||
|
||||
# OpenSSL's blake2s & blake2d don't support `key`
|
||||
- _name = hash_object_constructor.__name__
|
||||
- if 'key' in kwargs and _name.startswith('openssl_blake2'):
|
||||
+ if (
|
||||
+ 'key' in kwargs
|
||||
+ and _is_blake2_constructor(hash_object_constructor)
|
||||
+ ):
|
||||
return
|
||||
|
||||
m = hash_object_constructor(data, **kwargs)
|
||||
@@ -1036,6 +1051,16 @@ class HashLibTestCase(unittest.TestCase):
|
||||
with self.assertRaisesRegex(TypeError, "immutable type"):
|
||||
hash_type.value = False
|
||||
|
||||
+ @unittest.skipUnless(get_fips_mode(), 'Needs FIPS mode.')
|
||||
+ def test_usedforsecurity_repeat(self):
|
||||
+ """Make sure usedforsecurity flag isn't copied to other contexts"""
|
||||
+ for i in range(3):
|
||||
+ for cons in hashlib.md5, partial(hashlib.new, 'md5'):
|
||||
+ self.assertRaises(ValueError, cons)
|
||||
+ self.assertRaises(ValueError, partial(cons, usedforsecurity=True))
|
||||
+ self.assertEqual(cons(usedforsecurity=False).hexdigest(),
|
||||
+ 'd41d8cd98f00b204e9800998ecf8427e')
|
||||
+
|
||||
|
||||
class KDFTests(unittest.TestCase):
|
||||
|
||||
--
|
||||
2.45.0
|
||||
|
||||
|
||||
From b98c72b356a529a68cb4216526b838a57937cf6f Mon Sep 17 00:00:00 2001
|
||||
From: Petr Viktorin <pviktori@redhat.com>
|
||||
Date: Mon, 26 Aug 2019 19:39:48 +0200
|
||||
Subject: [PATCH 5/5] Guard against Python HMAC in FIPS mode
|
||||
|
||||
---
|
||||
Lib/hmac.py | 12 +++++++++---
|
||||
Lib/test/test_hmac.py | 10 ++++++++++
|
||||
2 files changed, 19 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/Lib/hmac.py b/Lib/hmac.py
|
||||
index 8b4eb2f..8930bda 100644
|
||||
--- a/Lib/hmac.py
|
||||
+++ b/Lib/hmac.py
|
||||
@@ -16,8 +16,9 @@ else:
|
||||
|
||||
import hashlib as _hashlib
|
||||
|
||||
-trans_5C = bytes((x ^ 0x5C) for x in range(256))
|
||||
-trans_36 = bytes((x ^ 0x36) for x in range(256))
|
||||
+if not _hashopenssl.get_fips_mode():
|
||||
+ trans_5C = bytes((x ^ 0x5C) for x in range(256))
|
||||
+ trans_36 = bytes((x ^ 0x36) for x in range(256))
|
||||
|
||||
# The size of the digests returned by HMAC depends on the underlying
|
||||
# hashing module used. Use digest_size from the instance of HMAC instead.
|
||||
@@ -55,10 +56,12 @@ class HMAC:
|
||||
if not digestmod:
|
||||
raise TypeError("Missing required argument 'digestmod'.")
|
||||
|
||||
- if _hashopenssl and isinstance(digestmod, (str, _functype)):
|
||||
+ if _hashopenssl.get_fips_mode() or (_hashopenssl and isinstance(digestmod, (str, _functype))):
|
||||
try:
|
||||
self._init_hmac(key, msg, digestmod)
|
||||
except _hashopenssl.UnsupportedDigestmodError:
|
||||
+ if _hashopenssl.get_fips_mode():
|
||||
+ raise
|
||||
self._init_old(key, msg, digestmod)
|
||||
else:
|
||||
self._init_old(key, msg, digestmod)
|
||||
@@ -69,6 +72,9 @@ class HMAC:
|
||||
self.block_size = self._hmac.block_size
|
||||
|
||||
def _init_old(self, key, msg, digestmod):
|
||||
+ if _hashopenssl.get_fips_mode():
|
||||
+ # In FIPS mode, use OpenSSL anyway: raise the appropriate error
|
||||
+ return self._init_hmac(key, msg, digestmod)
|
||||
if callable(digestmod):
|
||||
digest_cons = digestmod
|
||||
elif isinstance(digestmod, str):
|
||||
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
|
||||
index a39a2c4..b7b24ab 100644
|
||||
--- a/Lib/test/test_hmac.py
|
||||
+++ b/Lib/test/test_hmac.py
|
||||
@@ -5,6 +5,7 @@ import hashlib
|
||||
import unittest
|
||||
import unittest.mock
|
||||
import warnings
|
||||
+from _hashlib import get_fips_mode
|
||||
|
||||
from test.support import hashlib_helper, check_disallow_instantiation
|
||||
|
||||
@@ -351,6 +352,11 @@ class TestVectorsTestCase(unittest.TestCase):
|
||||
def digest(self):
|
||||
return self._x.digest()
|
||||
|
||||
+ if get_fips_mode():
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash)
|
||||
+ return
|
||||
+
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('error', RuntimeWarning)
|
||||
with self.assertRaises(RuntimeWarning):
|
||||
@@ -373,6 +379,7 @@ class TestVectorsTestCase(unittest.TestCase):
|
||||
with self.assertRaisesRegex(TypeError, r'required.*digestmod'):
|
||||
hmac.HMAC(key, msg=data, digestmod='')
|
||||
|
||||
+ @unittest.skipIf(get_fips_mode(), "No builtin constructors in FIPS mode")
|
||||
def test_with_fallback(self):
|
||||
cache = getattr(hashlib, '__builtin_constructor_cache')
|
||||
try:
|
||||
@@ -453,6 +460,7 @@ class ConstructorTestCase(unittest.TestCase):
|
||||
with self.assertRaisesRegex(TypeError, "immutable type"):
|
||||
C_HMAC.value = None
|
||||
|
||||
+ @unittest.skipIf(get_fips_mode(), "_sha256 unavailable in FIPS mode")
|
||||
@unittest.skipUnless(sha256_module is not None, 'need _sha256')
|
||||
def test_with_sha256_module(self):
|
||||
h = hmac.HMAC(b"key", b"hash this!", digestmod=sha256_module.sha256)
|
||||
@@ -481,6 +489,7 @@ class SanityTestCase(unittest.TestCase):
|
||||
|
||||
class CopyTestCase(unittest.TestCase):
|
||||
|
||||
+ @unittest.skipIf(get_fips_mode(), "_init_old unavailable in FIPS mode")
|
||||
@hashlib_helper.requires_hashdigest('sha256')
|
||||
def test_attributes_old(self):
|
||||
# Testing if attributes are of same type.
|
||||
@@ -492,6 +501,7 @@ class CopyTestCase(unittest.TestCase):
|
||||
self.assertEqual(type(h1._outer), type(h2._outer),
|
||||
"Types of outer don't match.")
|
||||
|
||||
+ @unittest.skipIf(get_fips_mode(), "_init_old unavailable in FIPS mode")
|
||||
@hashlib_helper.requires_hashdigest('sha256')
|
||||
def test_realcopy_old(self):
|
||||
# Testing if the copy method created a real copy.
|
||||
--
|
||||
2.45.0
|
||||
|
@ -0,0 +1,103 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <thrnciar@redhat.com>
|
||||
Date: Tue, 25 Oct 2022 12:02:33 +0200
|
||||
Subject: [PATCH] 00371: Revert "bpo-1596321: Fix threading._shutdown() for the
|
||||
main thread (GH-28549) (GH-28589)"
|
||||
|
||||
This reverts commit 38c67738c64304928c68d5c2bd78bbb01d979b94. It
|
||||
introduced regression causing FreeIPA's tests to fail.
|
||||
|
||||
For more info see:
|
||||
https://bodhi.fedoraproject.org/updates/FEDORA-2021-e152ce5f31
|
||||
https://github.com/GrahamDumpleton/mod_wsgi/issues/730
|
||||
---
|
||||
Lib/test/test_threading.py | 33 ---------------------------------
|
||||
Lib/threading.py | 25 ++++++++-----------------
|
||||
2 files changed, 8 insertions(+), 50 deletions(-)
|
||||
|
||||
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
|
||||
index 2e4b860b97..3066b23ee1 100644
|
||||
--- a/Lib/test/test_threading.py
|
||||
+++ b/Lib/test/test_threading.py
|
||||
@@ -1100,39 +1100,6 @@ def noop(): pass
|
||||
threading.Thread(target=noop).start()
|
||||
# Thread.join() is not called
|
||||
|
||||
- def test_import_from_another_thread(self):
|
||||
- # bpo-1596321: If the threading module is first import from a thread
|
||||
- # different than the main thread, threading._shutdown() must handle
|
||||
- # this case without logging an error at Python exit.
|
||||
- code = textwrap.dedent('''
|
||||
- import _thread
|
||||
- import sys
|
||||
-
|
||||
- event = _thread.allocate_lock()
|
||||
- event.acquire()
|
||||
-
|
||||
- def import_threading():
|
||||
- import threading
|
||||
- event.release()
|
||||
-
|
||||
- if 'threading' in sys.modules:
|
||||
- raise Exception('threading is already imported')
|
||||
-
|
||||
- _thread.start_new_thread(import_threading, ())
|
||||
-
|
||||
- # wait until the threading module is imported
|
||||
- event.acquire()
|
||||
- event.release()
|
||||
-
|
||||
- if 'threading' not in sys.modules:
|
||||
- raise Exception('threading is not imported')
|
||||
-
|
||||
- # don't wait until the thread completes
|
||||
- ''')
|
||||
- rc, out, err = assert_python_ok("-c", code)
|
||||
- self.assertEqual(out, b'')
|
||||
- self.assertEqual(err, b'')
|
||||
-
|
||||
def test_start_new_thread_at_finalization(self):
|
||||
code = """if 1:
|
||||
import _thread
|
||||
diff --git a/Lib/threading.py b/Lib/threading.py
|
||||
index 0bba85d08a..b256e3273f 100644
|
||||
--- a/Lib/threading.py
|
||||
+++ b/Lib/threading.py
|
||||
@@ -1587,29 +1587,20 @@ def _shutdown():
|
||||
|
||||
global _SHUTTING_DOWN
|
||||
_SHUTTING_DOWN = True
|
||||
+ # Main thread
|
||||
+ tlock = _main_thread._tstate_lock
|
||||
+ # The main thread isn't finished yet, so its thread state lock can't have
|
||||
+ # been released.
|
||||
+ assert tlock is not None
|
||||
+ assert tlock.locked()
|
||||
+ tlock.release()
|
||||
+ _main_thread._stop()
|
||||
|
||||
# Call registered threading atexit functions before threads are joined.
|
||||
# Order is reversed, similar to atexit.
|
||||
for atexit_call in reversed(_threading_atexits):
|
||||
atexit_call()
|
||||
|
||||
- # Main thread
|
||||
- if _main_thread.ident == get_ident():
|
||||
- tlock = _main_thread._tstate_lock
|
||||
- # The main thread isn't finished yet, so its thread state lock can't
|
||||
- # have been released.
|
||||
- assert tlock is not None
|
||||
- assert tlock.locked()
|
||||
- tlock.release()
|
||||
- _main_thread._stop()
|
||||
- else:
|
||||
- # bpo-1596321: _shutdown() must be called in the main thread.
|
||||
- # If the threading module was not imported by the main thread,
|
||||
- # _main_thread is the thread which imported the threading module.
|
||||
- # In this case, ignore _main_thread, similar behavior than for threads
|
||||
- # spawned by C libraries or using _thread.start_new_thread().
|
||||
- pass
|
||||
-
|
||||
# Join all non-deamon threads
|
||||
while True:
|
||||
with _shutdown_locks_lock:
|
@ -0,0 +1,286 @@
|
||||
From ddd8064257a1916726b784d43f18e889ea1634f7 Mon Sep 17 00:00:00 2001
|
||||
From: Petr Viktorin <encukou@gmail.com>
|
||||
Date: Tue, 2 Jul 2024 11:40:37 +0200
|
||||
Subject: [PATCH] CVE-2007-4559, PEP-706: Add filters for tarfile extraction
|
||||
(downstream)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Add and test RHEL-specific ways of configuring the default behavior: environment
|
||||
variable and config file.
|
||||
|
||||
Co-Authored-By: Tomáš Hrnčiar <thrnciar@redhat.com>
|
||||
---
|
||||
Lib/tarfile.py | 47 +++++++++++--
|
||||
Lib/test/test_shutil.py | 2 +-
|
||||
Lib/test/test_tarfile.py | 147 +++++++++++++++++++++++++++++++++++++--
|
||||
3 files changed, 185 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
|
||||
index e1487e3..89b6843 100755
|
||||
--- a/Lib/tarfile.py
|
||||
+++ b/Lib/tarfile.py
|
||||
@@ -71,6 +71,13 @@ __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError", "ReadError",
|
||||
"OutsideDestinationError", "SpecialFileError", "AbsolutePathError",
|
||||
"LinkOutsideDestinationError"]
|
||||
|
||||
+# If true, use the safer (but backwards-incompatible) 'tar' extraction filter,
|
||||
+# rather than 'fully_trusted', by default.
|
||||
+# The emitted warning is changed to match.
|
||||
+_RH_SAFER_DEFAULT = True
|
||||
+
|
||||
+# System-wide configuration file
|
||||
+_CONFIG_FILENAME = '/etc/python/tarfile.cfg'
|
||||
|
||||
#---------------------------------------------------------
|
||||
# tar constants
|
||||
@@ -2218,11 +2225,41 @@ class TarFile(object):
|
||||
if filter is None:
|
||||
filter = self.extraction_filter
|
||||
if filter is None:
|
||||
- warnings.warn(
|
||||
- 'Python 3.14 will, by default, filter extracted tar '
|
||||
- + 'archives and reject files or modify their metadata. '
|
||||
- + 'Use the filter argument to control this behavior.',
|
||||
- DeprecationWarning, stacklevel=3)
|
||||
+ name = os.environ.get('PYTHON_TARFILE_EXTRACTION_FILTER')
|
||||
+ if name is None:
|
||||
+ try:
|
||||
+ file = bltn_open(_CONFIG_FILENAME)
|
||||
+ except FileNotFoundError:
|
||||
+ pass
|
||||
+ else:
|
||||
+ import configparser
|
||||
+ conf = configparser.ConfigParser(
|
||||
+ interpolation=None,
|
||||
+ comment_prefixes=('#', ),
|
||||
+ )
|
||||
+ with file:
|
||||
+ conf.read_file(file)
|
||||
+ name = conf.get('tarfile',
|
||||
+ 'PYTHON_TARFILE_EXTRACTION_FILTER',
|
||||
+ fallback='')
|
||||
+ if name:
|
||||
+ try:
|
||||
+ filter = _NAMED_FILTERS[name]
|
||||
+ except KeyError:
|
||||
+ raise ValueError(f"filter {filter!r} not found") from None
|
||||
+ self.extraction_filter = filter
|
||||
+ return filter
|
||||
+ if _RH_SAFER_DEFAULT:
|
||||
+ warnings.warn(
|
||||
+ 'The default behavior of tarfile extraction has been '
|
||||
+ + 'changed to disallow common exploits '
|
||||
+ + '(including CVE-2007-4559). '
|
||||
+ + 'By default, absolute/parent paths are disallowed '
|
||||
+ + 'and some mode bits are cleared. '
|
||||
+ + 'See https://access.redhat.com/articles/7004769 '
|
||||
+ + 'for more details.',
|
||||
+ RuntimeWarning, stacklevel=3)
|
||||
+ return tar_filter
|
||||
return fully_trusted_filter
|
||||
if isinstance(filter, str):
|
||||
raise TypeError(
|
||||
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
|
||||
index 7bc5d12..88b4bdb 100644
|
||||
--- a/Lib/test/test_shutil.py
|
||||
+++ b/Lib/test/test_shutil.py
|
||||
@@ -2096,7 +2096,7 @@ class TestArchives(BaseTest, unittest.TestCase):
|
||||
self.check_unpack_archive(format, filter='fully_trusted')
|
||||
self.check_unpack_archive(format, filter='data')
|
||||
with warnings_helper.check_warnings(
|
||||
- ('Python 3.14', DeprecationWarning)):
|
||||
+ ('.*CVE-2007-4559', RuntimeWarning)):
|
||||
self.check_unpack_archive(format)
|
||||
|
||||
def test_unpack_archive_tar(self):
|
||||
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
|
||||
index 3fbd25e..9aa727e 100644
|
||||
--- a/Lib/test/test_tarfile.py
|
||||
+++ b/Lib/test/test_tarfile.py
|
||||
@@ -727,7 +727,17 @@ class MiscReadTestBase(CommonReadTest):
|
||||
tarfile.open(tarname, encoding="iso8859-1") as tar
|
||||
):
|
||||
directories = [t for t in tar if t.isdir()]
|
||||
- with self.assertWarnsRegex(DeprecationWarning, "Use the filter argument") as cm:
|
||||
+ with self.assertWarnsRegex(
|
||||
+ RuntimeWarning,
|
||||
+ re.escape(
|
||||
+ 'The default behavior of tarfile extraction has been '
|
||||
+ 'changed to disallow common exploits '
|
||||
+ '(including CVE-2007-4559). '
|
||||
+ 'By default, absolute/parent paths are disallowed '
|
||||
+ 'and some mode bits are cleared. '
|
||||
+ 'See https://access.redhat.com/articles/7004769 '
|
||||
+ 'for more details.'
|
||||
+ )) as cm:
|
||||
tar.extractall(DIR, directories)
|
||||
# check that the stacklevel of the deprecation warning is correct:
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
@@ -740,7 +750,17 @@ class MiscReadTestBase(CommonReadTest):
|
||||
tarfile.open(tarname, encoding="iso8859-1") as tar
|
||||
):
|
||||
tarinfo = tar.getmember(dirtype)
|
||||
- with self.assertWarnsRegex(DeprecationWarning, "Use the filter argument") as cm:
|
||||
+ with self.assertWarnsRegex(
|
||||
+ RuntimeWarning,
|
||||
+ re.escape(
|
||||
+ 'The default behavior of tarfile extraction has been '
|
||||
+ 'changed to disallow common exploits '
|
||||
+ '(including CVE-2007-4559). '
|
||||
+ 'By default, absolute/parent paths are disallowed '
|
||||
+ 'and some mode bits are cleared. '
|
||||
+ 'See https://access.redhat.com/articles/7004769 '
|
||||
+ 'for more details.'
|
||||
+ )) as cm:
|
||||
tar.extract(tarinfo, path=DIR)
|
||||
# check that the stacklevel of the deprecation warning is correct:
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
@@ -3144,8 +3164,8 @@ class NoneInfoExtractTests(ReadTest):
|
||||
tar.errorlevel = 0
|
||||
with ExitStack() as cm:
|
||||
if cls.extraction_filter is None:
|
||||
- cm.enter_context(warnings.catch_warnings(
|
||||
- action="ignore", category=DeprecationWarning))
|
||||
+ cm.enter_context(warnings.catch_warnings())
|
||||
+ warnings.simplefilter(action="ignore", category=RuntimeWarning)
|
||||
tar.extractall(cls.control_dir, filter=cls.extraction_filter)
|
||||
tar.close()
|
||||
cls.control_paths = set(
|
||||
@@ -3966,7 +3986,7 @@ class TestExtractionFilters(unittest.TestCase):
|
||||
with ArchiveMaker() as arc:
|
||||
arc.add('foo')
|
||||
with warnings_helper.check_warnings(
|
||||
- ('Python 3.14', DeprecationWarning)):
|
||||
+ ('.*CVE-2007-4559', RuntimeWarning)):
|
||||
with self.check_context(arc.open(), None):
|
||||
self.expect_file('foo')
|
||||
|
||||
@@ -4136,6 +4156,123 @@ class TestExtractionFilters(unittest.TestCase):
|
||||
self.expect_exception(TypeError) # errorlevel is not int
|
||||
|
||||
|
||||
+ @contextmanager
|
||||
+ def rh_config_context(self, config_lines=None):
|
||||
+ """Set up for testing various ways of overriding the default filter
|
||||
+
|
||||
+ return a triple with:
|
||||
+ - temporary directory
|
||||
+ - EnvironmentVarGuard()
|
||||
+ - a test archive for use with check_* methods below
|
||||
+
|
||||
+ If config_lines is given, write them to the config file. Otherwise
|
||||
+ the config file is missing.
|
||||
+ """
|
||||
+ tempdir = pathlib.Path(TEMPDIR) / 'tmp'
|
||||
+ configfile = tempdir / 'tarfile.cfg'
|
||||
+ with ArchiveMaker() as arc:
|
||||
+ arc.add('good')
|
||||
+ arc.add('ugly', symlink_to='/etc/passwd')
|
||||
+ arc.add('../bad')
|
||||
+ with (
|
||||
+ os_helper.temp_dir(tempdir),
|
||||
+ support.swap_attr(tarfile, '_CONFIG_FILENAME', str(configfile)),
|
||||
+ os_helper.EnvironmentVarGuard() as env,
|
||||
+ arc.open() as tar,
|
||||
+ ):
|
||||
+ if config_lines is not None:
|
||||
+ with configfile.open('w') as f:
|
||||
+ for line in config_lines:
|
||||
+ print(line, file=f)
|
||||
+ yield tempdir, env, tar
|
||||
+
|
||||
+ def check_rh_default_behavior(self, tar, tempdir):
|
||||
+ """Check RH default: warn and refuse to extract dangerous files."""
|
||||
+ with (
|
||||
+ warnings_helper.check_warnings(
|
||||
+ ('.*CVE-2007-4559', RuntimeWarning)),
|
||||
+ self.assertRaises(tarfile.OutsideDestinationError),
|
||||
+ ):
|
||||
+ tar.extractall(tempdir / 'outdir')
|
||||
+
|
||||
+ def check_trusted_default(self, tar, tempdir):
|
||||
+ """Check 'fully_trusted' is configured as the default filter."""
|
||||
+ with (
|
||||
+ warnings_helper.check_no_warnings(self),
|
||||
+ ):
|
||||
+ tar.extractall(tempdir / 'outdir')
|
||||
+ self.assertTrue((tempdir / 'outdir/good').exists())
|
||||
+ self.assertEqual((tempdir / 'outdir/ugly').readlink(),
|
||||
+ pathlib.Path('/etc/passwd'))
|
||||
+ self.assertTrue((tempdir / 'bad').exists())
|
||||
+
|
||||
+ def test_rh_default_no_conf(self):
|
||||
+ with self.rh_config_context() as (tempdir, env, tar):
|
||||
+ self.check_rh_default_behavior(tar, tempdir)
|
||||
+
|
||||
+ def test_rh_default_from_file(self):
|
||||
+ lines = ['[tarfile]', 'PYTHON_TARFILE_EXTRACTION_FILTER=fully_trusted']
|
||||
+ with self.rh_config_context(lines) as (tempdir, env, tar):
|
||||
+ self.check_trusted_default(tar, tempdir)
|
||||
+
|
||||
+ def test_rh_empty_config_file(self):
|
||||
+ """Empty config file -> default behavior"""
|
||||
+ lines = []
|
||||
+ with self.rh_config_context(lines) as (tempdir, env, tar):
|
||||
+ self.check_rh_default_behavior(tar, tempdir)
|
||||
+
|
||||
+ def test_empty_config_section(self):
|
||||
+ """Empty section in config file -> default behavior"""
|
||||
+ lines = ['[tarfile]']
|
||||
+ with self.rh_config_context(lines) as (tempdir, env, tar):
|
||||
+ self.check_rh_default_behavior(tar, tempdir)
|
||||
+
|
||||
+ def test_rh_default_empty_config_option(self):
|
||||
+ """Empty option value in config file -> default behavior"""
|
||||
+ lines = ['[tarfile]', 'PYTHON_TARFILE_EXTRACTION_FILTER=']
|
||||
+ with self.rh_config_context(lines) as (tempdir, env, tar):
|
||||
+ self.check_rh_default_behavior(tar, tempdir)
|
||||
+
|
||||
+ def test_bad_config_option(self):
|
||||
+ """Bad option value in config file -> ValueError"""
|
||||
+ lines = ['[tarfile]', 'PYTHON_TARFILE_EXTRACTION_FILTER=unknown!']
|
||||
+ with self.rh_config_context(lines) as (tempdir, env, tar):
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ tar.extractall(tempdir / 'outdir')
|
||||
+
|
||||
+ def test_default_from_envvar(self):
|
||||
+ with self.rh_config_context() as (tempdir, env, tar):
|
||||
+ env['PYTHON_TARFILE_EXTRACTION_FILTER'] = 'fully_trusted'
|
||||
+ self.check_trusted_default(tar, tempdir)
|
||||
+
|
||||
+ def test_empty_envvar(self):
|
||||
+ """Empty env variable -> default behavior"""
|
||||
+ with self.rh_config_context() as (tempdir, env, tar):
|
||||
+ env['PYTHON_TARFILE_EXTRACTION_FILTER'] = ''
|
||||
+ self.check_rh_default_behavior(tar, tempdir)
|
||||
+
|
||||
+ def test_bad_envvar(self):
|
||||
+ with self.rh_config_context() as (tempdir, env, tar):
|
||||
+ env['PYTHON_TARFILE_EXTRACTION_FILTER'] = 'unknown!'
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ tar.extractall(tempdir / 'outdir')
|
||||
+
|
||||
+ def test_envvar_overrides_file(self):
|
||||
+ lines = ['[tarfile]', 'PYTHON_TARFILE_EXTRACTION_FILTER=data']
|
||||
+ with self.rh_config_context(lines) as (tempdir, env, tar):
|
||||
+ env['PYTHON_TARFILE_EXTRACTION_FILTER'] = 'fully_trusted'
|
||||
+ self.check_trusted_default(tar, tempdir)
|
||||
+
|
||||
+ def test_monkeypatch_overrides_envvar(self):
|
||||
+ with self.rh_config_context(None) as (tempdir, env, tar):
|
||||
+ env['PYTHON_TARFILE_EXTRACTION_FILTER'] = 'data'
|
||||
+ with support.swap_attr(
|
||||
+ tarfile.TarFile, 'extraction_filter',
|
||||
+ staticmethod(tarfile.fully_trusted_filter)
|
||||
+ ):
|
||||
+ self.check_trusted_default(tar, tempdir)
|
||||
+
|
||||
+
|
||||
class OverwriteTests(archiver_tests.OverwriteTests, unittest.TestCase):
|
||||
testdir = os.path.join(TEMPDIR, "testoverwrite")
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
@ -0,0 +1,18 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQKTBAABCgB9FiEEcWlgX2LHUTVtBUomqCHmgOX6YwUFAmbbZv1fFIAAAAAALgAo
|
||||
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDcx
|
||||
Njk2MDVGNjJDNzUxMzU2RDA1NEEyNkE4MjFFNjgwRTVGQTYzMDUACgkQqCHmgOX6
|
||||
YwV51g//WpQjF/Rt19lgaWojZ3qDkvmTM2kpvfDGLe9Tkm1fWYzji4TLS3TnzGEp
|
||||
dw2K6ApqGX4aO9AKMBRdfiFyhaDp0ENlBzSspvyzVT4LsRxiWXqyJ1qZB9mui/S8
|
||||
k5pw2qygaS4gYEAOLrVEwmQ52pig1wMAouSmRuopVk5DGYUN6Wir7RZMrYynsd6P
|
||||
6HYqpZby2L1fKlcj2xYY44niuL5a+I8ucWN9qOBzRLCuzq20lVoII817vORjCqa7
|
||||
ZUMKrDXDlzHnISNqZyyX37/oi6a8UdNm0o8V9yDJLiBu9+Dy3OueoIguuzimk4hq
|
||||
ZnepBoCcr2YAxIsXvwl2qfQBOCjJ5WAZ/wzA/eQMo9Jn1TYRBwuMC1MmP0ylt7Me
|
||||
/pS57bGuulkfPv9pMto7qc2lNpotBmAsfGJAJMczeEmyo5tAXnJUBE94JRmiLaR/
|
||||
zwPmJB3O9uEQhEa8+cjx4+9bK6+YvAXkb9x92Wn70u+IaalPj8CRA7B45hy1KYHT
|
||||
5s/ndwFFWThxqxH61oqjPvlZW5PWBC83yi/KovhgDWNL2G9CTusKevMqX/LMUAKz
|
||||
M3mJU/24vUu9bJNxB2qsa3UeP8hbb6WN5LLQyxRsXPjVQ9iTeMWrQkz1mRGIK2Ec
|
||||
OFbYH2SGa/RELds6MZWzvZuXIefCoyuc51WsXnc4LFr2ZGv4dAI=
|
||||
=CK1W
|
||||
-----END PGP SIGNATURE-----
|
@ -0,0 +1,136 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQINBFUAInYBEACrmKcXagNRlo1VjznrJZMMUh0rxUn2iK2wy9H5qrCo4EgMYahZ
|
||||
ibBunSWB4RNeVQevzUm3eSyOixnt+BmGZbSYqKp8tJIXRRcnKhEtC62X+7NVMc7B
|
||||
9uPu/aJ3HNqXrsQwBJUzZxzLMLg6obCyarhhHAYbWmfaafU4yNk3J4dGNKoZtHvz
|
||||
bjnUtlsUAkCmuyt3MsUuSYz34BviRLSEZEKW6xNoyQmD9dUhQ5exBuTPjtmdTf+x
|
||||
gOKpBluRkJ4TADGlWf42lIkaI+8DYRj1R8eQdLFwS7sDTu/MMPceKU7nTWOoj8HF
|
||||
3xXRJ+bJbpOJXZFEzVKjXHKuMFkhKr562i0LD8pdl1+s+9LRovmAvGwggt04Drzb
|
||||
AK437QoyjPKiTnFlg4tOeIuN0Y+GGk2hXOdH7fNw79B9Tq5ENxth8NsnKVlz1zpF
|
||||
X+aV0zCvAjNWutAUpikqZT/ibpwmM+NJcz3pgzQOq+LfPFskyrv7zkVODEjH3SG3
|
||||
s4ROvyoWfLPWmX92kJMOkvzyQObZmU2zWJgJbjYRApZiTfbfnH1tE+wxH4ZR5dji
|
||||
FpEdUJn1yjpYp21Q10khIdsj6q9IvS3RDq0ygc5wfl5111byEsdP12y36lvPTclT
|
||||
33VHBR1vxr+js9d8FI4wwt/o+7TmAO39DYhLrtn+ZgyRgIBYY65lhEaUtwARAQAB
|
||||
tCJUaG9tYXMgV291dGVycyA8dGhvbWFzQHB5d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mjmWf7rOfmWHuxH/gbChXMDDfOMwgOYFXNXImsN
|
||||
PWPX3XA2DrhFrlNWzA8kxi9hXJrgAfkRcx/84oUAEQEAAYkCPAQYAQoAJgIbDBYh
|
||||
BHFpYF9ix1E1bQVKJqgh5oDl+mMFBQJg4GUPBQkVRkQZAAoJEKgh5oDl+mMFhIcP
|
||||
/j3tJamzKpJGJAwcsoneFtYfmZnLA4UosffaPlsLGRVL1buyRuj2dFBr2WU4NAld
|
||||
YrQPK4T+ciSpfogJ9Dk8s1eUMhZi7gxKmeOHUDyefPXIp7v3PSG4xcnfXjyEK9zC
|
||||
714qFsI9ERjTg7uaw6qmFv8Xht8O8TLGMgqDijQIgrH2oGd6tEdYyOOCOPQ7d6PB
|
||||
Sm5Sw53LlCWlW5I9bc0NCjbnwWjh7Z9UXtLffzZyxgxggSw0vfg5PuhcprZ2Rd3M
|
||||
wzJmALI2BB7eWW1x+M0hXmtdqj7Opmajh+UMrFjLtAlEZfslJwzV9NkAFxDYzRi2
|
||||
jvsmJx78vOPB1XhXgTvlEOvA7qEYDXFaZJHlBDmFU9JqytGZ6PtiQENuLHIe4hO6
|
||||
aHbhJA4I9EqoG1U1COQAwrsHreV6+fpcFn4lXbu+gWPyUzKiQMQd9kI3EEiayObU
|
||||
ro21OFHS7z131kKbMec/oc2RfADCvEwY8oay7o0S9aTqvPSQODs8nYkbZchNFoC+
|
||||
oF9n8pBMNzhYBsTk1OXleD1yMucsuywr5i0meyvu6oQ4+pdPYD6wh7JatJh0hayK
|
||||
y33GGsXd278J1Ek1p6MEFnGLc/zH+NZZLIU7Qn1oFU+gK4cVeaLX2g0/BLKcQ/AE
|
||||
mYIwnecLr8A+Y4mZVwwsnSHtfELtoGSsawN26bzKbnRs
|
||||
=t995
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
@ -0,0 +1,55 @@
|
||||
"""Checks if all *.pyc files have later mtime than their *.py files."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from importlib.util import cache_from_source
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
RPM_BUILD_ROOT = os.environ.get('RPM_BUILD_ROOT', '')
|
||||
|
||||
# ...cpython-3X.pyc
|
||||
# ...cpython-3X.opt-1.pyc
|
||||
# ...cpython-3X.opt-2.pyc
|
||||
LEVELS = (None, 1, 2)
|
||||
|
||||
# list of globs of test and other files that we expect not to have bytecode
|
||||
not_compiled = [
|
||||
'/usr/bin/*',
|
||||
'*/test/badsyntax_*.py',
|
||||
'*/tokenizedata/bad_coding.py',
|
||||
'*/tokenizedata/bad_coding2.py',
|
||||
'*/tokenizedata/badsyntax_*.py',
|
||||
'*/test_future_stmt/badsyntax_*.py',
|
||||
'*/test_lib2to3/data/*.py',
|
||||
'*/test_lib2to3/data/*/*.py',
|
||||
'*/test_lib2to3/data/*/*/*.py',
|
||||
'*.debug-gdb.py',
|
||||
]
|
||||
|
||||
|
||||
def bytecode_expected(path):
|
||||
path = Path(path[len(RPM_BUILD_ROOT):])
|
||||
for glob in not_compiled:
|
||||
if path.match(glob):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
failed = 0
|
||||
compiled = (path for path in sys.argv[1:] if bytecode_expected(path))
|
||||
for path in compiled:
|
||||
to_check = (cache_from_source(path, optimization=opt) for opt in LEVELS)
|
||||
f_mtime = os.path.getmtime(path)
|
||||
for pyc in to_check:
|
||||
c_mtime = os.path.getmtime(pyc)
|
||||
if c_mtime < f_mtime:
|
||||
print('Failed bytecompilation timestamps check: '
|
||||
f'Bytecode file {pyc} is older than source file {path}',
|
||||
file=sys.stderr)
|
||||
failed += 1
|
||||
|
||||
if failed:
|
||||
print(f'\n{failed} files failed bytecompilation timestamps check.',
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=IDLE 3
|
||||
Comment=Python 3 Integrated Development and Learning Environment
|
||||
Exec=idle3 %F
|
||||
TryExec=idle3
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon=idle3
|
||||
Categories=Development;IDE;
|
||||
MimeType=text/x-python;
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue