Module: Bundler::Codegraph::RuntimeDir
- Defined in:
- lib/bundler/codegraph/runtime_dir.rb
Overview
A private directory for the plugin's runtime files, one per user under
Dir.tmpdir.
On Linux Dir.tmpdir is the shared /tmp, where a fixed file name lets
another user create it first — and then either hold the lock forever or
leave it unopenable. The directory is created 0700 and only trusted when
it is a real directory (not a symlink), owned by the current user and
closed to everyone else; callers degrade gracefully when it is not.
Class Method Summary collapse
-
.candidate ⇒ String
Where the directory lives, trusted or not.
-
.path ⇒ String?
The directory, nil when it cannot be trusted.
Class Method Details
.candidate ⇒ String
Returns where the directory lives, trusted or not.
19 20 21 |
# File 'lib/bundler/codegraph/runtime_dir.rb', line 19 def self.candidate File.join(Dir.tmpdir, "bundler-codegraph-#{Process.uid}") end |
.path ⇒ String?
Returns the directory, nil when it cannot be trusted.
24 25 26 27 28 29 30 |
# File 'lib/bundler/codegraph/runtime_dir.rb', line 24 def self.path dir = candidate create(dir) trusted?(dir) ? dir : nil rescue SystemCallError nil end |