Mail Archives: cygwin/2009/10/22/15:40:20
Hi,
I'm not sure if this is the right place to post such problems, but I ran into
this problem when trying to use the paramiko library with python 2.5.2 in Cygwin.
Ultimately the problem is that an IOError is generated when opening
/dev/urandom, reading some bytes from it (doesn't seem to matter how much),
and closing the file. If you don't read from the file there is no error upon
closing.
$ python
Python 2.5.2 (r252:60911, Dec 2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
.>>> f = open("/dev/urandom")
.>>> f.close()
Note: no problem just opening and closing the special file. But:
.>>> f = open("/dev/urandom")
.>>> f.read(8)
'\xf9"\xb7\'E\xf8Q\xa0'
.>>> f.close()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 0] Error
.>>>
This problem manifests itself when trying to use the paramiko library in
any way:
.>>> import paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "__init__.py", line 69, in <module>
File "transport.py", line 32, in <module>
File "util.py", line 31, in <module>
File "common.py", line 101, in <module>
File "rng.py", line 69, in __init__
File "randpool.py", line 87, in __init__
File "randpool.py", line 120, in _randomize
IOError: [Errno 0] Error
This error ultimately comes from
/usr/lib/python2.5/site-packages/Crypto/Util/randpool.py, line 118, which I
believe I got from python-crypto 2.0.1-1.
This bug was previously noticed at least a year ago:
http://www.cygwin.com/ml/cygwin/2008-09/msg00561.html (and others)
The suggested work-around, for users of python-crypto, was to change the line
just below this in randpool.py from:
except IOError, (num, msg):
if num!=2: raise IOError, (num, msg)
to
except IOError, (num, msg):
if num!=2 and num!=0: raise IOError, (num, msg)
There was some concern about the validity of this fix but it seems to me that
random data is being pulled from /dev/urandom just fine. But still it would be
nice to attack this problem at the root.
It seems likely that this problem is not reproduced on all systems since, after
all, paramiko is distributed in Cygwin and yet I cannot even import the module.
I'm not sure what else I should detail about my system. It's running Vista SP1.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -