View | Details | Raw Unified | Return to bug 192511 | Differences between
and this patch

Collapse All | Expand All

(-)configure.ac (+7 lines)
Lines 2222-2227 Link Here
2222
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
2222
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
2223
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
2223
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
2224
2224
2225
### Fix build with LibreSSL (does not have RAND_egd)
2226
### PR192511, http://bugs.python.org/issue21356
2227
AC_CHECK_LIB(crypto, RAND_egd,
2228
             AC_DEFINE(HAVE_RAND_EGD, 1,
2229
             [Define if the libcrypto has RAND_egd]))
2230
### End PR192511
2231
2225
# only check for sem_init if thread support is requested
2232
# only check for sem_init if thread support is requested
2226
if test "$with_threads" = "yes" -o -z "$with_threads"; then
2233
if test "$with_threads" = "yes" -o -z "$with_threads"; then
2227
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2234
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
(-)configure (+46 lines)
Lines 8542-8547 Link Here
8542
fi
8542
fi
8543
	# Dynamic linking for HP-UX
8543
	# Dynamic linking for HP-UX
8544
8544
8545
### Fix build with LibreSSL (does not have RAND_egd)
8546
### PR192511, http://bugs.python.org/issue21356
8547
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAND_egd in -lcrypto" >&5
8548
$as_echo_n "checking for RAND_egd in -lcrypto... " >&6; }
8549
if ${ac_cv_lib_crypto_RAND_egd+:} false; then :
8550
  $as_echo_n "(cached) " >&6
8551
else
8552
  ac_check_lib_save_LIBS=$LIBS
8553
LIBS="-lcrypto  $LIBS"
8554
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8555
/* end confdefs.h.  */
8556
8557
/* Override any GCC internal prototype to avoid an error.
8558
   Use char because int might match the return type of a GCC
8559
   builtin and then its argument prototype would still apply.  */
8560
#ifdef __cplusplus
8561
extern "C"
8562
#endif
8563
char RAND_egd ();
8564
int
8565
main ()
8566
{
8567
return RAND_egd ();
8568
  ;
8569
  return 0;
8570
}
8571
_ACEOF
8572
if ac_fn_c_try_link "$LINENO"; then :
8573
  ac_cv_lib_crypto_RAND_egd=yes
8574
else
8575
  ac_cv_lib_crypto_RAND_egd=no
8576
fi
8577
rm -f core conftest.err conftest.$ac_objext \
8578
    conftest$ac_exeext conftest.$ac_ext
8579
LIBS=$ac_check_lib_save_LIBS
8580
fi
8581
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_RAND_egd" >&5
8582
$as_echo "$ac_cv_lib_crypto_RAND_egd" >&6; }
8583
if test "x$ac_cv_lib_crypto_RAND_egd" = xyes; then :
8584
8585
$as_echo "#define HAVE_RAND_EGD 1" >>confdefs.h
8586
8587
fi
8588
8589
### End PR192511
8590
8545
# only check for sem_init if thread support is requested
8591
# only check for sem_init if thread support is requested
8546
if test "$with_threads" = "yes" -o -z "$with_threads"; then
8592
if test "$with_threads" = "yes" -o -z "$with_threads"; then
8547
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
8593
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
(-)pyconfig.h.in (+6 lines)
Lines 544-549 Link Here
544
/* Define to 1 if you have the `putenv' function. */
544
/* Define to 1 if you have the `putenv' function. */
545
#undef HAVE_PUTENV
545
#undef HAVE_PUTENV
546
546
547
/* ### Fix build with LibreSSL (does not have RAND_egd)
548
   ### PR192511, http://bugs.python.org/issue21356 */
549
/* Define if the libcrypto has RAND_egd */
550
#undef HAVE_RAND_EGD
551
552
/* ### End PR192511 */
547
/* Define to 1 if you have the `readlink' function. */
553
/* Define to 1 if you have the `readlink' function. */
548
#undef HAVE_READLINK
554
#undef HAVE_READLINK
549
555
(-)Lib/test/test_ssl.py (-2 / +6 lines)
Lines 169-176 Link Here
169
            sys.stdout.write("\n RAND_status is %d (%s)\n"
169
            sys.stdout.write("\n RAND_status is %d (%s)\n"
170
                             % (v, (v and "sufficient randomness") or
170
                             % (v, (v and "sufficient randomness") or
171
                                "insufficient randomness"))
171
                                "insufficient randomness"))
172
        self.assertRaises(TypeError, ssl.RAND_egd, 1)
172
### Fix build with LibreSSL (does not have RAND_egd)
173
        self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
173
### PR192511, http://bugs.python.org/issue21356        
174
        if hasattr(ssl, 'RAND_egd'):
175
            self.assertRaises(TypeError, ssl.RAND_egd, 1)
176
            self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
177
### End PR192511
174
        ssl.RAND_add("this is a random string", 75.0)
178
        ssl.RAND_add("this is a random string", 75.0)
