[issue21207] urandom persistent fd - not re-openned after fd close
Antoine Pitrou
report at bugs.python.org
Wed Apr 16 19:57:48 CEST 2014
Antoine Pitrou added the comment:
Well, on the one hand this does sound like a valid use case. On the other hand, once the urandom file descriptor is closed by third-party code, it can very well be re-opened to point to another file, and then os.urandom() will start behaving in a very bad way.
Here is a possible solution in Python:
- when opening the urandom fd for the first time, record its st_ino and st_dev
- when calling urandom() a second time, call fstat() on the fd and check the st_ino and st_dev with the known values
- if the values have changed (or if fstat() fails with EBADF), open a new fd to /dev/urandom, again
----------
nosy: +neologix
type: crash -> behavior
versions: +Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21207>
_______________________________________
More information about the Python-bugs-list
mailing list