Commit 9263f554 by Nate Hardison

Use /dev/urandom, not /dev/random

/dev/random blocks if there is not enough entropy to return the
requested number of bytes, and this turns out to hang our AWS
servers. When generating random bytes for Jabber passwords, use
/dev/urandom instead. We figure that this will be "secure enough,"
since we'll have bigger problems if someone manages to get ahold
of our /dev/urandom's seed value.
parent 1dc91cfd
...@@ -4,6 +4,7 @@ functions to parse the settings, create and retrieve chat-specific ...@@ -4,6 +4,7 @@ functions to parse the settings, create and retrieve chat-specific
passwords for users, etc. passwords for users, etc.
""" """
import base64 import base64
import os
from django.conf import settings from django.conf import settings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
...@@ -106,8 +107,7 @@ def __generate_random_string(length): ...@@ -106,8 +107,7 @@ def __generate_random_string(length):
# so figure out how many random bytes we need to get a string of # so figure out how many random bytes we need to get a string of
# just the right length # just the right length
num_bytes = length / 4 * 3 num_bytes = length / 4 * 3
with open("/dev/random", "rb") as random: return base64.b64encode(os.urandom(num_bytes))
return base64.b64encode(random.read(num_bytes))
def __validate_settings(): def __validate_settings():
......
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