1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix exception namespace

* lib/fileutils.rb (remove_entry_secure): EISDIR is under the
  Errno namespace.  [ruby-core:91362] [Bug #15577]

From: Tietew (Toru Iwase) <tietew@tietew.net>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2019-01-31 14:02:30 +00:00
parent 1f64192494
commit cb5a329814
2 changed files with 9 additions and 1 deletions

View file

@ -695,7 +695,7 @@ module FileUtils
f.chown euid, -1
f.chmod 0700
}
rescue EISDIR # JRuby in non-native mode can't open files as dirs
rescue Errno::EISDIR # JRuby in non-native mode can't open files as dirs
File.lstat(dot_file).tap {|fstat|
unless fu_stat_identical_entry?(st, fstat)
# symlink (TOC-to-TOU attack?)

View file

@ -740,7 +740,15 @@ class TestFileUtils < Test::Unit::TestCase
remove_entry_secure 'tmp/tmpdir/c', true
assert_file_not_exist 'tmp/tmpdir/a'
assert_file_not_exist 'tmp/tmpdir/c'
File.chmod(01777, 'tmp/tmpdir')
Dir.mkdir 'tmp/tmpdir/d', 0
assert_raise(Errno::EACCES) {remove_entry_secure 'tmp/tmpdir/d'}
File.chmod 0777, 'tmp/tmpdir/d'
Dir.rmdir 'tmp/tmpdir/d'
Dir.rmdir 'tmp/tmpdir'
end
def test_remove_entry_secure_symlink