From 5e4bc6299bb49f469cc180cd6a1ba76fd46ae6ee Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 3 Nov 2019 22:19:09 +0100 Subject: util.startup: Update config path (fixes #1430) --- util/startup.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/startup.lua b/util/startup.lua index c101c290..82d0804d 100644 --- a/util/startup.lua +++ b/util/startup.lua @@ -33,7 +33,8 @@ function startup.read_config() if file then file:close(); prosody.config_file = filename; - CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$"); -- luacheck: ignore 111 + prosody.paths.config = filename:match("^(.*)[\\/][^\\/]*$"); + CFG_CONFIGDIR = prosody.paths.config; -- luacheck: ignore 111 break; end end -- cgit v1.2.3 From 91156ab5d9ea64f1c8f47aa5f30c06d8fc896056 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 4 Nov 2019 00:29:49 +0100 Subject: 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. --- util/startup.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'util') 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 -- cgit v1.2.3