ruby-changes:54755
From: nobu <ko1@a...>
Date: Thu, 31 Jan 2019 23:02:36 +0900 (JST)
Subject: [ruby-changes:54755] nobu:r66972 (trunk): Fix exception namespace
nobu 2019-01-31 23:02:30 +0900 (Thu, 31 Jan 2019) New Revision: 66972 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66972 Log: 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@t...> Modified files: trunk/lib/fileutils.rb trunk/test/fileutils/test_fileutils.rb Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 66971) +++ lib/fileutils.rb (revision 66972) @@ -695,7 +695,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L695 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?) Index: test/fileutils/test_fileutils.rb =================================================================== --- test/fileutils/test_fileutils.rb (revision 66971) +++ test/fileutils/test_fileutils.rb (revision 66972) @@ -740,7 +740,15 @@ class TestFileUtils < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L740 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/