Ruby bug reading from /dev/urandom after failed require?

M

Mike Boone

I've been trying to track down a bug that surfaced when trying to
generate a Rails 2.0.2 app in Cygwin. Reading from /dev/urandom fails
with "No such file or directory - /dev/urandom" if a failed require
has been made previously.

The Rails code looks OK, so I thought it might be Cygwin. I came up
with a simple snippet that fails in Cygwin (see below). Corinna
Vinschen over at Cygwin ran strace on it and thought it might be a
Ruby bug...see her thoughts here:
http://cygwin.com/ml/cygwin/2007-12/msg00502.html

I'm not well versed on the low level strace stuff, but I thought I'd
try to see this through. I'd appreciate any comments from someone
knowledgeable about the Ruby source.

Demonstration code:
----------------------------
# Test failure of reading /dev/urandom after failed require

# this method is from the Rails' source secret_key_generator.rb
def generate_secret_with_urandom
return File.read("/dev/urandom", 64).unpack("H*")[0]
end

cause_failure = true

begin
require 'nonexistent_file'
rescue LoadError
puts '' unless cause_failure
end

puts generate_secret_with_urandom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top