rubygems-update 4.0.24 → 4.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/bundler/CHANGELOG.md +13 -0
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/outdated.rb +1 -4
- data/bundler/lib/bundler/definition.rb +10 -4
- data/bundler/lib/bundler/dependency.rb +17 -2
- data/bundler/lib/bundler/injector.rb +1 -1
- data/bundler/lib/bundler/mirror.rb +7 -5
- data/bundler/lib/bundler/plugin/index.rb +29 -3
- data/bundler/lib/bundler/resolver.rb +55 -5
- data/bundler/lib/bundler/spec_set.rb +3 -3
- data/bundler/lib/bundler/version.rb +1 -1
- data/lib/rubygems/core_ext/tcpsocket_init.rb +2 -2
- data/lib/rubygems/package/old.rb +2 -2
- data/lib/rubygems/package.rb +45 -12
- data/lib/rubygems.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19a887e090c63e47ee3525f0d74cabae85a510aa3066dc98e27ef099ee23f83b
|
|
4
|
+
data.tar.gz: 0e9cd05343e09f62c50c273611b2f03cba6c8553c2ccb60b32d432a2719a01b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45c4cc9046f9ad488df12ca73d89e15e1d092ba0dfb12e438f41eef2186b2084cc1e5b03de8bdaa47a98317216ef3da92e198afe61711880ea7b5204982d5d01
|
|
7
|
+
data.tar.gz: 548ed1fbf6157750db5dd1fc9bf2ca3d5b732f4ba6009bdf02e22883d006eac40ab7c18200d1a57f1657570b4909574134c24b9f3c760d682f6c4be38e60050f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.25 / 2026-11-25
|
|
4
|
+
|
|
5
|
+
### Bug fixes:
|
|
6
|
+
|
|
7
|
+
* Fix file permissions during gem extraction. Pull request [#10128](https://github.com/ruby/rubygems/pull/10128) by Hiroshi SHIBATA
|
|
8
|
+
* Resolve chained symlink targets before creating them during extraction. Pull request [#10119](https://github.com/ruby/rubygems/pull/10119) by Hiroshi SHIBATA
|
|
9
|
+
* Forward keyword arguments in the IPv4 fallback TCPSocket#initialize. Pull request [#10098](https://github.com/ruby/rubygems/pull/10098) by Hiroshi SHIBATA
|
|
10
|
+
|
|
3
11
|
## 4.0.24 / 2026-11-05
|
|
4
12
|
|
|
5
13
|
### Enhancements:
|
data/bundler/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.25 / 2026-11-25
|
|
4
|
+
|
|
5
|
+
### Bug fixes:
|
|
6
|
+
|
|
7
|
+
* Retry resolution with transitive prereleases. Pull request [#10110](https://github.com/ruby/rubygems/pull/10110) by Hiroshi SHIBATA
|
|
8
|
+
* Allow full updates to downgrade a yanked gem. Pull request [#10106](https://github.com/ruby/rubygems/pull/10106) by Hiroshi SHIBATA
|
|
9
|
+
* Allow `bundle lock --add-platform` to add native platforms from JRuby. Pull request [#10105](https://github.com/ruby/rubygems/pull/10105) by Hiroshi SHIBATA
|
|
10
|
+
* Show fourth-segment and prerelease updates in `bundle outdated --filter-patch`. Pull request [#10103](https://github.com/ruby/rubygems/pull/10103) by Hiroshi SHIBATA
|
|
11
|
+
* Resolve dependencies before `bundle add` updates the Gemfile. Pull request [#10101](https://github.com/ruby/rubygems/pull/10101) by Hiroshi SHIBATA
|
|
12
|
+
* Read plugin index files that Bundler 4.1 writes. Pull request [#10077](https://github.com/ruby/rubygems/pull/10077) by Hiroshi SHIBATA
|
|
13
|
+
* Preload git sources that share a cache one after another: 4.0.x. Pull request [#10069](https://github.com/ruby/rubygems/pull/10069) by Hiroshi SHIBATA
|
|
14
|
+
* Fix Bundler mirror probing with `fallback_timeout`. Pull request [#10046](https://github.com/ruby/rubygems/pull/10046) by Hiroshi SHIBATA
|
|
15
|
+
|
|
3
16
|
## 4.0.24 / 2026-11-05
|
|
4
17
|
|
|
5
18
|
### Enhancements:
|
|
@@ -4,8 +4,8 @@ module Bundler
|
|
|
4
4
|
# Represents metadata from when the Bundler gem was built.
|
|
5
5
|
module BuildMetadata
|
|
6
6
|
# begin ivars
|
|
7
|
-
@built_at = "2026-11-
|
|
8
|
-
@git_commit_sha = "
|
|
7
|
+
@built_at = "2026-11-25".freeze
|
|
8
|
+
@git_commit_sha = "0b572c1".freeze
|
|
9
9
|
# end ivars
|
|
10
10
|
|
|
11
11
|
# A hash representation of the build metadata.
|
|
@@ -303,10 +303,7 @@ module Bundler
|
|
|
303
303
|
update_present = active_minor > current_minor if options["filter-minor"]
|
|
304
304
|
|
|
305
305
|
if !update_present && options["filter-patch"] && current_minor == active_minor
|
|
306
|
-
|
|
307
|
-
active_patch = get_version_semver_portion_value(active_spec, 2)
|
|
308
|
-
|
|
309
|
-
update_present = active_patch > current_patch
|
|
306
|
+
update_present = active_spec.version > current_spec.version
|
|
310
307
|
end
|
|
311
308
|
end
|
|
312
309
|
|
|
@@ -795,10 +795,10 @@ module Bundler
|
|
|
795
795
|
@resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
|
|
796
796
|
|
|
797
797
|
@new_platforms.each do |platform|
|
|
798
|
-
incomplete_specs = result.incomplete_specs_for_platform(
|
|
798
|
+
incomplete_specs = result.incomplete_specs_for_platform(dependencies, platform)
|
|
799
799
|
|
|
800
800
|
if incomplete_specs.any?
|
|
801
|
-
resolver.raise_incomplete! incomplete_specs
|
|
801
|
+
resolver.raise_incomplete! incomplete_specs, platform
|
|
802
802
|
end
|
|
803
803
|
end
|
|
804
804
|
|
|
@@ -1181,7 +1181,7 @@ module Bundler
|
|
|
1181
1181
|
def preload_git_source_worker
|
|
1182
1182
|
workers = Bundler.settings.installation_parallelization
|
|
1183
1183
|
|
|
1184
|
-
@preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(
|
|
1184
|
+
@preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(sources, _) { sources.each(&:specs) })
|
|
1185
1185
|
end
|
|
1186
1186
|
|
|
1187
1187
|
def preload_git_sources
|
|
@@ -1192,7 +1192,13 @@ module Bundler
|
|
|
1192
1192
|
end
|
|
1193
1193
|
|
|
1194
1194
|
begin
|
|
1195
|
-
|
|
1195
|
+
# Sources from the same repository share one cache directory, and
|
|
1196
|
+
# running git in that directory from two workers at once makes the
|
|
1197
|
+
# fetches collide. Preload sources that share a cache in one job, one
|
|
1198
|
+
# after the other, and run the separate caches in parallel.
|
|
1199
|
+
needed_git_sources.group_by(&:cache_path).each_value do |sources|
|
|
1200
|
+
preload_git_source_worker.enq(sources)
|
|
1201
|
+
end
|
|
1196
1202
|
ensure
|
|
1197
1203
|
preload_git_source_worker.stop
|
|
1198
1204
|
end
|
|
@@ -106,8 +106,8 @@ module Bundler
|
|
|
106
106
|
@expanded_platforms ||= platforms.filter_map {|pl| CurrentRuby::PLATFORM_MAP[pl] }.flatten.uniq
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
def should_include?
|
|
110
|
-
should_include && current_env? && current_platform?
|
|
109
|
+
def should_include?(platform = nil)
|
|
110
|
+
should_include && current_env? && (platform ? matches_platform?(platform) : current_platform?)
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
def gemspec_dev_dep?
|
|
@@ -147,5 +147,20 @@ module Bundler
|
|
|
147
147
|
rescue NoMethodError
|
|
148
148
|
requirement != ">= 0"
|
|
149
149
|
end
|
|
150
|
+
|
|
151
|
+
private
|
|
152
|
+
|
|
153
|
+
def matches_platform?(platform)
|
|
154
|
+
return true if platforms.empty?
|
|
155
|
+
|
|
156
|
+
generic = Gem::Platform.generic(platform)
|
|
157
|
+
platforms.any? do |name|
|
|
158
|
+
next false unless [CurrentRuby::PLATFORM_MAP[name]].flatten.include?(generic)
|
|
159
|
+
next Bundler.current_ruby.public_send("#{name}?") if generic == Bundler.generic_local_platform
|
|
160
|
+
|
|
161
|
+
version = name.to_s[/_(\d+)\z/, 1]
|
|
162
|
+
!version || Bundler.current_ruby.public_send("on_#{version}?")
|
|
163
|
+
end
|
|
164
|
+
end
|
|
150
165
|
end
|
|
151
166
|
end
|
|
@@ -41,7 +41,7 @@ module Bundler
|
|
|
41
41
|
|
|
42
42
|
# resolve to see if the new deps broke anything
|
|
43
43
|
@definition = builder.to_definition(lockfile_path, {})
|
|
44
|
-
@definition.
|
|
44
|
+
@definition.resolve_remotely!
|
|
45
45
|
|
|
46
46
|
# since nothing broke, we can add those gems to the gemfile
|
|
47
47
|
append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @deps.any?
|
|
@@ -151,9 +151,11 @@ module Bundler
|
|
|
151
151
|
socket.connect_nonblock(address)
|
|
152
152
|
rescue Errno::EINPROGRESS
|
|
153
153
|
wait_for_writtable_socket(socket, address, timeout)
|
|
154
|
-
rescue
|
|
154
|
+
rescue SystemCallError # Connection failed somehow, again
|
|
155
155
|
false
|
|
156
156
|
end
|
|
157
|
+
rescue SocketError # The mirror host does not resolve
|
|
158
|
+
false
|
|
157
159
|
end
|
|
158
160
|
|
|
159
161
|
private
|
|
@@ -185,7 +187,7 @@ module Bundler
|
|
|
185
187
|
class MirrorSockets
|
|
186
188
|
def initialize(mirror)
|
|
187
189
|
@timeout = mirror.fallback_timeout
|
|
188
|
-
@addresses = Socket.getaddrinfo(mirror.uri.
|
|
190
|
+
@addresses = Socket.getaddrinfo(mirror.uri.hostname, mirror.uri.port, nil, Socket::SOCK_STREAM).map do |address|
|
|
189
191
|
SocketAddress.new(address[0], address[3], address[1])
|
|
190
192
|
end
|
|
191
193
|
end
|
|
@@ -194,9 +196,9 @@ module Bundler
|
|
|
194
196
|
@addresses.any? do |address|
|
|
195
197
|
socket = Socket.new(Socket.const_get(address.type), Socket::SOCK_STREAM, 0)
|
|
196
198
|
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
yield socket, address.to_socket_address, @timeout
|
|
200
|
+
ensure
|
|
201
|
+
socket&.close
|
|
200
202
|
end
|
|
201
203
|
end
|
|
202
204
|
end
|
|
@@ -163,6 +163,8 @@ module Bundler
|
|
|
163
163
|
# @param [Pathname] index file path
|
|
164
164
|
# @param [Boolean] is the index file global index
|
|
165
165
|
def load_index(index_file, global = false)
|
|
166
|
+
base = global ? Plugin.global_root : Plugin.root
|
|
167
|
+
|
|
166
168
|
SharedHelpers.filesystem_access(index_file, :read) do |index_f|
|
|
167
169
|
valid_file = index_f&.exist? && !index_f.size.zero?
|
|
168
170
|
break unless valid_file
|
|
@@ -170,16 +172,40 @@ module Bundler
|
|
|
170
172
|
data = index_f.read
|
|
171
173
|
|
|
172
174
|
require_relative "../yaml_serializer"
|
|
173
|
-
|
|
175
|
+
loaded = YAMLSerializer.load(data)
|
|
176
|
+
# Bundler 4.1 writes empty sections as "{}", which this serializer
|
|
177
|
+
# reads as a string.
|
|
178
|
+
index = %w[commands hooks load_paths plugin_paths sources].to_h do |key|
|
|
179
|
+
[key, loaded[key].is_a?(Hash) ? loaded[key] : {}]
|
|
180
|
+
end
|
|
174
181
|
|
|
175
182
|
@commands.merge!(index["commands"])
|
|
176
183
|
@hooks.merge!(index["hooks"])
|
|
177
|
-
@load_paths.merge!(index["load_paths"])
|
|
178
|
-
@plugin_paths.merge!(index["plugin_paths"])
|
|
184
|
+
@load_paths.merge!(absolutize_paths(index["load_paths"], base))
|
|
185
|
+
@plugin_paths.merge!(absolutize_paths(index["plugin_paths"], base))
|
|
179
186
|
@sources.merge!(index["sources"]) unless global
|
|
180
187
|
end
|
|
181
188
|
end
|
|
182
189
|
|
|
190
|
+
# Bundler 4.1 records the paths of a plugin installed in the plugin root
|
|
191
|
+
# relative to it.
|
|
192
|
+
def absolutize_paths(paths, base)
|
|
193
|
+
paths.transform_values do |value|
|
|
194
|
+
if value.is_a?(Array)
|
|
195
|
+
value.map {|path| absolutize_path(path, base) }
|
|
196
|
+
else
|
|
197
|
+
absolutize_path(value, base)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def absolutize_path(path, base)
|
|
203
|
+
pathname = Pathname.new(path)
|
|
204
|
+
return path if pathname.absolute?
|
|
205
|
+
|
|
206
|
+
Pathname.new(base).join(pathname).to_s
|
|
207
|
+
end
|
|
208
|
+
|
|
183
209
|
# Should be called when any of the instance variables change. Stores the
|
|
184
210
|
# instance variables in YAML format. (The instance variables are supposed
|
|
185
211
|
# to be only String key value pairs)
|
|
@@ -137,8 +137,10 @@ module Bundler
|
|
|
137
137
|
names_to_allow_remote_specs_for = []
|
|
138
138
|
extended_explanation = nil
|
|
139
139
|
|
|
140
|
+
satisfiers = []
|
|
140
141
|
while incompatibility.conflict?
|
|
141
142
|
cause = incompatibility.cause
|
|
143
|
+
satisfiers << cause.satisfier
|
|
142
144
|
incompatibility = cause.incompatibility
|
|
143
145
|
|
|
144
146
|
incompatibility.terms.each do |term|
|
|
@@ -147,7 +149,7 @@ module Bundler
|
|
|
147
149
|
|
|
148
150
|
if base_requirements[name]
|
|
149
151
|
names_to_unlock << name
|
|
150
|
-
elsif package
|
|
152
|
+
elsif filtered_prereleases?(package)
|
|
151
153
|
names_to_allow_prereleases_for << name
|
|
152
154
|
elsif package.prefer_local? && @all_specs[name].any? {|s| !s.is_a?(StubSpecification) }
|
|
153
155
|
names_to_allow_remote_specs_for << name
|
|
@@ -160,6 +162,11 @@ module Bundler
|
|
|
160
162
|
end
|
|
161
163
|
end
|
|
162
164
|
|
|
165
|
+
# Preserve the usual retry order when it can already resolve the conflict.
|
|
166
|
+
if names_to_unlock.empty? && names_to_allow_prereleases_for.empty? && names_to_allow_remote_specs_for.empty?
|
|
167
|
+
names_to_allow_prereleases_for = prerelease_names_in(satisfiers)
|
|
168
|
+
end
|
|
169
|
+
|
|
163
170
|
[names_to_unlock.uniq, names_to_allow_prereleases_for.uniq, names_to_allow_remote_specs_for.uniq, extended_explanation]
|
|
164
171
|
end
|
|
165
172
|
|
|
@@ -321,8 +328,10 @@ module Bundler
|
|
|
321
328
|
"Gemfile"
|
|
322
329
|
end
|
|
323
330
|
|
|
324
|
-
def raise_incomplete!(incomplete_specs)
|
|
325
|
-
|
|
331
|
+
def raise_incomplete!(incomplete_specs, platform = nil)
|
|
332
|
+
spec = incomplete_specs.first
|
|
333
|
+
# An unresolved dependency may be missing for a different resolution platform.
|
|
334
|
+
raise_not_found!(@base.get_package(spec.name), spec.version && platform)
|
|
326
335
|
end
|
|
327
336
|
|
|
328
337
|
def sort_versions_by_preferred(package, versions)
|
|
@@ -331,7 +340,7 @@ module Bundler
|
|
|
331
340
|
|
|
332
341
|
private
|
|
333
342
|
|
|
334
|
-
def raise_not_found!(package)
|
|
343
|
+
def raise_not_found!(package, platform = nil)
|
|
335
344
|
name = package.name
|
|
336
345
|
source = source_for(name)
|
|
337
346
|
specs = @all_specs[name]
|
|
@@ -347,7 +356,7 @@ module Bundler
|
|
|
347
356
|
not_found_message = if specs_matching_requirement.any?
|
|
348
357
|
specs = specs_matching_requirement
|
|
349
358
|
matching_part = requirement_label
|
|
350
|
-
platforms = package.platforms
|
|
359
|
+
platforms = platform ? [platform] : package.platforms
|
|
351
360
|
|
|
352
361
|
if platforms.size == 1
|
|
353
362
|
"Could not find gem '#{requirement_label}' with platform '#{platforms.first}'"
|
|
@@ -414,6 +423,30 @@ module Bundler
|
|
|
414
423
|
filter_remote_specs(filter_cooldown(filter_prereleases(specs, package)), package)
|
|
415
424
|
end
|
|
416
425
|
|
|
426
|
+
def prerelease_names_in(incompatibilities)
|
|
427
|
+
seen = {}.compare_by_identity
|
|
428
|
+
packages = []
|
|
429
|
+
while (incompatibility = incompatibilities.pop)
|
|
430
|
+
next if seen[incompatibility]
|
|
431
|
+
seen[incompatibility] = true
|
|
432
|
+
|
|
433
|
+
if incompatibility.conflict?
|
|
434
|
+
cause = incompatibility.cause
|
|
435
|
+
incompatibilities.push(cause.incompatibility, cause.satisfier)
|
|
436
|
+
else
|
|
437
|
+
incompatibility.terms.each {|term| packages << term.package }
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
packages.uniq.filter_map do |package|
|
|
442
|
+
package.name if !base_requirements[package.name] && filtered_prereleases?(package)
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def filtered_prereleases?(package)
|
|
447
|
+
package.ignores_prereleases? && @all_specs[package.name].any? {|s| s.version.prerelease? }
|
|
448
|
+
end
|
|
449
|
+
|
|
417
450
|
def filter_prereleases(specs, package)
|
|
418
451
|
return specs unless package.ignores_prereleases? && specs.size > 1
|
|
419
452
|
|
|
@@ -573,6 +606,13 @@ module Bundler
|
|
|
573
606
|
versions = versions_for(dep_package, dep_range)
|
|
574
607
|
end
|
|
575
608
|
|
|
609
|
+
if versions.empty? && locked_version_missing?(dep_package)
|
|
610
|
+
@base.unlock_names([name])
|
|
611
|
+
@all_versions.delete(dep_package)
|
|
612
|
+
@sorted_versions.delete(dep_package)
|
|
613
|
+
versions = versions_for(dep_package, dep_range)
|
|
614
|
+
end
|
|
615
|
+
|
|
576
616
|
if versions.empty? && select_all_versions(dep_package, dep_range).any?
|
|
577
617
|
raise_all_versions_filtered_out!(dep_package)
|
|
578
618
|
end
|
|
@@ -585,6 +625,16 @@ module Bundler
|
|
|
585
625
|
end.to_h
|
|
586
626
|
end
|
|
587
627
|
|
|
628
|
+
def locked_version_missing?(package)
|
|
629
|
+
return false unless package.unlock?
|
|
630
|
+
|
|
631
|
+
name = package.name
|
|
632
|
+
version = package.locked_version
|
|
633
|
+
return false unless base_requirements[name]&.requirements == [[">=", version]]
|
|
634
|
+
|
|
635
|
+
source_for(name).specs.search([name, version]).empty?
|
|
636
|
+
end
|
|
637
|
+
|
|
588
638
|
def select_all_versions(package, range)
|
|
589
639
|
range.select_versions(@all_versions[package])
|
|
590
640
|
end
|
|
@@ -140,14 +140,14 @@ module Bundler
|
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
def incomplete_for_platform?(deps, platform)
|
|
143
|
+
return false if @specs.empty?
|
|
144
|
+
|
|
143
145
|
incomplete_specs_for_platform(deps, platform).any?
|
|
144
146
|
end
|
|
145
147
|
|
|
146
148
|
def incomplete_specs_for_platform(deps, platform)
|
|
147
|
-
return [] if @specs.empty?
|
|
148
|
-
|
|
149
149
|
validation_set = self.class.new(@specs)
|
|
150
|
-
validation_set.for(deps, [platform])
|
|
150
|
+
validation_set.for(deps.select {|dep| dep.should_include?(platform) }, [platform])
|
|
151
151
|
validation_set.incomplete_specs
|
|
152
152
|
end
|
|
153
153
|
|
|
@@ -12,7 +12,7 @@ module CoreExtensions
|
|
|
12
12
|
CONNECTION_TIMEOUT = 5
|
|
13
13
|
IPV4_DELAY_SECONDS = 0.1
|
|
14
14
|
|
|
15
|
-
def initialize(host, serv,
|
|
15
|
+
def initialize(host, serv, ...)
|
|
16
16
|
mutex = Thread::Mutex.new
|
|
17
17
|
addrs = []
|
|
18
18
|
threads = []
|
|
@@ -45,7 +45,7 @@ module CoreExtensions
|
|
|
45
45
|
|
|
46
46
|
threads.each {|t| t.kill.join if t.alive? }
|
|
47
47
|
|
|
48
|
-
super(host, serv,
|
|
48
|
+
super(host, serv, ...)
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
data/lib/rubygems/package/old.rb
CHANGED
|
@@ -79,10 +79,10 @@ class Gem::Package::Old < Gem::Package
|
|
|
79
79
|
raise Gem::Package::FormatError, "#{full_name} in #{@gem} is corrupt" if
|
|
80
80
|
file_data.length != entry["size"].to_i
|
|
81
81
|
|
|
82
|
-
FileUtils.mkdir_p File.dirname(destination), mode: dir_mode && 0o755
|
|
83
|
-
|
|
84
82
|
verify_extraction_dir File.dirname(destination), destination_dir
|
|
85
83
|
|
|
84
|
+
FileUtils.mkdir_p File.dirname(destination), mode: dir_mode && 0o755
|
|
85
|
+
|
|
86
86
|
FileUtils.rm_rf destination
|
|
87
87
|
|
|
88
88
|
File.open destination, "wb", file_mode(entry["mode"]) do |out|
|
data/lib/rubygems/package.rb
CHANGED
|
@@ -432,6 +432,10 @@ EOM
|
|
|
432
432
|
|
|
433
433
|
def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
|
|
434
434
|
destination_dir = File.realpath(destination_dir)
|
|
435
|
+
# File.umask sets the process umask to 0 while reading it, so read it once
|
|
436
|
+
# instead of per file to keep other threads' files from being created
|
|
437
|
+
# world-writable.
|
|
438
|
+
umask = File.umask
|
|
435
439
|
|
|
436
440
|
directories = []
|
|
437
441
|
symlinks = []
|
|
@@ -455,7 +459,7 @@ EOM
|
|
|
455
459
|
raise Gem::Package::SymlinkError.new(full_name, real_destination, destination_dir) unless
|
|
456
460
|
normalize_path(real_destination).start_with? normalize_path(destination_dir + "/")
|
|
457
461
|
|
|
458
|
-
symlinks << [full_name, link_target, destination
|
|
462
|
+
symlinks << [full_name, link_target, destination]
|
|
459
463
|
end
|
|
460
464
|
|
|
461
465
|
mkdir =
|
|
@@ -465,13 +469,13 @@ EOM
|
|
|
465
469
|
File.dirname destination
|
|
466
470
|
end
|
|
467
471
|
|
|
472
|
+
verify_extraction_dir mkdir, destination_dir
|
|
473
|
+
|
|
468
474
|
unless directories.include?(mkdir)
|
|
469
|
-
FileUtils.mkdir_p mkdir, mode: dir_mode ? 0o755 : (entry.header.mode & 0o777 if entry.directory?)
|
|
475
|
+
FileUtils.mkdir_p mkdir, mode: dir_mode ? 0o755 : (entry.header.mode & 0o777 & ~umask if entry.directory?)
|
|
470
476
|
directories << mkdir
|
|
471
477
|
end
|
|
472
478
|
|
|
473
|
-
verify_extraction_dir mkdir, destination_dir
|
|
474
|
-
|
|
475
479
|
if entry.file?
|
|
476
480
|
File.open(destination, "wb") do |out|
|
|
477
481
|
copy_stream(tar.io, out, entry.size)
|
|
@@ -479,7 +483,7 @@ EOM
|
|
|
479
483
|
# in the IO buffer that needs to be written, and that could be
|
|
480
484
|
# written after the chmod (on close) which would mess up the perms
|
|
481
485
|
out.flush
|
|
482
|
-
out.chmod file_mode(entry.header.mode) & ~
|
|
486
|
+
out.chmod file_mode(entry.header.mode) & ~umask
|
|
483
487
|
end
|
|
484
488
|
end
|
|
485
489
|
|
|
@@ -487,12 +491,21 @@ EOM
|
|
|
487
491
|
end
|
|
488
492
|
end
|
|
489
493
|
|
|
490
|
-
symlinks.each do |name, target, destination
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
494
|
+
symlinks.each do |name, target, destination|
|
|
495
|
+
# The check above expands ".." lexically, so a target that walks
|
|
496
|
+
# through another symlink in the gem is only known once resolved.
|
|
497
|
+
real_destination = begin
|
|
498
|
+
resolve_symlink_target(target, File.dirname(destination))
|
|
499
|
+
rescue SystemCallError
|
|
500
|
+
gem_name = @spec ? @spec.full_name : "unknown"
|
|
501
|
+
alert_warning "#{gem_name} ships with a dangling symlink named #{name} pointing to missing #{target} file. Ignoring"
|
|
502
|
+
next
|
|
495
503
|
end
|
|
504
|
+
|
|
505
|
+
raise Gem::Package::SymlinkError.new(name, real_destination, destination_dir) unless
|
|
506
|
+
normalize_path(real_destination).start_with? normalize_path(destination_dir + "/")
|
|
507
|
+
|
|
508
|
+
create_symlink(target, destination)
|
|
496
509
|
end
|
|
497
510
|
|
|
498
511
|
if dir_mode
|
|
@@ -688,10 +701,13 @@ EOM
|
|
|
688
701
|
|
|
689
702
|
##
|
|
690
703
|
# Raises an exception unless +dir+, with symlinks resolved, is
|
|
691
|
-
# +destination_dir+ or a directory inside it. +
|
|
692
|
-
#
|
|
704
|
+
# +destination_dir+ or a directory inside it. When +dir+ does not exist
|
|
705
|
+
# yet, its nearest existing ancestor is checked instead, so this can run
|
|
706
|
+
# before +dir+ is created. +destination_dir+ must already be resolved with
|
|
707
|
+
# File.realpath by the caller.
|
|
693
708
|
|
|
694
709
|
def verify_extraction_dir(dir, destination_dir) # :nodoc:
|
|
710
|
+
dir = File.dirname(dir) until File.exist?(dir)
|
|
695
711
|
real_dir = File.realpath(dir)
|
|
696
712
|
|
|
697
713
|
return if real_dir == destination_dir ||
|
|
@@ -700,6 +716,23 @@ EOM
|
|
|
700
716
|
raise Gem::Package::PathError.new(real_dir, destination_dir)
|
|
701
717
|
end
|
|
702
718
|
|
|
719
|
+
##
|
|
720
|
+
# Resolves the symlink +target+ against +dir+ one component at a time.
|
|
721
|
+
# File.realpath on JRuby and TruffleRuby folds ".." before following
|
|
722
|
+
# symlinks, so ".." is applied here to the already resolved path instead.
|
|
723
|
+
|
|
724
|
+
def resolve_symlink_target(target, dir) # :nodoc:
|
|
725
|
+
root = target[%r{\A(?:[A-Za-z]:)?/}] if target.start_with?("/") || File.absolute_path?(target)
|
|
726
|
+
|
|
727
|
+
target.delete_prefix(root.to_s).split("/").inject(File.realpath(File.expand_path(root || dir))) do |current, name|
|
|
728
|
+
case name
|
|
729
|
+
when "", "." then current
|
|
730
|
+
when ".." then File.dirname(current)
|
|
731
|
+
else File.realpath(name, current)
|
|
732
|
+
end
|
|
733
|
+
end
|
|
734
|
+
end
|
|
735
|
+
|
|
703
736
|
##
|
|
704
737
|
# Verifies the +checksums+ against the +digests+. This check is not
|
|
705
738
|
# cryptographically secure. Missing checksums are ignored.
|
data/lib/rubygems.rb
CHANGED