python: Backport patch: Do not use getentropy on Linux.
Backport upstream fix for glibc 2.24 for python 2.7.17.
Had to be modified from original patch for applying to
python 2.7.10 in Chrome OS.
Original patch details:
https://hg.python.org/cpython/rev/13a39142c047
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)
BUG=chromium:834385
BUG=chromium:902371
TEST=graphics_webGLAquarium passes on peach_pit with glibc 2.27
Change-Id: Ic9f57373a5b8867ba16dfefa5dba2227474c7922
Reviewed-on: https://chromium-review.googlesource.com/1318314
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
diff --git a/dev-lang/python/files/python-2.7.17-getentropy.patch b/dev-lang/python/files/python-2.7.17-getentropy.patch
new file mode 100644
index 0000000..1a60498
--- /dev/null
+++ b/dev-lang/python/files/python-2.7.17-getentropy.patch
@@ -0,0 +1,25 @@
+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
diff --git a/dev-lang/python/python-2.7.10-r4.ebuild b/dev-lang/python/python-2.7.10-r5.ebuild
similarity index 100%
rename from dev-lang/python/python-2.7.10-r4.ebuild
rename to dev-lang/python/python-2.7.10-r5.ebuild
diff --git a/dev-lang/python/python-2.7.10.ebuild b/dev-lang/python/python-2.7.10.ebuild
index c1b541d..01afd12 100644
--- a/dev-lang/python/python-2.7.10.ebuild
+++ b/dev-lang/python/python-2.7.10.ebuild
@@ -119,6 +119,7 @@
epatch "${FILESDIR}"/python-2.7.10-cross-distutils.patch
epatch "${FILESDIR}"/python-2.7.3-unique-semaphore-name.patch
epatch "${FILESDIR}"/python-2.7.10-ldshared.patch
+ epatch "${FILESDIR}"/python-2.7.17-getentropy.patch
epatch "${FILESDIR}"/2.7-disable-nis.patch
# Undo the @libdir@ change for portage's pym folder as it is always
# installed into /usr/lib/ and not the abi libdir.