details: http://www.bx.psu.edu/hg/galaxy/rev/52e504c91cbc changeset: 1601:52e504c91cbc user: Greg Von Kuster <greg@bx.psu.edu> date: Tue Nov 04 09:27:49 2008 -0500 description: Apply James' faster_random patch from Nov 1. 1 file(s) affected in this change: lib/galaxy/web/security/__init__.py diffs (34 lines): diff -r 7ae75e6d9d6a -r 52e504c91cbc lib/galaxy/web/security/__init__.py --- a/lib/galaxy/web/security/__init__.py Mon Nov 03 15:31:38 2008 -0500 +++ b/lib/galaxy/web/security/__init__.py Tue Nov 04 09:27:49 2008 -0500 @@ -10,18 +10,17 @@ log = logging.getLogger( __name__ ) if os.path.exists( "/dev/urandom" ): - log.debug("###using /dev/urandom....") # We have urandom, use it as the source of random data random_fd = os.open( "/dev/urandom", os.O_RDONLY ) def get_random_bytes( nbytes ): value = os.read( random_fd, nbytes ) # Normally we should get as much as we need if len( value ) == nbytes: - return value + return value.encode( "hex" ) # If we don't, keep reading (this is slow and should never happen) while len( value ) < nbytes: value += os.read( random_fd, nbytes - len( value ) ) - return value + return value.encode( "hex" ) else: def get_random_bytes( nbytes ): nbits = nbytes * 8 @@ -29,7 +28,8 @@ while random_pool.entropy < nbits: random_pool.add_event() random_pool.stir() - return( str( number.getRandomNumber( nbits, random_pool.get_bytes ) ) ) + return str( number.getRandomNumber( nbits, random_pool.get_bytes ) ) + class SecurityHelper( object ): # TODO: checking if histories/datasets are owned by the current user) will be moved here.