1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib
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
..
benchmark [ruby/benchmark] Freeze VERSION 2021-12-18 08:38:58 +09:00
bundler Remove warning for old TLS version connection 2022-09-15 14:48:47 +09:00
cgi [ruby/cgi] Implement CGI.url_encode and CGI.url_decode 2022-08-16 19:12:03 +09:00
csv [ruby/csv] Revert "parser: fix a keep bug that some texts may be dropped unexpectedly" 2021-12-24 14:35:33 +09:00
delegate [ruby/delegate] gemspec: Drop unused executables directives 2021-10-22 19:48:22 +09:00
did_you_mean [ruby/did_you_mean] Fixed correction duplicates in VariableNameChecker 2022-09-01 19:47:39 +09:00
drb lib/drb/drb.rb: Prevent a "warning: assigned but unused variable" 2022-01-17 14:56:11 +09:00
erb
error_highlight [ruby/error_highlight] Apply ErrorHighlight::CoreExt to TypeError and ArgumentError 2022-08-19 18:34:15 +09:00
forwardable [ruby/forwardable] Move :stopdoc: directive 2022-03-14 14:44:46 +09:00
getoptlong
irb [ruby/irb] Fix the error when LC_MESSAGES config value is nil 2022-09-14 11:14:08 +09:00
logger [ruby/logger] Enhanced RDoc for Logger 2022-05-13 22:52:53 +09:00
mjit MJIT: Use the built-in PACK_MAP 2022-09-11 15:39:40 +09:00
net [ruby/net-protocol] Improve BufferedIO performance 2022-08-31 12:37:49 +09:00
observer
open3 Fixed filename for Open3::VERSION 2021-12-09 19:48:22 +09:00
optparse [ruby/optparse] Add rdoc options 2022-01-12 21:16:01 +09:00
ostruct [ruby/ostruct] Drop unused directives from gemspec (https://github.com/ruby/ostruct/pull/39) 2022-03-07 20:08:29 +09:00
pstore
racc Update parser-text.rb with 4ecc13c9cb 2022-07-29 19:10:10 +09:00
random [ruby/securerandom] Use String#unpack1 2021-12-14 11:59:22 +09:00
rdoc [ruby/rdoc] Allow multiple footnotes without in-between blank lines 2022-08-08 01:12:49 +09:00
reline [ruby/reline] Fix a typo [ci skip] 2022-09-03 03:27:58 +09:00
rinda [ruby/rinda] Bump up rinda version to 0.1.1 2021-10-21 21:02:37 +09:00
rubygems [rubygems/rubygems] Mask the file mode when extracting files 2022-09-15 14:49:20 +09:00
set [ruby/set] Bump version to 1.0.3 2022-09-06 10:41:20 +09:00
singleton
syntax_suggest Sync SyntaxSuggest 2022-08-19 10:02:24 +09:00
timeout [ruby/timeout] gemspec: Drop unused directives "executables" 2022-07-14 16:21:25 +09:00
unicode_normalize [DOC] hide UnicodeNormalize in module index 2022-03-14 15:01:20 +09:00
uri [ruby/uri] Improve URI.register_scheme tests and automatically upcase the given scheme 2022-05-12 18:19:17 +09:00
weakref
yaml [ruby/yaml] Bump up yaml version to 0.2.0 2021-10-14 20:16:04 +09:00
abbrev.gemspec
abbrev.rb
base64.gemspec [ruby/base64] Bump up base64 version to 0.1.1 2021-10-14 20:41:15 +09:00
base64.rb
benchmark.rb
bundler.rb Merge 16c3535413 2022-09-05 14:37:12 +09:00
cgi.rb Fix broken links of rdoc 2022-03-17 10:11:38 +09:00
csv.rb [ruby/csv] Add handling for ambiguous parsing options (https://github.com/ruby/csv/pull/226) 2021-12-24 14:35:33 +09:00
delegate.rb Kernel#=~: delete 2022-01-03 22:33:38 +09:00
did_you_mean.rb Sync did_you_mean 2021-12-24 23:20:30 +09:00
drb.rb
English.gemspec [ruby/English] gemspec: Remove unused "executables" configuration 2021-12-09 19:28:53 +09:00
English.rb
erb.gemspec
erb.rb [ruby/erb] Revert "Remove safe_level and further positional arguments (https://github.com/ruby/erb/pull/7)" 2022-01-17 12:39:17 -08:00
error_highlight.rb
fileutils.gemspec
fileutils.rb [ruby/fileutils] FileUtils.rm* methods swallows only Errno::ENOENT when force is true 2022-08-23 16:52:41 +09:00
find.gemspec [ruby/find] Bump up find version to 0.1.1 2021-10-14 20:26:15 +09:00
find.rb
forwardable.rb [ruby/forwardable] Freeze VERSION and FORWARDABLE_VERSION to improve Ractor-compliance 2022-09-08 14:31:42 +09:00
getoptlong.rb [ruby/getoptlong] Fixup https://github.com/ruby/getoptlong/commit/39faa7b390f0 2022-05-09 07:26:29 +09:00
ipaddr.gemspec Support directory layout of ruby/ruby repository 2022-02-10 17:18:05 +09:00
ipaddr.rb [ruby/ipaddr] Improve Ractor-compliance 2022-09-08 14:09:06 +09:00
irb.rb [ruby/irb] [DOC] Include updated help message (https://github.com/ruby/irb/pull/377) 2022-07-12 00:05:15 +09:00
logger.rb [ruby/logger] [DOC] Enhanced RDoc for Logger (https://github.com/ruby/logger/pull/77) 2022-05-14 05:02:18 +09:00
mkmf.rb Use $(bindir) for path to executable in mkmf 2022-08-04 16:29:22 +09:00
mutex_m.gemspec
mutex_m.rb [ruby/mutex_m] Make VERSION shareable 2021-10-22 19:49:34 +09:00
observer.rb
open-uri.gemspec [ruby/open-uri] gemspec: This gem exposes 0 executables 2021-12-09 19:28:54 +09:00
open-uri.rb [ruby/open-uri] [DOC] Fix markup for URI.open 2022-06-07 00:06:56 +09:00
open3.rb [ruby/open3] Update to match JRuby 9.4 2021-12-09 19:28:54 +09:00
optionparser.rb
optparse.rb [ruby/optparse] Also accept '-' as an optional argument (https://github.com/ruby/optparse/pull/35) 2022-07-29 19:10:10 +09:00
ostruct.rb [ruby/ostruct] v0.5.5 2022-04-01 00:18:36 +09:00
pp.gemspec [ruby/pp] Bump version to 0.3.0 2021-12-20 12:44:31 +09:00
pp.rb [ruby/pp] [DOC] Update for PP.width_for [Feature #12913] 2021-12-23 18:00:56 +09:00
prettyprint.gemspec [ruby/prettyprint] Bump up prettyprint version to 0.1.1 2021-10-21 21:05:39 +09:00
prettyprint.rb
pstore.rb [ruby/pstore] Emphasize keys instead of roots, values instead of objects (https://github.com/ruby/pstore/pull/7) 2022-07-07 07:05:01 +09:00
racc.rb
rdoc.rb [ruby/rdoc] Relative loading for easier development (https://github.com/ruby/rdoc/pull/821) 2022-02-12 15:06:06 +09:00
readline.gemspec [ruby/readline] Bump version to 0.0.3 2021-12-24 17:54:09 +09:00
readline.rb [ruby/readline] Suppress constant redefinition warning 2021-11-29 18:50:27 +09:00
reline.rb [ruby/reline] Support dumb terminal 2022-09-01 16:36:16 +09:00
resolv-replace.gemspec
resolv-replace.rb
resolv.gemspec
resolv.rb [ruby/resolv] Support more characters in link local addresses 2022-01-12 10:49:57 +09:00
ruby2_keywords.gemspec
rubygems.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
securerandom.gemspec [ruby/securerandom] Bump up v0.2.0 2022-02-28 20:08:58 +09:00
securerandom.rb lib/securerandom.rb: Fix the check of availability of Random.urandom 2022-02-16 16:32:28 +09:00
set.rb [ruby/set] Fix a typo 2022-05-16 23:43:04 +09:00
shellwords.gemspec
shellwords.rb
singleton.rb
syntax_suggest.rb Sync SyntaxSuggest 2022-08-19 10:02:24 +09:00
tempfile.gemspec [ruby/tempfile] Drop unused gemspec directives 2022-05-20 17:49:14 +09:00
tempfile.rb [ruby/tempfile] Enhanced RDoc for ::new and ::create (https://github.com/ruby/tempfile/pull/10) 2022-05-20 17:49:14 +09:00
time.gemspec [ruby/time] Bump up time version to 0.2.0 2021-10-14 21:14:35 +09:00
time.rb fix typo in Time#xmlschema documentation 2022-07-29 19:10:10 +09:00
timeout.rb [ruby/timeout] Give a name to the background thread 2022-07-13 21:16:15 +09:00
tmpdir.gemspec
tmpdir.rb [ruby/tmpdir] [DOC] Fix syntax in example code [ci skip] 2021-11-11 10:37:35 +09:00
tsort.gemspec
tsort.rb [ruby/tsort] Small tweaks for easier vendoring 2022-04-18 09:40:07 +09:00
un.gemspec
un.rb [ruby/un] Support FileUtils.cp_lr 2022-07-14 16:26:47 +09:00
uri.rb [ruby/uri] Feat: Support WSS 2022-04-22 11:59:54 +09:00
weakref.rb [DOC] Remove outdated note from WeakRef#initialize 2022-03-14 10:50:52 +01:00
yaml.rb [ruby/yaml] Add JRuby-specific warning when psych fails 2022-01-27 17:16:05 +09:00