You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dir.tmpdir should prefer to provide something in /tmp over something in .
Actual Behavior
Dir.tmpdir chooses . over /tmp because it prefers an user-writable, non-world-writable directory over an user-writable, world-writable directory with sticky bit set.
Thoughts
Temporary files will sometimes accumulate in the application‘s root directory if the application was written with an assumption that things get dumped into /tmp which can be cleared by another script run periodically. In cases where apps are deployed and release-managed with Capistrano this can cause releases to swell and take up more disk space than necessary.
My setup looked like this:
[evadne@ecu-converter-nonprod-1 /]$ ls -al /srv/converter/releases | grep 20170118213914
drwxr-xr-x 14 deployer deployer 77824 Jan 21 18:51 20170118213914
[evadne@ecu-converter-nonprod-1 /]$ ls -la / | grep tmp
drwxrwxrwt 13 root root 49152 Jan 21 16:41 tmp
At this time I have worked around the issue by setting TMPDIR to something in /var/tmp with proper permissions.
I would think that a sensible change would be to not prefer the current directory over somewhere else, as shown in this diff:
diff --git a/lib/ruby/stdlib/tmpdir.rb b/lib/ruby/stdlib/tmpdir.rb
index f62a082..bb4086d 100644
--- a/lib/ruby/stdlib/tmpdir.rb
+++ b/lib/ruby/stdlib/tmpdir.rb
@@ -27,7 +27,7 @@ class Dir
# 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', '.']
+ 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)
Since tmpdir is in MRI's standard library, I do not think we should be patching it here. If you want this change, please report it on https://bugs.ruby-lang.org.
Environment
JRuby: 9.1.5.0
OS: Amazon Linux
Expected Behavior
Dir.tmpdir
should prefer to provide something in/tmp
over something in.
Actual Behavior
Dir.tmpdir
chooses.
over/tmp
because it prefers an user-writable, non-world-writable directory over an user-writable, world-writable directory with sticky bit set.Thoughts
Temporary files will sometimes accumulate in the application‘s root directory if the application was written with an assumption that things get dumped into
/tmp
which can be cleared by another script run periodically. In cases where apps are deployed and release-managed with Capistrano this can cause releases to swell and take up more disk space than necessary.My setup looked like this:
At this time I have worked around the issue by setting
TMPDIR
to something in /var/tmp with proper permissions.I would think that a sensible change would be to not prefer the current directory over somewhere else, as shown in this diff:
See:
#405
#633
The text was updated successfully, but these errors were encountered: