diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-06 07:14:13 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-06 07:14:13 +0000 |
commit | 470a7046d45b4a16c457698137326c8ce212d459 (patch) | |
tree | 3f26af7f53b1e27a1948ee67a22a79c13bd809be | |
parent | 1c8f0c55501ca97ea11d3009244a011293ac3df1 (diff) |
merge revision(s) 66972: [Backport #15577]
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/branches/ruby_2_6@67177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/fileutils.rb | 2 | ||||
-rw-r--r-- | test/fileutils/test_fileutils.rb | 8 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index dc7261857b..8981ef98e8 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -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?) diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index f2600005f5..64dd2464c0 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -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 @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.6.1" #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 34 +#define RUBY_PATCHLEVEL 35 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 3 |