aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-11-04 00:29:49 +0100
committerKim Alvefur <zash@zash.se>2019-11-04 00:29:49 +0100
commit9b5d4cf8750c90b6eb90d985d98807b63910c7d3 (patch)
treed620900e2f37d3c05fa357c074b33a461022568f
parentd3ec2e6fef757bdf9d40a4412945d9daae3142b4 (diff)
downloadprosody-9b5d4cf8750c90b6eb90d985d98807b63910c7d3.tar.gz
prosody-9b5d4cf8750c90b6eb90d985d98807b63910c7d3.zip
util.startup: Ensure prosody.paths are absolute (see #1430)
Normally these paths are injected into the installed 'prosody' executable as absolute paths, but it is possible to override at least the config path via environment variable or command line argument. This makes sure a path relative to pwd stays relative to that instead of the data directory.
-rw-r--r--util/startup.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/util/startup.lua b/util/startup.lua
index 82d0804d..e88ed709 100644
--- a/util/startup.lua
+++ b/util/startup.lua
@@ -231,8 +231,14 @@ end
function startup.chdir()
if prosody.installed then
+ local lfs = require "lfs";
+ -- Ensure paths are absolute, not relative to the working directory which we're about to change
+ local cwd = lfs.currentdir();
+ prosody.paths.source = config.resolve_relative_path(cwd, prosody.paths.source);
+ prosody.paths.config = config.resolve_relative_path(cwd, prosody.paths.config);
+ prosody.paths.data = config.resolve_relative_path(cwd, prosody.paths.data);
-- Change working directory to data path.
- require "lfs".chdir(prosody.paths.data);
+ lfs.chdir(prosody.paths.data);
end
end