Browse code

Fixing python issue 29188, backport random.c from 3.5 to 2.7

Change-Id: I612beff8f9df63f718309a7fb0f4f7b124f2ba09
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/2698
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>

Kumar Kaushik authored on 2017/05/17 10:57:54
Showing 2 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,20 @@
0
+diff -r e908e90fb147 Python/random.c
1
+--- a/Python/random.c	Fri Jan 06 09:44:36 2017 +0100
2
+@@ -97,8 +97,14 @@ win32_urandom(unsigned char *buffer, Py_
3
+ }
4
+ 
5
+ /* Issue #25003: Don't use getentropy() on Solaris (available since
6
+- * Solaris 11.3), it is blocking whereas os.urandom() should not block. */
7
+-#elif defined(HAVE_GETENTROPY) && !defined(sun)
8
++   Solaris 11.3), it is blocking whereas os.urandom() should not block.
9
++   Issue #29188: Don't use getentropy() on Linux since the glibc 2.24
10
++   implements it with the getrandom() syscall which can fail with ENOSYS,
11
++   and this error is not supported in py_getentropy() and getrandom() is called
12
++   with flags=0 which blocks until system urandom is initialized, which is not
13
++   the desired behaviour to seed the Python hash secret nor for os.urandom():
14
++   see the PEP 524 which was only implemented in Python 3.6. */
15
++#elif defined(HAVE_GETENTROPY) && !defined(sun) && !defined(linux)
16
+ #define PY_GETENTROPY 1
17
+ 
18
+ /* Fill buffer with size pseudo-random bytes generated by getentropy().
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        A high-level scripting language
2 2
 Name:           python2
3 3
 Version:        2.7.13
4
-Release:        4%{?dist}
4
+Release:        5%{?dist}
5 5
 License:        PSF
6 6
 URL:            http://www.python.org/
7 7
 Group:          System Environment/Programming
... ...
@@ -13,6 +13,7 @@ Patch0:         cgi.patch
13 13
 Patch1:         added-compiler-flags-for-curses-module.patch
14 14
 Patch2:         added-pyopenssl-ipaddress-certificate-validation.patch
15 15
 Patch3:         python2-support-photon-platform.patch
16
+Patch4:         back-port-random-dot-c.patch
16 17
 BuildRequires:  pkg-config >= 0.28
17 18
 BuildRequires:  bzip2-devel
18 19
 BuildRequires:  openssl-devel
... ...
@@ -105,6 +106,7 @@ to build python programs.
105 105
 %patch1 -p1
106 106
 %patch2 -p1
107 107
 %patch3 -p1
108
+%patch4 -p1
108 109
 
109 110
 %build
110 111
 export OPT="${CFLAGS}"
... ...
@@ -220,8 +222,10 @@ rm -rf %{buildroot}/*
220 220
 %exclude %{_bindir}/idle*
221 221
 
222 222
 %changelog
223
-*	Fri Apr 28 2017 Harish Udaiya <hudaiyakumar@vmware.com> 2.7.13-4
224
--	Excluded unwanted binaries from python2-tools.
223
+*   Tue May 16 2017 Kumar Kaushik <kaushikk@vmware.com> 2.7.13-5
224
+-   Fixing python issue 29188, backport random.c from 3.5 to 2.7.
225
+*   Fri Apr 28 2017 Harish Udaiya <hudaiyakumar@vmware.com> 2.7.13-4
226
+-   Excluded unwanted binaries from python2-tools.
225 227
 *   Fri Apr 14 2017 Alexey Makhalov <amakhalov@vmware.com> 2.7.13-3
226 228
 -   Python2-devel requires expat-devel.
227 229
 *   Fri Mar 24 2017 Xiaolin Li <xiaolinl@vmware.com> 2.7.13-2