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

Collapse All | Expand All

(-)Modules/_ssl.c (+10 lines)
Lines 3339-3344 Link Here
3339
It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
3339
It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
3340
using the ssl() function.");
3340
using the ssl() function.");
3341
3341
3342
/* ### Fix build with LibreSSL (does not have RAND_egd)
3343
   ### PR195508, http://bugs.python.org/issue21356 */
3344
#ifdef HAVE_RAND_EGD
3342
static PyObject *
3345
static PyObject *
3343
PySSL_RAND_egd(PyObject *self, PyObject *args)
3346
PySSL_RAND_egd(PyObject *self, PyObject *args)
3344
{
3347
{
Lines 3366-3371 Link Here
3366
Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
3369
Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
3367
Returns number of bytes read.  Raises SSLError if connection to EGD\n\
3370
Returns number of bytes read.  Raises SSLError if connection to EGD\n\
3368
fails or if it does not provide enough data to seed PRNG.");
3371
fails or if it does not provide enough data to seed PRNG.");
3372
#endif /* HAVE_RAND_EGD */
3373
/* ### End PR195508  */
3369
3374
3370
#endif /* HAVE_OPENSSL_RAND */
3375
#endif /* HAVE_OPENSSL_RAND */
3371
3376
Lines 3761-3768 Link Here
3761
     PySSL_RAND_bytes_doc},
3766
     PySSL_RAND_bytes_doc},
3762
    {"RAND_pseudo_bytes",   PySSL_RAND_pseudo_bytes, METH_VARARGS,
3767
    {"RAND_pseudo_bytes",   PySSL_RAND_pseudo_bytes, METH_VARARGS,
3763
     PySSL_RAND_pseudo_bytes_doc},
3768
     PySSL_RAND_pseudo_bytes_doc},
3769
/* ### Fix build with LibreSSL (does not have RAND_egd)
3770
   ### PR195508, http://bugs.python.org/issue21356 */
3771
#ifdef HAVE_RAND_EGD
3764
    {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
3772
    {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
3765
     PySSL_RAND_egd_doc},
3773
     PySSL_RAND_egd_doc},
3774
#endif /* HAVE_RAND_EGD */
3775
/* ### End PR195508 */
3766
    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
3776
    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
3767
     PySSL_RAND_status_doc},
3777
     PySSL_RAND_status_doc},
3768
#endif
3778
#endif
(-)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, RAND_bytes, RAND_pseudo_bytes
109
### Fix build with LibreSSL (does not have RAND_egd)
110
### PR195508, http://bugs.python.org/issue21356
111
from _ssl import RAND_status, RAND_add, RAND_bytes, RAND_pseudo_bytes
112
try:
113
    from _ssl import RAND_egd
114
except ImportError:
115
    # LibreSSL does not provide RAND_egd
116
    pass
117
### End PR195508
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/test/test_ssl.py (-2 / +6 lines)
Lines 154-161 Link Here
154
        self.assertRaises(ValueError, ssl.RAND_bytes, -5)
154
        self.assertRaises(ValueError, ssl.RAND_bytes, -5)
155
        self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5)
155
        self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5)
156
156
157
        self.assertRaises(TypeError, ssl.RAND_egd, 1)
157
### Fix build with LibreSSL (does not have RAND_egd)
158
        self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
158
### PR195508, http://bugs.python.org/issue21356        
159
        if hasattr(ssl, 'RAND_egd'):
160
            self.assertRaises(TypeError, ssl.RAND_egd, 1)
161
            self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
162
### End PR195508
159
        ssl.RAND_add("this is a random string", 75.0)
163
        ssl.RAND_add("this is a random string", 75.0)
160
164
161
    @unittest.skipUnless(os.name == 'posix', 'requires posix')
165
    @unittest.skipUnless(os.name == 'posix', 'requires posix')
(-)configure.ac (+7 lines)
Lines 2239-2244 Link Here
2239
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
2239
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
2240
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
2240
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
2241
2241
2242
### Fix build with LibreSSL (does not have RAND_egd)
2243
### PR195508, http://bugs.python.org/issue21356
2244
AC_CHECK_LIB(crypto, RAND_egd,
2245
             AC_DEFINE(HAVE_RAND_EGD, 1,
2246
             [Define if the libcrypto has RAND_egd]))
