1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/rubygems
Kevin Newton 68a5b0f086 [rubygems/rubygems] Mask the file mode when extracting files
When extracting files from the tarball, a mode is retrieved from
the header. Occasionally you'll encounter a gem that was packaged
on a system whose permission bits result in a value that is larger
than the value that File.chmod will allow (anything >= 2^16). In
that case the extraction fails with a RangeError, which is pretty
esoteric.

If you extract the tarball with the tar and gunzip utilities, the
file permissions end up being just the bottom 16 bits masked off
from the original value. I've mirrored that behavior here. Per the
tar spec:

> Modes which are not supported by the operating system restoring
> files from the archive will be ignored.

I think that basically means what I've done here.

---

This commit also changes the behavior very slightly with regard to
when the chmod is called. Previously it was called while the file
descriptor was still open, but after the write call.

When write flushes, the file permissions are changed to the mode
value from the File.open call, undoing the changes made by
FileUtils.chmod. CRuby appears to flush the buffer after the
chmod call, whereas TruffleRuby flushes before the chmod call.
So the file permissions can change depending on implementation.
Both implementations end up getting the correct file permissions
for the bottom 9 bits (user, group, world), but differ with
regard to the sticky bit in the next 3.

To get consistent behavior, this commit changes it to close the
file descriptor before attempting to chmod anything, which makes
it consistent because the write flushes in both cases.

https://github.com/rubygems/rubygems/commit/22ce076e99
2022-09-15 14:49:20 +09:00
..
commands Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
core_ext Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
ext Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
optparse Merge 3f7d0352e8 2022-04-28 19:08:49 +09:00
package Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
request Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
request_set Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
resolver Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
security Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
source Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
ssl_certs
tsort
util RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
available_set.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
basic_specification.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
bundler_version_finder.rb [rubygems/rubygems] Normalize end alignment style with Bundler 2022-01-19 11:20:36 +09:00
command.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
command_manager.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
compatibility.rb [rubygems/rubygems] Move :stopdoc: directive 2022-03-15 01:18:03 +09:00
config_file.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
defaults.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
dependency.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
dependency_installer.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
dependency_list.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
deprecate.rb
doctor.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
errors.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
exceptions.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
ext.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
gem_runner.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
gemcutter_utilities.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
indexer.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
install_default_message.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
install_message.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
install_update_options.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
installer.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
installer_uninstaller_utils.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
local_remote_options.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
mock_gem_ui.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
name_tuple.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
openssl.rb
optparse.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
package.rb [rubygems/rubygems] Mask the file mode when extracting files 2022-09-15 14:49:20 +09:00
package_task.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
path_support.rb
platform.rb [rubygems/rubygems] Support non gnu libc arm-linux-eabi platforms 2022-09-01 15:01:40 +09:00
psych_tree.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
query_utils.rb [rubygems/rubygems] Fix: Gem info bug with version flag 2022-09-07 06:18:58 +09:00
rdoc.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
remote_fetcher.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
request.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
request_set.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
requirement.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
resolver.rb [rubygems/rubygems] Fix resolution on non-musl platforms 2022-09-09 19:38:52 +09:00
s3_uri_signer.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
safe_yaml.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
security.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
security_option.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
source.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
source_list.rb Sync RubyGems & Bundler with upstream repo 2022-06-24 10:52:02 +09:00
spec_fetcher.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
specification.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
specification_policy.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
stub_specification.rb Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
text.rb [DOC] Change URLs from git.io 2022-04-27 10:13:23 +09:00
tsort.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
uninstaller.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
unknown_command_spell_checker.rb
uri.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
uri_formatter.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
user_interaction.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
util.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00
validator.rb Merge rubygems/bundler HEAD 2022-08-03 13:14:10 +09:00
version.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
version_option.rb RubyGems: Enable Style/StringLiterals cop 2022-07-22 12:07:23 +09:00