From 9bdba373b2d46b4506a6de3cf94c6413a4d35fb3 Mon Sep 17 00:00:00 2001 From: Kasumi Hanazuki Date: Tue, 10 Nov 2015 22:59:13 +0900 Subject: [PATCH] Make the temporary directory path contain uid of the process This patch resolves #376 a problem with multi-user environment. On many traditional *nix systems all the users on the same machine share a single global `/tmp`. If two users on such a system run spring at the same time, the first user's spring process creates `/tmp/spring` and stores a pidfile and a socket within the directory. The second users process will then try to store its pidfile within `/tmp/spring`, but it fails since the directory is owned by another user and (usually) not writable to non-owners. This patch resolves this problem by making the temporary directory path used by spring contain the UID of the running process. If you are the user with UID of 1000, your spring processes will create the directory `$TMPDIR/spring-1000` and store everything therein. --- CHANGELOG.md | 5 +++++ lib/spring/env.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2248ba51..95348935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Next Release + +* Make the temporary directory path used by spring contain the UID of the process + so that spring can work on machines where multiple users share a single $TMPDIR. + ## 1.4.3 * Support new binstub format and --remove option diff --git a/lib/spring/env.rb b/lib/spring/env.rb index e1e9656f..6a60f0ae 100644 --- a/lib/spring/env.rb +++ b/lib/spring/env.rb @@ -33,7 +33,7 @@ def version end def tmp_path - path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring")) + path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring-#{Process.uid}")) FileUtils.mkdir_p(path) unless path.exist? path end