Comparison

util/startup.lua @ 10390:82705ec87253 0.11

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.
author Kim Alvefur <zash@zash.se>
date Mon, 04 Nov 2019 00:29:49 +0100
parent 10389:dbb8dae58265
child 10391:986349fc0f9e
child 10596:cb107ea49b35
comparison
equal deleted inserted replaced
10389:dbb8dae58265 10390:82705ec87253
229 end 229 end
230 end 230 end
231 231
232 function startup.chdir() 232 function startup.chdir()
233 if prosody.installed then 233 if prosody.installed then
234 local lfs = require "lfs";
235 -- Ensure paths are absolute, not relative to the working directory which we're about to change
236 local cwd = lfs.currentdir();
237 prosody.paths.source = config.resolve_relative_path(cwd, prosody.paths.source);
238 prosody.paths.config = config.resolve_relative_path(cwd, prosody.paths.config);
239 prosody.paths.data = config.resolve_relative_path(cwd, prosody.paths.data);
234 -- Change working directory to data path. 240 -- Change working directory to data path.
235 require "lfs".chdir(prosody.paths.data); 241 lfs.chdir(prosody.paths.data);
236 end 242 end
237 end 243 end
238 244
239 function startup.add_global_prosody_functions() 245 function startup.add_global_prosody_functions()
240 -- Function to reload the config file 246 -- Function to reload the config file