aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--core/configmanager.lua14
-rw-r--r--util/startup.lua9
3 files changed, 22 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index e4f0d269..c7c7e9c9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -60,7 +60,7 @@ TRUNK
- The configuration file now supports referring and appending to options previously set
- Direct usage of the Lua API in the config file is deprecated, but can now be accessed via Lua.* instead
-- Convenience functions for reading values from files
+- Convenience functions for reading values from files, with variant meant for credentials or secrets
## Changes
diff --git a/core/configmanager.lua b/core/configmanager.lua
index 37a01a84..922ff05f 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.lua
@@ -198,6 +198,7 @@ do
FileContents = true,
FileLine = true,
FileLines = true,
+ Secret = true,
Include = true, include = true, RunScript = true }, {
__index = function (_, k)
if k:match("^ENV_") then
@@ -359,6 +360,19 @@ do
env.FileLine = filereader(config_path, "*l");
env.FileLines = linereader(config_path);
+ if _G.prosody.paths.secrets then
+ env.Secret = filereader(_G.prosody.paths.secrets, "*a");
+ elseif _G.prosody.process_type == "prosody" then
+ env.Secret = function() error("Secret() requires the $CREDENTIALS_DIRECTORY environment variable to be set", 2) end
+ else
+ env.Secret = function()
+ t_insert(warnings, ("%s:%d: Secret() requires the $CREDENTIALS_DIRECTORY environment variable to be set")
+ :format(config_file, get_line_number(config_file)));
+ return nil;
+ end
+
+ end
+
local chunk, err = envload(data, "@"..config_file, env);
if not chunk then
diff --git a/util/startup.lua b/util/startup.lua
index caae895d..1557ab0f 100644
--- a/util/startup.lua
+++ b/util/startup.lua
@@ -266,8 +266,13 @@ function startup.init_global_state()
full_sessions = prosody.full_sessions;
hosts = prosody.hosts;
- prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR or ".",
- plugins = CFG_PLUGINDIR or "plugins", data = "data" };
+ prosody.paths = {
+ source = CFG_SOURCEDIR;
+ config = CFG_CONFIGDIR or ".";
+ plugins = CFG_PLUGINDIR or "plugins";
+ data = "data";
+ secrets = os.getenv("CREDENTIALS_DIRECTORY");
+ };
prosody.arg = _G.arg;