2005-12-08 18:26:38 +00:00
|
|
|
#
|
|
|
|
# Provides some sanity checks against the ruby build and version
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
# Check for the broken pack/unpack in OS X 10.4.x
|
|
|
|
if ([1].pack('n') == "\x01\x00")
|
2009-06-15 02:40:28 +00:00
|
|
|
$stderr.puts "*** This ruby build has a broken pack/unpack implementation! "
|
2005-12-08 18:26:38 +00:00
|
|
|
|
|
|
|
if (RUBY_PLATFORM =~ /darwin/)
|
2009-06-15 02:40:28 +00:00
|
|
|
$stderr.puts " Apple shipped a broken version of ruby with the 10.4.x "
|
|
|
|
$stderr.puts " release. Please install ruby from source, or use one of "
|
|
|
|
$stderr.puts " the free package managers to obtain a working ruby build."
|
2005-12-08 18:26:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
exit(0)
|
|
|
|
end
|
|
|
|
|
2007-03-25 07:57:54 +00:00
|
|
|
# Check for ruby 1.8.2 as the minimal supported version
|
|
|
|
if (RUBY_VERSION =~ /^1\.[0-7]\./ or RUBY_VERSION =~ /^1\.8\.[0-1]$/)
|
2009-06-15 02:40:28 +00:00
|
|
|
$stderr.puts "*** This version of ruby is not supported, please upgrade to 1.8.2+"
|
2005-12-08 18:26:38 +00:00
|
|
|
exit(0)
|
|
|
|
end
|
2008-09-25 04:42:08 +00:00
|
|
|
|
2009-03-05 15:04:07 +00:00
|
|
|
# Check for ruby 1.9.0 and throw a big nasty warning
|
2009-06-14 21:30:56 +00:00
|
|
|
if (RUBY_VERSION =~ /^1\.9\.0/)
|
2009-06-15 02:40:28 +00:00
|
|
|
$stderr.puts "*** Ruby 1.9.0 is not supported, please upgrade to Ruby 1.9.1 or newer."
|
2009-06-14 21:30:56 +00:00
|
|
|
exit(0)
|
|
|
|
end
|
2009-03-30 02:57:10 +00:00
|
|
|
|
2009-09-28 03:15:10 +00:00
|
|
|
if(RUBY_VERSION =~ /^1\.9\./)
|
2009-06-03 03:02:42 +00:00
|
|
|
# Force binary encoding for Ruby versions that support it
|
|
|
|
if(Object.const_defined?('Encoding') and Encoding.respond_to?('default_external='))
|
|
|
|
Encoding.default_external = Encoding.default_internal = "binary"
|
|
|
|
end
|
2009-03-05 15:04:07 +00:00
|
|
|
end
|
2008-11-07 20:44:13 +00:00
|
|
|
|
2009-06-14 21:37:02 +00:00
|
|
|
if(RUBY_PLATFORM == 'java')
|
|
|
|
require 'socket'
|
|
|
|
s = Socket.new(::Socket::AF_INET, ::Socket::SOCK_STREAM, ::Socket::IPPROTO_TCP)
|
|
|
|
if(not s.respond_to?('bind'))
|
2009-06-15 02:40:28 +00:00
|
|
|
$stderr.puts "*** JRuby will not be supported until the Socket API is complete"
|
|
|
|
$stderr.puts "*** Information: http://jira.codehaus.org/browse/JRUBY-2739"
|
2009-06-14 21:37:02 +00:00
|
|
|
exit(0)
|
|
|
|
end
|
|
|
|
end
|
2009-03-30 02:57:10 +00:00
|
|
|
|
2009-10-02 14:24:10 +00:00
|
|
|
# Check for OpenSSL and print a warning if it is not installed
|
|
|
|
begin
|
|
|
|
require 'openssl'
|
|
|
|
rescue ::LoadError
|
|
|
|
$stderr.puts "*** The ruby-openssl library is not installed, many features will be disabled!"
|
|
|
|
$stderr.puts "*** Examples: Meterpreter, SSL Sockets, SMB/NTLM Authentication, and more"
|
|
|
|
end
|
|
|
|
|
2009-03-30 02:57:10 +00:00
|
|
|
|
2008-11-07 20:44:13 +00:00
|
|
|
#
|
|
|
|
# Check for the ugly 1.8.7 short-named constants bug
|
|
|
|
#
|
|
|
|
|
|
|
|
class ConstBugTestA
|
|
|
|
Const = 'A'
|
|
|
|
def test
|
|
|
|
Const == 'A'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ConstBugTestC = ConstBugTestA.dup
|
|
|
|
|
|
|
|
class ConstBugTestB < ConstBugTestC
|
|
|
|
Const = 'B'
|
|
|
|
end
|
|
|
|
|
|
|
|
def ruby_187_const_bug
|
|
|
|
bugged = false
|
|
|
|
|
|
|
|
begin
|
|
|
|
ConstBugTestA.new.test()
|
|
|
|
ConstBugTestB.new.test()
|
|
|
|
rescue ::NameError
|
|
|
|
bugged = true
|
|
|
|
end
|
|
|
|
|
|
|
|
bugged
|
|
|
|
end
|
|
|
|
|
|
|
|
if(ruby_187_const_bug())
|
2008-09-25 04:42:08 +00:00
|
|
|
$stderr.puts ""
|
|
|
|
$stderr.puts "***********************************************************************"
|
2008-11-07 20:44:13 +00:00
|
|
|
$stderr.puts "*** *"
|
2009-03-05 15:04:07 +00:00
|
|
|
$stderr.puts "*** This version of the Ruby interpreter contains a serious bug *"
|
|
|
|
$stderr.puts "*** related to short-named constants, we strongly recommend that you *"
|
|
|
|
$stderr.puts "*** switch to a fixed version. Unfortunately, some Linux distros have *"
|
|
|
|
$stderr.puts "*** backported the buggy patch into 1.8.6, so you may need to contact *"
|
|
|
|
$stderr.puts "*** your vendor and ask them to review the URL below. *"
|
|
|
|
$stderr.puts "*** *"
|
|
|
|
$stderr.puts "*** Alternatively, you can download, build, and install the latest *"
|
|
|
|
$stderr.puts "*** stable snapshot of Ruby from the following URL: *"
|
2008-11-07 20:44:13 +00:00
|
|
|
$stderr.puts "*** - http://www.ruby-lang.org/ *"
|
2009-03-05 15:04:07 +00:00
|
|
|
$stderr.puts "*** *"
|
2008-11-07 20:44:13 +00:00
|
|
|
$stderr.puts "*** For more information, please see the following URL: *"
|
|
|
|
$stderr.puts "*** - https://bugs.launchpad.net/bugs/282302 *"
|
|
|
|
$stderr.puts "*** *"
|
2008-09-25 04:42:08 +00:00
|
|
|
$stderr.puts "***********************************************************************"
|
|
|
|
$stderr.puts ""
|
2008-11-07 20:44:13 +00:00
|
|
|
end
|