[lfs-patches] r3083 - trunk/Python

igor at higgs.linuxfromscratch.org igor at higgs.linuxfromscratch.org
Mon Dec 22 12:27:46 PST 2014


Author: igor
Date: Mon Dec 22 12:27:46 2014
New Revision: 3083

Log:
fix python build with libressl

Added:
   trunk/Python/Python-2.7.9-libressl-1.patch

Added: trunk/Python/Python-2.7.9-libressl-1.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/Python/Python-2.7.9-libressl-1.patch	Mon Dec 22 12:27:46 2014	(r3083)
@@ -0,0 +1,180 @@
+Submitted By:            Igor Živković <contact at igor-zivkovic.from.hr>
+Date:                    2014-12-22
+Initial Package Version: 2.7.9
+Upstream Status:         Submitted
+Origin:                  FreeBSD
+Description:             Fixes build with LibreSSL.
+
+diff -Naur Python-2.7.9.orig/configure Python-2.7.9/configure
+--- Python-2.7.9.orig/configure	2014-12-10 17:00:00.000000000 +0100
++++ Python-2.7.9/configure	2014-12-22 21:13:31.738951488 +0100
+@@ -8542,6 +8542,52 @@
+ fi
+ 	# Dynamic linking for HP-UX
+ 
++### Fix build with LibreSSL (does not have RAND_egd)
++### PR192511, http://bugs.python.org/issue21356
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAND_egd in -lcrypto" >&5
++$as_echo_n "checking for RAND_egd in -lcrypto... " >&6; }
++if ${ac_cv_lib_crypto_RAND_egd+:} false; then :
++  $as_echo_n "(cached) " >&6
++else
++  ac_check_lib_save_LIBS=$LIBS
++LIBS="-lcrypto  $LIBS"
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
++/* Override any GCC internal prototype to avoid an error.
++   Use char because int might match the return type of a GCC
++   builtin and then its argument prototype would still apply.  */
++#ifdef __cplusplus
++extern "C"
++#endif
++char RAND_egd ();
++int
++main ()
++{
++return RAND_egd ();
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++  ac_cv_lib_crypto_RAND_egd=yes
++else
++  ac_cv_lib_crypto_RAND_egd=no
++fi
++rm -f core conftest.err conftest.$ac_objext \
++    conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_RAND_egd" >&5
++$as_echo "$ac_cv_lib_crypto_RAND_egd" >&6; }
++if test "x$ac_cv_lib_crypto_RAND_egd" = xyes; then :
++
++$as_echo "#define HAVE_RAND_EGD 1" >>confdefs.h
++
++fi
++
++### End PR192511
++
+ # only check for sem_init if thread support is requested
+ if test "$with_threads" = "yes" -o -z "$with_threads"; then
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
+diff -Naur Python-2.7.9.orig/Lib/socket.py Python-2.7.9/Lib/socket.py
+--- Python-2.7.9.orig/Lib/socket.py	2014-12-10 16:59:40.000000000 +0100
++++ Python-2.7.9/Lib/socket.py	2014-12-22 21:13:31.738951488 +0100
+@@ -67,7 +67,6 @@
+     from _ssl import SSLError as sslerror
+     from _ssl import \
+          RAND_add, \
+-         RAND_egd, \
+          RAND_status, \
+          SSL_ERROR_ZERO_RETURN, \
+          SSL_ERROR_WANT_READ, \
+@@ -78,6 +77,14 @@
+          SSL_ERROR_WANT_CONNECT, \
+          SSL_ERROR_EOF, \
+          SSL_ERROR_INVALID_ERROR_CODE
++### Fix build with LibreSSL (does not have RAND_egd)
++### PR192511, http://bugs.python.org/issue21356
++    try:
++         from _ssl import RAND_egd
++         # LibreSSL does not provide RAND_egd
++    except ImportError:
++         pass
++### End PR192511
+ 
+ import os, sys, warnings
+ 
+diff -Naur Python-2.7.9.orig/Lib/ssl.py Python-2.7.9/Lib/ssl.py
+--- Python-2.7.9.orig/Lib/ssl.py	2014-12-10 16:59:40.000000000 +0100
++++ Python-2.7.9/Lib/ssl.py	2014-12-22 21:17:33.722926272 +0100
+@@ -106,7 +106,16 @@
+ from _ssl import (VERIFY_DEFAULT, VERIFY_CRL_CHECK_LEAF, VERIFY_CRL_CHECK_CHAIN,
+     VERIFY_X509_STRICT)
+ from _ssl import txt2obj as _txt2obj, nid2obj as _nid2obj
+-from _ssl import RAND_status, RAND_egd, RAND_add
++from _ssl import RAND_status, RAND_add
++### Fix build with LibreSSL (does not have RAND_egd)
++### PR192511, http://bugs.python.org/issue21356
++from _ssl import RAND_status, RAND_add
++try:
++    from _ssl import RAND_egd
++except ImportError:
++    # LibreSSL does not provide RAND_egd
++    pass
++### End PR192511
+ 
+ def _import_symbols(prefix):
+     for n in dir(_ssl):
+diff -Naur Python-2.7.9.orig/Lib/test/test_ssl.py Python-2.7.9/Lib/test/test_ssl.py
+--- Python-2.7.9.orig/Lib/test/test_ssl.py	2014-12-10 16:59:47.000000000 +0100
++++ Python-2.7.9/Lib/test/test_ssl.py	2014-12-22 21:13:31.735951525 +0100
+@@ -169,8 +169,12 @@
+             sys.stdout.write("\n RAND_status is %d (%s)\n"
+                              % (v, (v and "sufficient randomness") or
+                                 "insufficient randomness"))
+-        self.assertRaises(TypeError, ssl.RAND_egd, 1)
+-        self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
++### Fix build with LibreSSL (does not have RAND_egd)
++### PR192511, http://bugs.python.org/issue21356        
++        if hasattr(ssl, 'RAND_egd'):
++            self.assertRaises(TypeError, ssl.RAND_egd, 1)
++            self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
++### End PR192511
+         ssl.RAND_add("this is a random string", 75.0)
+ 
+     def test_parse_cert(self):
+diff -Naur Python-2.7.9.orig/Modules/_ssl.c Python-2.7.9/Modules/_ssl.c
+--- Python-2.7.9.orig/Modules/_ssl.c	2014-12-10 16:59:53.000000000 +0100
++++ Python-2.7.9/Modules/_ssl.c	2014-12-22 21:14:09.664477354 +0100
+@@ -3301,6 +3301,9 @@
+ It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
+ using the ssl() function.");
+ 
++/* ### Fix build with LibreSSL (does not have RAND_egd)
++   ### PR192511, http://bugs.python.org/issue21356 */
++#ifdef HAVE_RAND_EGD
+ static PyObject *
+ PySSL_RAND_egd(PyObject *self, PyObject *arg)
+ {
+@@ -3326,6 +3329,8 @@
+ Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
+ Returns number of bytes read.  Raises SSLError if connection to EGD\n\
+ fails or if it does not provide enough data to seed PRNG.");
++#endif /* HAVE_RAND_EGD */
++/* ### End PR192511 */
+ 
+ #endif /* HAVE_OPENSSL_RAND */
+ 
+@@ -3720,8 +3725,13 @@
+ #ifdef HAVE_OPENSSL_RAND
+     {"RAND_add",            PySSL_RAND_add, METH_VARARGS,
+      PySSL_RAND_add_doc},
++/* ### Fix build with LibreSSL (does not have RAND_egd)
++   ### PR192511, http://bugs.python.org/issue21356 */
++#ifdef HAVE_RAND_EGD
+     {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
+      PySSL_RAND_egd_doc},
++#endif /* HAVE_RAND_EGD */
++/* ### End PR192551 */
+     {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
+      PySSL_RAND_status_doc},
+ #endif
+diff -Naur Python-2.7.9.orig/pyconfig.h.in Python-2.7.9/pyconfig.h.in
+--- Python-2.7.9.orig/pyconfig.h.in	2014-12-10 17:00:01.000000000 +0100
++++ Python-2.7.9/pyconfig.h.in	2014-12-22 21:13:31.734951538 +0100
+@@ -544,6 +544,12 @@
+ /* Define to 1 if you have the `putenv' function. */
+ #undef HAVE_PUTENV
+ 
++/* ### Fix build with LibreSSL (does not have RAND_egd)
++   ### PR192511, http://bugs.python.org/issue21356 */
++/* Define if the libcrypto has RAND_egd */
++#undef HAVE_RAND_EGD
++
++/* ### End PR192511 */
+ /* Define to 1 if you have the `readlink' function. */
+ #undef HAVE_READLINK
+ 


More information about the patches mailing list