Tweak to urandom opening

Bug #56883 reported by Matthew Fuller
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
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/osutils.py.orig Fri Aug 11 05:35:06 2006
+++ bzrlib/osutils.py 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

Revision history for this message
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
Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.