From 84bb8e81c25d4d7d6020c3acfbbc36e9064200fa Mon Sep 17 00:00:00 2001 From: mame Date: Tue, 15 May 2018 04:16:08 +0000 Subject: Revert "Merge fileutils-1.1.0." This reverts commit 99da3d2570e110d3024039102205f6d64174bf5e. The change caused the following build failure: ``` .../ruby/lib/fileutils.rb:88:in `require': cannot load such file -- rbconfig (LoadError) uncommon.mk:987: recipe for target 'encdb.h' failed make: *** [encdb.h] Error 1 ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/fileutils.gemspec | 6 ++--- lib/fileutils.rb | 66 ++++++++++++++++----------------------------------- 2 files changed, 23 insertions(+), 49 deletions(-) (limited to 'lib') diff --git a/lib/fileutils.gemspec b/lib/fileutils.gemspec index a72b878810..5e11587aab 100644 --- a/lib/fileutils.gemspec +++ b/lib/fileutils.gemspec @@ -1,14 +1,14 @@ # frozen_string_literal: true - Gem::Specification.new do |s| s.name = "fileutils" - s.version = '1.1.0' + s.version = '1.0.2' + s.date = '2017-12-22' s.summary = "Several file utility methods for copying, moving, removing, etc." s.description = "Several file utility methods for copying, moving, removing, etc." s.require_path = %w{lib} s.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "fileutils.gemspec", "lib/fileutils.rb"] - s.required_ruby_version = ">= 2.3.0" + s.required_ruby_version = ">= 2.4.0" s.authors = ["Minero Aoki"] s.email = [nil] diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 7cbc6f46fa..88e28f29d5 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -85,11 +85,9 @@ # :verbose flags to methods in FileUtils. # -require 'rbconfig' - module FileUtils - VERSION = "1.1.0" + VERSION = "1.0.2" def self.private_module_function(name) #:nodoc: module_function name @@ -121,9 +119,8 @@ module FileUtils # def cd(dir, verbose: nil, &block) # :yield: dir fu_output_message "cd #{dir}" if verbose - result = Dir.chdir(dir, &block) + Dir.chdir(dir, &block) fu_output_message 'cd -' if verbose and block - result end module_function :cd @@ -544,7 +541,7 @@ module FileUtils module_function :move def rename_cannot_overwrite_file? #:nodoc: - /emx/ =~ RbConfig::CONFIG['host_os'] + /emx/ =~ RUBY_PLATFORM end private_module_function :rename_cannot_overwrite_file? @@ -684,38 +681,22 @@ module FileUtils unless parent_st.sticky? raise ArgumentError, "parent directory is world writable, FileUtils#remove_entry_secure does not work; abort: #{path.inspect} (parent directory mode #{'%o' % parent_st.mode})" end - # freeze tree root euid = Process.euid - dot_file = fullpath + "/." - begin - File.open(dot_file) {|f| - unless fu_stat_identical_entry?(st, f.stat) - # symlink (TOC-to-TOU attack?) - File.unlink fullpath - return - end - f.chown euid, -1 - f.chmod 0700 - } - rescue 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?) - File.unlink fullpath - return - end - File.chown euid, -1, dot_file - File.chmod 0700, dot_file - } - end - - unless fu_stat_identical_entry?(st, File.lstat(fullpath)) - # TOC-to-TOU attack? - File.unlink fullpath - return - end - + File.open(fullpath + '/.') {|f| + unless fu_stat_identical_entry?(st, f.stat) + # symlink (TOC-to-TOU attack?) + File.unlink fullpath + return + end + f.chown euid, -1 + f.chmod 0700 + unless fu_stat_identical_entry?(st, File.lstat(fullpath)) + # TOC-to-TOU attack? + File.unlink fullpath + return + end + } # ---- tree root is frozen ---- root = Entry_.new(path) root.preorder_traverse do |ent| @@ -816,15 +797,8 @@ module FileUtils # def compare_stream(a, b) bsize = fu_stream_blksize(a, b) - - if RUBY_VERSION > "2.4" - sa = String.new(capacity: bsize) - sb = String.new(capacity: bsize) - else - sa = String.new - sb = String.new - end - + sa = String.new(capacity: bsize) + sb = String.new(capacity: bsize) begin a.read(bsize, sa) b.read(bsize, sb) @@ -1149,7 +1123,7 @@ module FileUtils private def fu_windows? - /mswin|mingw|bccwin|emx/ =~ RbConfig::CONFIG['host_os'] + /mswin|mingw|bccwin|emx/ =~ RUBY_PLATFORM end def fu_copy_stream0(src, dest, blksize = nil) #:nodoc: -- cgit v1.2.3