2247
### PR195508
2248
2242
# only check for sem_init if thread support is requested
2249
# only check for sem_init if thread support is requested
2243
if test "$with_threads" = "yes" -o -z "$with_threads"; then
2250
if test "$with_threads" = "yes" -o -z "$with_threads"; then
2244
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2251
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
(-)configure (+48 lines)
Lines 8905-8910 Link Here
8905
fi
8905
fi
8906
	# Dynamic linking for HP-UX
8906
	# Dynamic linking for HP-UX
8907
8907
8908
### Fix build with LibreSSL (does not have RAND_egd)
8909
### PR195508, http://bugs.python.org/issue21356
8910
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAND_egd in -lcrypto" >&5
8911
$as_echo_n "checking for RAND_egd in -lcrypto... " >&6; }
8912
if ${ac_cv_lib_crypto_RAND_egd+:} false; then :
8913
  $as_echo_n "(cached) " >&6
8914
else
8915
  ac_check_lib_save_LIBS=$LIBS
8916
LIBS="-lcrypto  $LIBS"
8917
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8918
/* end confdefs.h.  */
8919
8920
/* Override any GCC internal prototype to avoid an error.
8921
   Use char because int might match the return type of a GCC
8922
   builtin and then its argument prototype would still apply.  */
8923
#ifdef __cplusplus
8924
extern "C"
8925
#endif
8926
char RAND_egd ();
8927
int
8928
main ()
8929
{
8930
return RAND_egd ();
8931
  ;
8932
  return 0;
8933
}
8934
_ACEOF
8935
if ac_fn_c_try_link "$LINENO"; then :
8936
  ac_cv_lib_crypto_RAND_egd=yes
8937
else
8938
  ac_cv_lib_crypto_RAND_egd=no
8939
fi
8940
rm -f core conftest.err conftest.$ac_objext \
8941
    conftest$ac_exeext conftest.$ac_ext
8942
LIBS=$ac_check_lib_save_LIBS
8943
fi
8944
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_RAND_egd" >&5
8945
$as_echo "$ac_cv_lib_crypto_RAND_egd" >&6; }
8946
if test "x$ac_cv_lib_crypto_RAND_egd" = xyes; then :
8947
8948
$as_echo "#define HAVE_RAND_EGD 1" >>confdefs.h
8949
8950
fi
8951
8952
### PR195508
8953
8908
# only check for sem_init if thread support is requested
8954
# only check for sem_init if thread support is requested
8909
if test "$with_threads" = "yes" -o -z "$with_threads"; then
8955
if test "$with_threads" = "yes" -o -z "$with_threads"; then
8910
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
8956
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
Lines 9318-9323 Link Here
9318
fi
9364
fi
9319
9365
9320
9366
9367
9368
9321
# Check for use of the system expat library
9369
# Check for use of the system expat library
9322
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-expat" >&5
9370
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-expat" >&5
9323
$as_echo_n "checking for --with-system-expat... " >&6; }
9371
$as_echo_n "checking for --with-system-expat... " >&6; }
(-)pyconfig.h.in (+6 lines)
Lines 672-677 Link Here
672
/* Define to 1 if you have the `pwrite' function. */
672
/* Define to 1 if you have the `pwrite' function. */
673
#undef HAVE_PWRITE
673
#undef HAVE_PWRITE
674
674
675
/* ### Fix build with LibreSSL (does not have RAND_egd)
676
   ### PR195508, http://bugs.python.org/issue21356 */
677
/* Define if the libcrypto has RAND_egd */
678
#undef HAVE_RAND_EGD
679
/* ### PR195508 */
680
675
/* Define to 1 if you have the `readlink' function. */
681
/* Define to 1 if you have the `readlink' function. */
676
#undef HAVE_READLINK
682
#undef HAVE_READLINK
677
683

Return to bug 195508