aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/dnsregistry.lua7
-rw-r--r--util/prosodyctl.lua24
-rw-r--r--util/prosodyctl/cert.lua2
-rw-r--r--util/pubsub.lua26
-rw-r--r--util/sslconfig.lua14
-rw-r--r--util/xtemplate.lua9
6 files changed, 66 insertions, 16 deletions
diff --git a/util/dnsregistry.lua b/util/dnsregistry.lua
index c52abee9..b65debe0 100644
--- a/util/dnsregistry.lua
+++ b/util/dnsregistry.lua
@@ -1,5 +1,5 @@
-- Source: https://www.iana.org/assignments/dns-parameters/dns-parameters.xml
--- Generated on 2023-01-20
+-- Generated on 2024-10-26
return {
classes = {
["IN"] = 1; [1] = "IN";
@@ -79,6 +79,7 @@ return {
["LP"] = 107; [107] = "LP";
["EUI48"] = 108; [108] = "EUI48";
["EUI64"] = 109; [109] = "EUI64";
+ ["NXNAME"] = 128; [128] = "NXNAME";
["TKEY"] = 249; [249] = "TKEY";
["TSIG"] = 250; [250] = "TSIG";
["IXFR"] = 251; [251] = "IXFR";
@@ -91,6 +92,10 @@ return {
["AVC"] = 258; [258] = "AVC";
["DOA"] = 259; [259] = "DOA";
["AMTRELAY"] = 260; [260] = "AMTRELAY";
+ ["RESINFO"] = 261; [261] = "RESINFO";
+ ["WALLET"] = 262; [262] = "WALLET";
+ ["CLA"] = 263; [263] = "CLA";
+ ["IPN"] = 264; [264] = "IPN";
["TA"] = 32768; [32768] = "TA";
["DLV"] = 32769; [32769] = "DLV";
};
diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua
index d256e558..9cb4b4dd 100644
--- a/util/prosodyctl.lua
+++ b/util/prosodyctl.lua
@@ -15,9 +15,13 @@ local usermanager = require "prosody.core.usermanager";
local interpolation = require "prosody.util.interpolation";
local signal = require "prosody.util.signal";
local set = require "prosody.util.set";
+local path = require"prosody.util.paths";
local lfs = require "lfs";
local type = type;
+local have_socket_unix, socket_unix = pcall(require, "socket.unix");
+have_socket_unix = have_socket_unix and type(socket_unix) == "table"; -- was a function in older LuaSocket
+
local nodeprep, nameprep = stringprep.nodeprep, stringprep.nameprep;
local io, os = io, os;
@@ -177,11 +181,31 @@ local function start(source_dir, lua)
if ret then
return false, "already-running";
end
+ local notify_socket;
+ if have_socket_unix then
+ local notify_path = path.join(prosody.paths.data, "notify.sock");
+ os.remove(notify_path);
+ lua = string.format("NOTIFY_SOCKET=%q %s", notify_path, lua);
+ notify_socket = socket_unix.dgram();
+ local ok = notify_socket:setsockname(notify_path);
+ if not ok then return false, "notify-failed"; end
+ end
if not source_dir then
os.execute(lua .. "./prosody -D");
else
os.execute(lua .. source_dir.."/../../bin/prosody -D");
end
+
+ if notify_socket then
+ for i = 1, 5 do
+ notify_socket:settimeout(i);
+ if notify_socket:receivefrom() == "READY=1" then
+ return true;
+ end
+ end
+ return false, "not-ready";
+ end
+
return true;
end
diff --git a/util/prosodyctl/cert.lua b/util/prosodyctl/cert.lua
index aea61c20..70c09443 100644
--- a/util/prosodyctl/cert.lua
+++ b/util/prosodyctl/cert.lua
@@ -163,7 +163,7 @@ local function copy(from, to, umask, owner, group)
local attrs = lfs.attributes(to);
if attrs then -- Move old file out of the way
local backup = to..".bkp~"..os.date("%FT%T", attrs.change);
- os.rename(to, backup);
+ assert(os.rename(to, backup));
end
-- FIXME friendlier error handling, maybe move above backup back?
local input = assert(io.open(from));
diff --git a/util/pubsub.lua b/util/pubsub.lua
index ccde8b53..d6779736 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -1,6 +1,5 @@
local events = require "prosody.util.events";
local cache = require "prosody.util.cache";
-local errors = require "prosody.util.error";
local service_mt = {};
@@ -12,6 +11,7 @@ local default_config = {
itemcheck = function () return true; end;
get_affiliation = function () end;
normalize_jid = function (jid) return jid; end;
+ metadata_subset = {};
capabilities = {
outcast = {
create = false;
@@ -46,6 +46,7 @@ local default_config = {
get_subscription = true;
get_subscriptions = true;
get_items = false;
+ get_metadata = true;
subscribe_other = false;
unsubscribe_other = false;
@@ -68,6 +69,7 @@ local default_config = {
get_subscription = true;
get_subscriptions = true;
get_items = true;
+ get_metadata = true;
subscribe_other = false;
unsubscribe_other = false;
@@ -91,6 +93,7 @@ local default_config = {
get_subscription = true;
get_subscriptions = true;
get_items = true;
+ get_metadata = true;
subscribe_other = false;
unsubscribe_other = false;
@@ -116,6 +119,7 @@ local default_config = {
get_subscription = true;
get_subscriptions = true;
get_items = true;
+ get_metadata = true;
subscribe_other = true;
@@ -562,11 +566,7 @@ function service:publish(node, actor, id, item, requested_config) --> ok, err
-- Check that node has the requested config before we publish
local ok, field = check_preconditions(node_obj.config, requested_config);
if not ok then
- local err = errors.new({
- type = "cancel", condition = "conflict", text = "Field does not match: "..field;
- });
- err.pubsub_condition = "precondition-not-met";
- return false, err;
+ return false, "precondition-not-met", { field = field };
end
end
if not self.config.itemcheck(item) then
@@ -877,6 +877,20 @@ function service:get_node_config(node, actor) --> (true, config) or (false, err)
return true, config_table;
end
+function service:get_node_metadata(node, actor)
+ if not self:may(node, actor, "get_metadata") then
+ return false, "forbidden";
+ end
+
+ local ok, config = self:get_node_config(node, true);
+ if not ok then return ok, config; end
+ local meta = {};
+ for _, k in ipairs(self.config.metadata_subset) do
+ meta[k] = config[k];
+ end
+ return true, meta;
+end
+
return {
new = new;
};
diff --git a/util/sslconfig.lua b/util/sslconfig.lua
index 7b0ed34a..01a8adb5 100644
--- a/util/sslconfig.lua
+++ b/util/sslconfig.lua
@@ -84,8 +84,18 @@ end
finalisers.certificate = finalisers.key;
finalisers.cafile = finalisers.key;
finalisers.capath = finalisers.key;
--- XXX: copied from core/certmanager.lua, but this seems odd, because it would remove a dhparam function from the config
-finalisers.dhparam = finalisers.key;
+
+function finalisers.dhparam(value, config)
+ if type(value) == "string" then
+ if value:sub(1, 10) == "-----BEGIN" then
+ -- literal value
+ return value;
+ else
+ -- assume a filename
+ return resolve_path(config._basedir, value);
+ end
+ end
+end
-- protocol = "x" should enable only that protocol
-- protocol = "x+" should enable x and later versions
diff --git a/util/xtemplate.lua b/util/xtemplate.lua
index 56413012..446d7d1f 100644
--- a/util/xtemplate.lua
+++ b/util/xtemplate.lua
@@ -39,7 +39,8 @@ local function render(template, root, escape, filters)
if tmpl then tmpl = s_sub(tmpl, 2, -2); end
if args then args = s_sub(args, 2, -2); end
- if func == "each" and tmpl and st.is_stanza(value) then
+ if func == "each" and tmpl then
+ if not st.is_stanza(value) then return pre_blank .. post_blank end
if not args then value, args = root, path; end
local ns, name = s_match(args, "^(%b{})(.*)$");
if ns then
@@ -69,11 +70,7 @@ local function render(template, root, escape, filters)
end
elseif filters and filters[func] then
local f = filters[func];
- if args == nil then
- value, is_escaped = f(value, tmpl);
- else
- value, is_escaped = f(args, value, tmpl);
- end
+ value, is_escaped = f(value, args, tmpl);
else
error("No such filter function: " .. func);
end