Project

General

Profile

Actions

Bug #8557

closed

rubygems/security.rb is loaded twice if openssl is unavailable

Added by nobu (Nobuyoshi Nakada) over 11 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
ruby -v:
2.1.0dev
Backport:
[ruby-core:55581]

Description

=begin
Since r39606, ((%rubygems/security.rb%)) is loaded twice if ((%openssl%)) is unavailable.

$ make TESTS=rubygems test-all
CC = clang
LD = ld
LDSHARED = clang -dynamiclib
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-stateme
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin11 -I../src/include -I../src
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -install_name @executable_path/../lib/libruby.2.1.0.dylib -current_version 2.1.0 -compatibility_version 2.1.0 -fstack-protector -Wl,-u,_objc_msgSend -fstack
SOLIBS =
Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
./miniruby -I../src/lib -I. -I.ext/common ../src/tool/runruby.rb --extout=.ext -- --disable-gems "../src/test/runner.rb" --ruby="./miniruby -I../src/lib -I. -I.ext/common ../src/tool/runruby.rb --extout=.ext -- --disable-gems" rubyge
/Users/nobu/src/ruby/trunk/src/lib/rubygems/security.rb:355: warning: already initialized constant Gem::Security::DIGEST_ALGORITHM
/Users/nobu/src/ruby/trunk/src/lib/rubygems/security.rb:355: warning: previous definition of DIGEST_ALGORITHM was here

$ nmake TESTS=rubygems test-all
CC = cl -nologo
LD = cl -nologo
LDSHARED = cl -nologo -LD
CFLAGS = -MD -Zi -W2 -wd4996 -we4028 -we4142 -O2sy- -Zm600
XCFLAGS = -DRUBY_EXPORT -I. -I.ext/include/i386-mswin32_110 -I../src/include -I../src -I../src/missing
CPPFLAGS =
DLDFLAGS = -incremental:no -debug -opt:ref -opt:icf -dll
SOLIBS =
.\ruby.exe -I../src/lib -I".ext/i386-mswin32_110" -I. "../src/tool/runruby.rb" --extout=".ext" -- --disable-gems "../src/test/runner.rb" --ruby=".\ruby.exe -I../src/lib -I".ext/i386-mswin32_110" -I. "../src/tool/runruby.rb" --extout=".ext" -- --disable-gems" rubygems
C:/Users/nobu/build/ruby/trunk/src/lib/rubygems/security.rb:355: warning: already initialized constant Gem::Security::DIGEST_ALGORITHM
C:/Users/nobu/build/ruby/trunk/src/lib/rubygems/security.rb:355: warning: previous definition of DIGEST_ALGORITHM was here

It seems to intend to fake (({OpenSSL})) but doesn't work actually, because (({Gem::Security::Policy})) requires ((%openssl%)).

$ ./bin/ruby -rrubygems/security -ep
C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require': cannot load such file -- openssl (LoadError) from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require'
from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/security/policy.rb:23:in initialize' from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/security/policies.rb:6:in new'
from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/security/policies.rb:6:in <module:Security>' from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/security/policies.rb:1:in <top (required)>'
from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require' from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require'
from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/security.rb:583:in <top (required)>' from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require'
from C:/Users/nobu/build/ruby/trunk/i386-mswin32_110/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in `require'
bash: exit 1

$ ./bin/ruby -rrubygems/security -ep
/Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require': cannot load such file -- openssl (LoadError) from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require'
from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/security/policy.rb:23:in initialize' from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/security/policies.rb:6:in new'
from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/security/policies.rb:6:in <module:Security>' from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/security/policies.rb:1:in <top (required)>'
from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require' from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require'
from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/security.rb:583:in <top (required)>' from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in require'
from /Users/nobu/build/ruby/trunk/x86_64-darwin/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:45:in `require'
bash: exit 1

Moreover, since (({LoadError#path})) returns required library name with its suffix, so (({e.path == 'openssl'})) never become true.
=end

Updated by nobu (Nobuyoshi Nakada) over 11 years ago

  • Description updated (diff)

Updated by drbrain (Eric Hodel) over 11 years ago

=begin
How can LoadError#path return the required library name if the file is missing?

It seems (({e.path == "openssl"})) will return true:

$ ruby -e 'begin; require "nonexistent"; rescue LoadError; p $!.path; end'
"nonexistent"

I get the same result (required file name in #path) if the file is not loadable due to permissions.
=end

Updated by drbrain (Eric Hodel) over 11 years ago

I have this fixed on RubyGems master and will merge to ruby trunk after releasing RubyGems 2.0.4 (later this week).

Updated by drbrain (Eric Hodel) over 11 years ago

  • Status changed from Assigned to Closed

Fixed by r41873

Updated by nagachika (Tomoyuki Chikanaga) about 11 years ago

  • Backport changed from 2.0.0: REQUIRED to 2.0.0: DONE

I believe this issue was fixed on ruby_2_0_0, isn't it?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0