1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test
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
..
-ext- test/-ext-/eval/test_eval.rb: Prevent "assigned but unused variable" 2022-08-24 10:36:17 +09:00
base64
benchmark
bigdecimal
cgi [ruby/cgi] Implement CGI.url_encode and CGI.url_decode 2022-08-16 19:12:03 +09:00
coverage Fix a regression of b2e58b02ae 2022-07-11 23:38:37 +09:00
csv Respect RUBY_TESTOPTS on test-all (https://github.com/Shopify/ruby/pull/435) 2022-08-29 09:09:41 -07:00
date [ruby/date] Fix Time#to_datetime before calendar reform 2022-08-08 23:50:17 +09:00
did_you_mean [ruby/did_you_mean] Fixed correction duplicates in VariableNameChecker 2022-09-01 19:47:39 +09:00
digest [ruby/digest] Ignore test_ractor.rb on non-Ractor ruby 2022-07-21 11:45:48 +09:00
drb omit random failure tests with FreeBSD 2022-09-06 16:27:12 +09:00
dtrace
erb
error_highlight [ruby/error_highlight] Make backtrace_location keyword work 2022-08-10 21:19:10 +09:00
etc
excludes Now Psych uses the proleptic Gregorian calendar 2022-09-07 10:37:01 +09:00
fiber
fiddle [ruby/fiddle] Fix PACK_MAP for unsigned types (https://github.com/ruby/fiddle/pull/110) 2022-09-11 15:30:49 +09:00
fileutils [ruby/fileutils] FileUtils.rm* methods swallows only Errno::ENOENT when force is true 2022-08-23 16:52:41 +09:00
fixtures/fake_sorted_set_gem
io omit all assertions at TestIO_Console#test_intr when running with FreeBSD 2022-08-23 12:49:46 +09:00
irb [ruby/irb] Refine assertion for failures 2022-09-15 08:25:53 +09:00
json [flori/json] test parsing of unicode, mixing literal characters with escaped 2022-07-29 19:10:10 +09:00
lib Stop testing MJIT on s390x 2022-09-05 02:02:17 -07:00
logger
mkmf Make sure super is called and fix teardown 2022-08-25 11:31:16 -07:00
monitor
net [ruby/net-http] Make Net::HTTPHeader#content_range return nil on non-byte units 2022-06-16 23:35:27 +09:00
nkf
objspace Dump non-ASCII char as unsigned 2022-07-22 09:56:48 +09:00
open-uri
openssl [ruby/openssl] Skip a new test when old OpenSSL 2022-07-09 15:26:32 +09:00
optparse [ruby/optparse] Also accept '-' as an optional argument (https://github.com/ruby/optparse/pull/35) 2022-07-29 19:10:10 +09:00
ostruct
pathname
psych [ruby/psych] Dump Date/DateTime as proleptic Gregorian date as well as Time 2022-09-07 09:44:14 +09:00
racc
rdoc [ruby/rdoc] Allow multiple footnotes without in-between blank lines 2022-08-08 01:12:49 +09:00
readline
reline [ruby/reline] Support dumb terminal 2022-09-01 16:36:16 +09:00
resolv
rinda Skip running a DRb test on MinGW 2022-08-25 11:37:39 -07:00
ripper [Bug #18963] Separate string contents by here document terminator 2022-08-28 09:29:24 +09:00
ruby Remove get_actual_encoding() and the dynamic endian detection for dummy UTF-16/UTF-32 2022-09-12 14:02:34 +02:00
rubygems [rubygems/rubygems] Mask the file mode when extracting files 2022-09-15 14:49:20 +09:00
socket fixup 8cd6f2a087 2022-09-07 09:41:28 +09:00
stringio [ruby/stringio] Fix the result of StringIO#truncate so compatible with File 2022-07-01 00:52:29 +09:00
strscan
syslog
uri
win32ole
yaml
zlib
runner.rb
test_abbrev.rb
test_delegate.rb
test_extlibs.rb
test_find.rb
test_forwardable.rb
test_getoptlong.rb
test_ipaddr.rb
test_mutex_m.rb
test_observer.rb
test_open3.rb
test_pp.rb
test_prettyprint.rb
test_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
test_pty.rb
test_rbconfig.rb
test_securerandom.rb
test_set.rb [ruby/set] Get rid of use of Gem::Version 2022-07-14 17:13:52 +09:00
test_shellwords.rb
test_singleton.rb
test_sorted_set.rb
test_syslog.rb
test_tempfile.rb
test_time.rb
test_timeout.rb
test_tmpdir.rb
test_trick.rb
test_tsort.rb
test_unicode_normalize.rb
test_weakref.rb