Opened 16 years ago
Closed 16 years ago
#10253 closed (invalid)
sessions.base.py random.SystemRandom() fails
Reported by: | monkut | Owned by: | nobody |
---|---|---|---|
Component: | contrib.sessions | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Related to changeset 8340.
# Use the system (hardware-based) random number generator if it exists. if hasattr(random, 'SystemRandom'): randrange = random.SystemRandom().randrange else: randrange = random.randrange MAX_SESSION_KEY = 18446744073709551616L # 2 << 63
Platform info:
>>> platform.system() 'SunOS' >>> platform.version() 'Generic_105181-35' >>> platform.release() '5.6' >>> platform.python_version() '2.5.2'
Condition in line 17 of base.py, "if hasattr(random, 'SystemRandom'):", evaluates to True, but randrange fails.
>>> hasattr(random, 'SystemRandom') True >>> randrange = random.SystemRandom().randrange >>> randrange(0, MAX_SESSION_KEY) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/apps/public/python_2.5.2/lib/python2.5/random.py", line 188, in randrange return int(istart + self._randbelow(width)) File "/apps/public/python_2.5.2/lib/python2.5/random.py", line 235, in _randbelow r = getrandbits(k) File "/apps/public/python_2.5.2/lib/python2.5/random.py", line 778, in getrandbits x = long(_hexlify(_urandom(bytes)), 16) File "/apps/public/python_2.5.2/lib/python2.5/os.py", line 730, in urandom raise NotImplementedError("/dev/urandom (or equivalent) not found") NotImplementedError: /dev/urandom (or equivalent) not found
Exception occurs at when attempting to generate a new session key (when trying to access admin).
File "/django/contrib/sessions/backends/base.py", line 142, in _get_new_session_key % (randrange(0, MAX_SESSION_KEY), pid, time.time(),
Change History (4)
comment:1 by , 16 years ago
Description: | modified (diff) |
---|
comment:2 by , 16 years ago
I'd say this is either a) a Python (the project) programing bug when running in that platform, b) a bug in the Python package/port (if installed in such ways) or the set of options choosen when building python (if complied manually) or c) a sysadmin problem with the RNG setup in the system.
In all cases, it's in a lower level of the stack than Django and it would be better to explore/ask for support/fill bugs with the relevant provider.
comment:3 by , 16 years ago
Component: | Uncategorized → django.contrib.sessions |
---|
comment:4 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Yes, this is a problem either with Python itself or the Python/Solaris package you're using. If SystemRandom.randrange
exists, it ought to work; otherwise the platform shouldn't provide it.
Please use the preview button folks.