sanqui / rpms / python2

Forked from rpms/python2 6 years ago
Clone

Blame 00250-getentropy.patch

aabe04e
diff --git a/Python/random.c b/Python/random.c
aabe04e
index 2f83b5d..4cae217 100644
aabe04e
--- a/Python/random.c
aabe04e
+++ b/Python/random.c
aabe04e
@@ -97,8 +97,15 @@ win32_urandom(unsigned char *buffer, Py_ssize_t size, int raise)
aabe04e
 }
aabe04e
 
aabe04e
 /* Issue #25003: Don't use getentropy() on Solaris (available since
aabe04e
- * Solaris 11.3), it is blocking whereas os.urandom() should not block. */
aabe04e
-#elif defined(HAVE_GETENTROPY) && !defined(sun)
aabe04e
+   Solaris 11.3), it is blocking whereas os.urandom() should not block.
aabe04e
+
aabe04e
+   Issue #29188: Don't use getentropy() on Linux since the glibc 2.24
aabe04e
+   implements it with the getrandom() syscall which can fail with ENOSYS,
aabe04e
+   and this error is not supported in py_getentropy() and getrandom() is called
aabe04e
+   with flags=0 which blocks until system urandom is initialized, which is not
aabe04e
+   the desired behaviour to seed the Python hash secret nor for os.urandom():
aabe04e
+   see the PEP 524 which was only implemented in Python 3.6. */
aabe04e
+#elif defined(HAVE_GETENTROPY) && !defined(sun) && !defined(linux)
aabe04e
 #define PY_GETENTROPY 1
aabe04e
 
aabe04e
 /* Fill buffer with size pseudo-random bytes generated by getentropy().