check SPEC_TEMP_DIR
is world-writable or not
``` 1) Dir.mktmpdir when passed a block yields the path to the passed block ERROR ArgumentError: parent directory is world writable but not sticky: /tmp/rubytest.wlu5cs_11 /tmp/ruby/src/trunk/lib/tmpdir.rb:113:in 'Dir.mktmpdir' /tmp/ruby/src/trunk/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb:39:in 'block (2 levels) in <top (required)>' ``` This weird error comes from world-writable (and not sticky) directory of `SPEC_TEMP_DIR`. This patch checks `SPEC_TEMP_DIR` is not world-writable if exists and `File.umask` contains o+w mask.
This commit is contained in:
parent
f0001a4fa7
commit
6086bae5c8
@ -36,7 +36,18 @@ all specs are cleaning up temporary files:
|
||||
end
|
||||
|
||||
def tmp(name, uniquify = true)
|
||||
mkdir_p SPEC_TEMP_DIR unless Dir.exist? SPEC_TEMP_DIR
|
||||
if Dir.exist? SPEC_TEMP_DIR
|
||||
stat = File.stat(SPEC_TEMP_DIR)
|
||||
if stat.world_writable? and !stat.sticky?
|
||||
raise ArgumentError, "SPEC_TEMP_DIR (#{SPEC_TEMP_DIR}) is world writable but not sticky"
|
||||
end
|
||||
else
|
||||
umask = File.umask
|
||||
if (umask & 0002) == 0 # o+w
|
||||
raise ArgumentError, "File.umask #=> #{umask.to_s(8)} (world-writable)"
|
||||
end
|
||||
mkdir_p SPEC_TEMP_DIR
|
||||
end
|
||||
|
||||
if uniquify and !name.empty?
|
||||
slash = name.rindex "/"
|
||||
|
Loading…
x
Reference in New Issue
Block a user