summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-18 12:02:52 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-18 12:02:52 +0000
commitb593b831d3caee7620ce028a0171cc0c7280d861 (patch)
treed7d0337ae53b7955f4560df2a186f7c6c22b5a0c
parent4fdfac491a95b99ad782991d9eaaa35456f897b5 (diff)
merges r30896 from trunk into ruby_1_9_2.
-- * lib/fileutils.rb (FileUtils::remove_entry_secure): there is a race condition in the case where the given path is a directory, and some other user can move that directory, and create a symlink while this method is executing. Reported by: Nicholas Jefferson <nicholas at pythonic.com.au> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--lib/fileutils.rb13
-rw-r--r--version.h2
3 files changed, 18 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 3cba4a4fe7..a02d89ee06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Feb 18 19:31:31 2011 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/fileutils.rb (FileUtils::remove_entry_secure): there is a
+ race condition in the case where the given path is a directory,
+ and some other user can move that directory, and create a
+ symlink while this method is executing.
+ Reported by: Nicholas Jefferson <nicholas at pythonic.com.au>
+
Sat Jan 29 22:16:26 2011 NARUSE, Yui <naruse@ruby-lang.org>
* array.c (rb_ary_join): [].join.encoding must be US-ASCII.
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 73e2bfe3c3..7cc223c17e 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -667,10 +667,10 @@ module FileUtils
# removing directories. This requires the current process is the
# owner of the removing whole directory tree, or is the super user (root).
#
- # WARNING: You must ensure that *ALL* parent directories are not
- # world writable. Otherwise this method does not work.
- # Only exception is temporary directory like /tmp and /var/tmp,
- # whose permission is 1777.
+ # WARNING: You must ensure that *ALL* parent directories cannot be
+ # moved by other untrusted users. For example, parent directories
+ # should not be owned by untrusted users, and should not be world
+ # writable except when the sticky bit set.
#
# WARNING: Only the owner of the removing directory tree, or Unix super
# user (root) should invoke this method. Otherwise this method does not
@@ -713,6 +713,11 @@ module FileUtils
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)
diff --git a/version.h b/version.h
index 7ae81ecfcf..fc14306a00 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 179
+#define RUBY_PATCHLEVEL 180
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1