[Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.140,1.141

Guido van Rossum gvanrossum@users.sourceforge.net
Sun, 15 Apr 2001 17:21:35 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv1391

Modified Files:
	socketmodule.c 
Log Message:
Reverting Moshe's EGD patch *and* Martin's patch to make it work with
OpenSSL versions beore 0.9.5.  This just is too experimental to be
worth it, especially since the user would have to do some severe
hacking of the Modules/Setup file to even enable the EGD code, and
without the EGD code it would always spit out a warning on some
systems -- even when socket.ssl() is not used.  Fixing that properly
is not my job; the EGD patch is clearly not so important that it
should hold up the 2.1 release.


Index: socketmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v
retrieving revision 1.140
retrieving revision 1.141
diff -C2 -r1.140 -r1.141
*** socketmodule.c	2001/04/13 17:54:04	1.140
--- socketmodule.c	2001/04/16 00:21:33	1.141
***************
*** 195,206 ****
  #include "openssl/ssl.h"
  #include "openssl/err.h"
- #include "openssl/rand.h"
- 
- #if OPENSSL_VERSION_NUMBER < 0x0090510fL
- /* RAND_status was added in OpenSSL 0.9.5. If it is not available,
-    we assume that seeding the RNG is necessary every time. */
- #define RAND_status()	0
- #endif
- 
  #endif /* USE_SSL */
  
--- 195,198 ----
***************
*** 2553,2582 ****
  				 (PyObject *)&SSL_Type) != 0)
  		return;
- 	if (RAND_status() == 0) {
- #ifdef USE_EGD
- 		char random_device[MAXPATHLEN+1];
- 		if (!RAND_file_name (random_device, MAXPATHLEN + 1)) {
- 			PyErr_SetObject(SSLErrorObject,
- 			        PyString_FromString("RAND_file_name error"));
- 			return;
- 		}
- 		if (RAND_egd (random_device) == -1) {
- 			PyErr_SetObject(SSLErrorObject,
- 			             PyString_FromString("RAND_egd error"));
- 			return;
- 		}
- #else /* USE_EGD not defined */
- 		char random_string[32];
- 		int i;
- 
-                 PyErr_Warn(PyExc_RuntimeWarning, 
-                            "using insecure method to generate random numbers");
- 		srand(time(NULL));
- 		for(i=0; i<sizeof(random_string); i++) {
- 			random_string[i] = rand();
- 		}
- 		RAND_seed(random_string, sizeof(random_string));
- #endif /* USE_EGD */
- 	}
  #endif /* USE_SSL */
  	PyDict_SetItemString(d, "error", PySocket_Error);
--- 2545,2548 ----