From 15217fe1162a400fa1cd2216e395d9f17be8083e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 18 Nov 2009 17:28:12 -0800 Subject: Do not expand paths given on the shell Shells already expand '~' before the executables see it, and relative paths inside symlinks can get set incorrectly to the actual directory name, and not the (usually desired) symlink name for things like Capistrano. Since our paths are now unexpanded, we must now check the "working_directory" directive and raise an error if the user specifies the config file in a way that makes the config file unreloadable. --- lib/unicorn/configurator.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/unicorn/configurator.rb') diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index 2d92aa3..e809b22 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -372,6 +372,13 @@ module Unicorn def working_directory(path) # just let chdir raise errors path = File.expand_path(path) + if config_file && + config_file[0] != ?/ && + ! test(?r, "#{path}/#{config_file}") + raise ArgumentError, + "config_file=#{config_file} would not be accessible in" \ + " working_directory=#{path}" + end Dir.chdir(path) HttpServer::START_CTX[:cwd] = ENV["PWD"] = path end -- cgit v1.2.3-24-ge0c7