175
179
176
    def test_parse_cert(self):
180
    def test_parse_cert(self):
(-)Lib/ssl.py (-1 / +9 lines)
Lines 106-112 Link Here
106
from _ssl import (VERIFY_DEFAULT, VERIFY_CRL_CHECK_LEAF, VERIFY_CRL_CHECK_CHAIN,
106
from _ssl import (VERIFY_DEFAULT, VERIFY_CRL_CHECK_LEAF, VERIFY_CRL_CHECK_CHAIN,
107
    VERIFY_X509_STRICT)
107
    VERIFY_X509_STRICT)
108
from _ssl import txt2obj as _txt2obj, nid2obj as _nid2obj
108
from _ssl import txt2obj as _txt2obj, nid2obj as _nid2obj
109
from _ssl import RAND_status, RAND_egd, RAND_add
109
### Fix build with LibreSSL (does not have RAND_egd)
110
### PR192511, http://bugs.python.org/issue21356
111
from _ssl import RAND_status, RAND_add
112
try:
113
    from _ssl import RAND_egd
114
except ImportError:
115
    # LibreSSL does not provide RAND_egd
116
    pass
117
### End PR192511
110
118
111
def _import_symbols(prefix):
119
def _import_symbols(prefix):
112
    for n in dir(_ssl):
120
    for n in dir(_ssl):
(-)Lib/socket.py (-1 / +8 lines)
Lines 67-73 Link Here
67
    from _ssl import SSLError as sslerror
67
    from _ssl import SSLError as sslerror
68
    from _ssl import \
68
    from _ssl import \
69
         RAND_add, \
69
         RAND_add, \
70
         RAND_egd, \
71
         RAND_status, \
70
         RAND_status, \
72
         SSL_ERROR_ZERO_RETURN, \
71
         SSL_ERROR_ZERO_RETURN, \
73
         SSL_ERROR_WANT_READ, \
72
         SSL_ERROR_WANT_READ, \
Lines 78-83 Link Here
78
         SSL_ERROR_WANT_CONNECT, \
77
         SSL_ERROR_WANT_CONNECT, \
79
         SSL_ERROR_EOF, \
78
         SSL_ERROR_EOF, \
80
         SSL_ERROR_INVALID_ERROR_CODE
79
         SSL_ERROR_INVALID_ERROR_CODE
80
### Fix build with LibreSSL (does not have RAND_egd)
81
### PR192511, http://bugs.python.org/issue21356
82
    try:
83
         from _ssl import RAND_egd
84
         # LibreSSL does not provide RAND_egd
85
    except ImportError:
86
         pass
87
### End PR192511
81
88
82
import os, sys, warnings
89
import os, sys, warnings
83
90
(-)Modules/_ssl.c (+10 lines)
Lines 3301-3306 Link Here
3301
It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
3301
It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
3302
using the ssl() function.");
3302
using the ssl() function.");
3303
3303
3304
/* ### Fix build with LibreSSL (does not have RAND_egd)
3305
   ### PR192511, http://bugs.python.org/issue21356 */
3306
#ifdef HAVE_RAND_EGD
3304
static PyObject *
3307
static PyObject *
3305
PySSL_RAND_egd(PyObject *self, PyObject *arg)
3308
PySSL_RAND_egd(PyObject *self, PyObject *arg)
3306
{
3309
{
Lines 3326-3331 Link Here
3326
Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
3329
Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
3327
Returns number of bytes read.  Raises SSLError if connection to EGD\n\
3330
Returns number of bytes read.  Raises SSLError if connection to EGD\n\
3328
fails or if it does not provide enough data to seed PRNG.");
3331
fails or if it does not provide enough data to seed PRNG.");
3332
#endif /* HAVE_RAND_EGD */
3333
/* ### End PR192511 */
3329
3334
3330
#endif /* HAVE_OPENSSL_RAND */
3335
#endif /* HAVE_OPENSSL_RAND */
3331
3336
Lines 3720-3727 Link Here
3720
#ifdef HAVE_OPENSSL_RAND
3725
#ifdef HAVE_OPENSSL_RAND
3721
    {"RAND_add",            PySSL_RAND_add, METH_VARARGS,
3726
    {"RAND_add",            PySSL_RAND_add, METH_VARARGS,
3722
     PySSL_RAND_add_doc},
3727
     PySSL_RAND_add_doc},
3728
/* ### Fix build with LibreSSL (does not have RAND_egd)
3729
   ### PR192511, http://bugs.python.org/issue21356 */
3730
#ifdef HAVE_RAND_EGD
3723
    {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
3731
    {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
3724
     PySSL_RAND_egd_doc},
3732
     PySSL_RAND_egd_doc},
3733
#endif /* HAVE_RAND_EGD */
3734
/* ### End PR192551 */
3725
    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
3735
    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
3726
     PySSL_RAND_status_doc},
3736
     PySSL_RAND_status_doc},
3727
#endif
3737
#endif

Return to bug 192511