Skip to content

Commit 25d77eb

Browse files
nobusorah
authored andcommitted
downloader.rb: disable verify if rubygems is old
* tool/downloader.rb (Downloader::RubyGems.download): verify gems only if RubyGems is 2.4 or later. old RubyGems fails to verify almost all of bundled gems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent b1d205a commit 25d77eb

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tool/downloader.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,27 @@ class RubyGems < self
5757
def self.download(name, dir = nil, since = true, options = {})
5858
require 'rubygems'
5959
require 'rubygems/package'
60+
verify = options.delete(:verify) {Gem::VERSION >= "2.4."}
6061
options[:ssl_ca_cert] = Dir.glob(File.expand_path("../lib/rubygems/ssl_certs/**/*.pem", File.dirname(__FILE__)))
6162
file = under(dir, name)
6263
super("https://rubygems.org/downloads/#{name}", file, nil, since, options) or
6364
return false
65+
return true unless verify
6466
policy = Gem::Security::LowSecurity
6567
(policy = policy.dup).ui = Gem::SilentUI.new if policy.respond_to?(:'ui=')
6668
pkg = Gem::Package.new(file)
6769
pkg.security_policy = policy
6870
begin
71+
$stdout.puts "verifying #{name}"
6972
pkg.verify
7073
rescue Gem::Security::Exception => e
71-
$stderr.puts e.message
74+
$stderr.puts "#{name}: #{e.message}"
7275
File.unlink(file)
7376
false
7477
else
7578
true
7679
end
7780
end
78-
79-
def self.verify(pkg)
80-
end
8181
end
8282

8383
Gems = RubyGems
@@ -134,6 +134,7 @@ def self.http_options(file, since)
134134
# download 'http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt',
135135
# 'UnicodeData.txt', 'enc/unicode/data'
136136
def self.download(url, name, dir = nil, since = true, options = {})
137+
options.delete(:verify)
137138
file = under(dir, name)
138139
if since.nil? and File.exist?(file)
139140
if $VERBOSE
@@ -194,6 +195,10 @@ def self.download(url, name, dir = nil, since = true, options = {})
194195
raise "failed to download #{name}\n#{e.message}: #{url}"
195196
end
196197

198+
def self.verify(file)
199+
true
200+
end
201+
197202
def self.under(dir, name)
198203
dir ? File.join(dir, File.basename(name)) : name
199204
end
@@ -203,6 +208,7 @@ def self.under(dir, name)
203208

204209
if $0 == __FILE__
205210
since = true
211+
options = {}
206212
until ARGV.empty?
207213
case ARGV[0]
208214
when '-d'
@@ -217,6 +223,8 @@ def self.under(dir, name)
217223
since = nil
218224
when '-a'
219225
since = false
226+
when '-V'
227+
options[:verify] = true
220228
when /\A-/
221229
abort "#{$0}: unknown option #{ARGV[0]}"
222230
else
@@ -233,10 +241,10 @@ def self.under(dir, name)
233241
ARGV.shift
234242
ARGV.each do |name|
235243
name = "#{prefix}/#{File.basename(name)}" if prefix
236-
dl.download(name, destdir, since)
244+
dl.download(name, destdir, since, options)
237245
end
238246
else
239247
abort "usage: #{$0} url name" unless ARGV.size == 2
240-
Downloader.download(ARGV[0], ARGV[1], destdir, since)
248+
Downloader.download(ARGV[0], ARGV[1], destdir, since, options)
241249
end
242250
end

0 commit comments

Comments
 (0)