Tweak to urandom opening

Bug #56883 reported by Matthew Fuller on 2006-08-19
Affects Status Importance Assigned to Milestone
John A Meinel

Bug Description

The FreeBSD port of bzr contains a patch to setting up the random device due to the possibility that opening /dev/urandom could throw an exception. Per discussion on IRC, some variant is probably called for:

<lifeless> actually his fix is ok
<lifeless> but it would be better to catch an explicit exception

Patch in question (against 0.9):

--- bzrlib/ Fri Aug 11 05:35:06 2006
+++ bzrlib/ Fri Aug 18 03:04:58 2006
@@ -593,10 +593,10 @@
 except (NotImplementedError, AttributeError):
     # If python doesn't have os.urandom, or it doesn't work,
     # then try to first pull random data from /dev/urandom
- if os.path.exists("/dev/urandom"):
+ try:
         rand_bytes = file('/dev/urandom', 'rb').read
     # Otherwise, use this hack as a last resort
- else:
+ except:
         # not well seeded, but better than nothing
         def rand_bytes(n):
             import random

Related branches

John A Meinel (jameinel) wrote :

Medium severity because freebsd already has a patch for this which should be in core.

The associated branch has a fix which I'm hoping to integrate into 0.12.

Changed in bzr:
assignee: nobody → jameinel
importance: Undecided → Medium
status: Unconfirmed → Fix Committed
John A Meinel (jameinel) wrote :

the associated fix has been merged for bzr 0.12

Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers