Skip to content

Commit

Permalink
Revert "Restore world-readable search to tmpdir.rb."
Browse files Browse the repository at this point in the history
This reverts commit e292b95.

This logic is mostly identical to the logic below it, but omits
the important stat.sticky? check that would allow typical Linux
/tmp dirs to be used. I revert this change and will update our
stdlib fork.

Fixes #4184.
  • Loading branch information
headius committed Oct 6, 2016
1 parent 51124a6 commit ee17203
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions lib/ruby/stdlib/tmpdir.rb
Expand Up @@ -23,20 +23,6 @@ def self.tmpdir
@@systmpdir.dup
else
tmp = nil
# Search a directory which isn't world-writable first. In JRuby,
# FileUtils.remove_entry_secure(dir) crashes when a dir is under
# a world-writable directory because it tries to open directory.
# Opening directory is not allowed in Java.
dirs = [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp', '.']
for dir in dirs
if dir and stat = File.stat(dir) and stat.directory? and stat.writable? and !stat.world_writable?
return File.expand_path(dir)
end
end

# Some OS sets the environment variables to '/tmp', which we may reject.
warn "Unable to find a non world-writable directory for #{__method__}. Consider setting ENV['TMPDIR'], ENV['TMP'] or ENV['TEMP'] to a non world-writable directory."

[ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp', '.'].each do |dir|
next if !dir
dir = File.expand_path(dir)
Expand Down

0 comments on commit ee17203

Please sign in to comment.