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