blob: 1a6049858d0851b0e6f68a6805aece6044d32f24 [file] [log] [blame]
Don't use getentropy() on Linux
Issue #29188: Support glibc 2.24 on Linux: don't use getentropy() function but
read from /dev/urandom to get random bytes, for example in os.urandom(). On
Linux, getentropy() is implemented which getrandom() is blocking mode, whereas
os.urandom() should not block. [#29188]
author Victor Stinner <victor.stinner@gmail.com>
date Mon, 09 Jan 2017 11:10:41 +0100 (22 months ago)
Note: Patch is modfied from upstream to apply to
python 2.7.10.
diff --git a/Python/random.c b/Python/random.c
index d94f89a..c33fe07 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -333,7 +333,7 @@ _PyOS_URandom(void *buffer, Py_ssize_t size)
#ifdef MS_WINDOWS
return win32_urandom((unsigned char *)buffer, size, 1);
-#elif HAVE_GETENTROPY
+#elif HAVE_GETENTROPY && !defined(sun) && !defined(linux)
return py_getentropy(buffer, size, 0);
#else
# ifdef __VMS