[前][次][番号順一覧][スレッド一覧]

ruby-changes:54943

From: usa <ko1@a...>
Date: Thu, 28 Feb 2019 23:55:11 +0900 (JST)
Subject: [ruby-changes:54943] usa:r67148 (ruby_2_4): merge revision(s) 66909: [Backport #15555]

usa	2019-02-28 23:55:05 +0900 (Thu, 28 Feb 2019)

  New Revision: 67148

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67148

  Log:
    merge revision(s) 66909: [Backport #15555]
    
    tmpdir.rb: permission of user given directory
    
    * lib/tmpdir.rb (Dir.mktmpdir): check if the permission of the
      parent directory only when using the default temporary
      directory, and no check against user given directory.  the
      security is the user's responsibility in that case.
      [ruby-core:91216] [Bug #15555]

  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/lib/tmpdir.rb
    branches/ruby_2_4/test/test_tmpdir.rb
    branches/ruby_2_4/version.h
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 67147)
+++ ruby_2_4/version.h	(revision 67148)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.6"
 #define RUBY_RELEASE_DATE "2019-02-28"
-#define RUBY_PATCHLEVEL 348
+#define RUBY_PATCHLEVEL 349
 
 #define RUBY_RELEASE_YEAR 2019
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_4/lib/tmpdir.rb
===================================================================
--- ruby_2_4/lib/tmpdir.rb	(revision 67147)
+++ ruby_2_4/lib/tmpdir.rb	(revision 67148)
@@ -83,14 +83,20 @@ class Dir https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/tmpdir.rb#L83
   #  end
   #
   def self.mktmpdir(prefix_suffix=nil, *rest)
-    path = Tmpname.create(prefix_suffix || "d", *rest) {|n| mkdir(n, 0700)}
+    base = nil
+    path = Tmpname.create(prefix_suffix || "d", *rest) {|path, _, _, d|
+      base = d
+      mkdir(path, 0700)
+    }
     if block_given?
       begin
         yield path
       ensure
-        stat = File.stat(File.dirname(path))
-        if stat.world_writable? and !stat.sticky?
-          raise ArgumentError, "parent directory is world writable but not sticky"
+        unless base
+          stat = File.stat(File.dirname(path))
+          if stat.world_writable? and !stat.sticky?
+            raise ArgumentError, "parent directory is world writable but not sticky"
+          end
         end
         FileUtils.remove_entry path
       end
@@ -124,12 +130,13 @@ class Dir https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/tmpdir.rb#L130
       if $SAFE > 0 and tmpdir.tainted?
         tmpdir = '/tmp'
       else
+        origdir = tmpdir
         tmpdir ||= tmpdir()
       end
       n = nil
       begin
         path = File.join(tmpdir, make_tmpname(basename, n))
-        yield(path, n, opts)
+        yield(path, n, opts, origdir)
       rescue Errno::EEXIST
         n ||= 0
         n += 1
Index: ruby_2_4/test/test_tmpdir.rb
===================================================================
--- ruby_2_4/test/test_tmpdir.rb	(revision 67147)
+++ ruby_2_4/test/test_tmpdir.rb	(revision 67148)
@@ -31,6 +31,12 @@ class TestTmpdir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/test_tmpdir.rb#L31
         assert_equal(tmpdir, Dir.tmpdir)
         File.chmod(0777, tmpdir)
         assert_not_equal(tmpdir, Dir.tmpdir)
+        newdir = Dir.mktmpdir("d", tmpdir) do |dir|
+          assert_file.directory? dir
+          assert_equal(tmpdir, File.dirname(dir))
+          dir
+        end
+        assert_file.not_exist?(newdir)
         File.chmod(01777, tmpdir)
         assert_equal(tmpdir, Dir.tmpdir)
       ensure
Index: ruby_2_4
===================================================================
--- ruby_2_4	(revision 67147)
+++ ruby_2_4	(revision 67148)

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r66909

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]