Commit aa0abdc2 authored by fedor.brunner's avatar fedor.brunner

Update entropy gathering for interface changes of pyOpenSSL.

Fixes: #7642
parent 28c6ea4a
......@@ -98,16 +98,16 @@ def add_entropy_sources_OpenSSL():
dirs = ['/proc', '/proc/net', '/proc/self']
for d in dirs:
if os.access(d, os.R_OK):
for filename in os.listdir(d):
OpenSSL.rand.add(filename, 0)
try:
with open(d + os.sep + filename, "r") as fp:
# Limit the ammount of read bytes, in case a memory
# file was opened
OpenSSL.rand.add(str(fp.read(5000)), 0.01)
except:
# Ignore all read and access errors
pass
for filename in os.listdir(d):
OpenSSL.rand.add(filename, 0)
try:
with open(d + os.sep + filename, "r") as fp:
# Limit the ammount of read bytes, in case a memory
# file was opened
OpenSSL.rand.add(str(fp.read(5000)), 1)
except IOError:
# Ignore all read and access errors
pass
PYOPENSSL_PRNG_PRESENT = False
try:
......
......@@ -463,7 +463,7 @@ del pid_dir
def on_exit():
# Save the entropy from OpenSSL PRNG
if PYOPENSSL_PRNG_PRESENT:
OpenSSL.rand.write_file(RNG_SEED)
OpenSSL.rand.write_file(str(RNG_SEED))
# delete pid file on normal exit
if os.path.exists(pid_filename):
os.remove(pid_filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment