mirror of https://github.com/fail2ban/fail2ban
Merge pull request #714 from kwirk/urandom-persistent
BF: Avoid closing "/dev/urandom" for Python 3.4.0pull/715/merge
commit
91eb75098b
|
@ -22,6 +22,8 @@ ver. 0.9.1 (2014/xx/xx) - better, faster, stronger
|
||||||
* Nginx filter to support missing server_name. Closes gh-676
|
* Nginx filter to support missing server_name. Closes gh-676
|
||||||
* fail2ban-regex assertion error caused by miscount missed lines with
|
* fail2ban-regex assertion error caused by miscount missed lines with
|
||||||
multiline regex
|
multiline regex
|
||||||
|
* Fix actions failing to execute for Python 3.4.0. Work around for
|
||||||
|
http://bugs.python.org/issue21207
|
||||||
|
|
||||||
- New features:
|
- New features:
|
||||||
|
|
||||||
|
|
|
@ -523,11 +523,19 @@ class Server:
|
||||||
except (AttributeError, ValueError):
|
except (AttributeError, ValueError):
|
||||||
maxfd = 256 # default maximum
|
maxfd = 256 # default maximum
|
||||||
|
|
||||||
for fd in range(0, maxfd):
|
# urandom should not be closed in Python 3.4.0. Fixed in 3.4.1
|
||||||
try:
|
# http://bugs.python.org/issue21207
|
||||||
os.close(fd)
|
if sys.version_info[0:3] == (3, 4, 0): # pragma: no cover
|
||||||
except OSError: # ERROR (ignore)
|
urandom_fd = os.open("/dev/urandom", os.O_RDONLY)
|
||||||
pass
|
for fd in range(0, maxfd):
|
||||||
|
try:
|
||||||
|
if not os.path.sameopenfile(urandom_fd, fd):
|
||||||
|
os.close(fd)
|
||||||
|
except OSError: # ERROR (ignore)
|
||||||
|
pass
|
||||||
|
os.close(urandom_fd)
|
||||||
|
else:
|
||||||
|
os.closerange(0, maxfd)
|
||||||
|
|
||||||
# Redirect the standard file descriptors to /dev/null.
|
# Redirect the standard file descriptors to /dev/null.
|
||||||
os.open("/dev/null", os.O_RDONLY) # standard input (0)
|
os.open("/dev/null", os.O_RDONLY) # standard input (0)
|
||||||
|
|
Loading…
Reference in New Issue