Skip to content

Commit 9bdba37

Browse files
committed
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.
1 parent 91294f0 commit 9bdba37

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Next Release
2+
3+
* Make the temporary directory path used by spring contain the UID of the process
4+
so that spring can work on machines where multiple users share a single $TMPDIR.
5+
16
## 1.4.3
27

38
* Support new binstub format and --remove option

lib/spring/env.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def version
3333
end
3434

3535
def tmp_path
36-
path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring"))
36+
path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring-#{Process.uid}"))
3737
FileUtils.mkdir_p(path) unless path.exist?
3838
path
3939
end

0 commit comments

Comments
 (0)