Merge 13.0->trunk

This commit is contained in:
Matthew Wild 2025-03-11 18:45:23 +00:00
commit 74970e2815
7 changed files with 56 additions and 18 deletions

View file

@ -6,6 +6,15 @@ TRUNK
## New
## Modules
- mod_account_activity
- mod_cloud_notify
- mod_flags
- mod_http_altconnect
- mod_s2s_auth_dane_in
- mod_server_info
### Administration
- Add 'watch log' command to follow live debug logs at runtime (even if disabled)

View file

@ -109,6 +109,7 @@ end
local function set_password(username, password, host, resource)
local ok, err = hosts[host].users.set_password(username, password);
if ok then
log("info", "Account password changed: %s@%s", username, host);
prosody.events.fire_event("user-password-changed", { username = username, host = host, resource = resource });
end
return ok, err;
@ -126,12 +127,17 @@ local function user_exists(username, host)
end
local function create_user(username, password, host)
return hosts[host].users.create_user(username, password);
local ok, err = hosts[host].users.create_user(username, password);
if ok then
log("info", "User account created: %s@%s", username, host);
end
return ok, err;
end
local function delete_user(username, host)
local ok, err = hosts[host].users.delete_user(username);
if not ok then return nil, err; end
log("info", "User account deleted: %s@%s", username, host);
prosody.events.fire_event("user-deleted", { username = username, host = host });
return storagemanager.purge(username, host);
end
@ -158,6 +164,7 @@ local function enable_user(username, host)
if not method then return nil, "method not supported"; end
local ret, err = method(username);
if ret then
log("info", "User account enabled: %s@%s", username, host);
prosody.events.fire_event("user-enabled", { username = username, host = host });
end
return ret, err;
@ -168,6 +175,7 @@ local function disable_user(username, host, meta)
if not method then return nil, "method not supported"; end
local ret, err = method(username, meta);
if ret then
log("info", "User account disabled: %s@%s", username, host);
prosody.events.fire_event("user-disabled", { username = username, host = host, meta = meta });
end
return ret, err;
@ -198,6 +206,7 @@ local function set_user_role(user, host, role_name)
local role, err = hosts[host].authz.set_user_role(user, role_name);
if role then
log("info", "Account %s@%s role changed to %s", user, host, role_name);
prosody.events.fire_event("user-role-changed", {
username = user, host = host, role = role;
});

View file

@ -252,12 +252,16 @@ local function session_close(session, reason)
if not session.destroyed then
session.log("warn", "Failed to receive a stream close response, closing connection anyway...");
sm_destroy_session(session, reason_text);
if conn then conn:close(); end
if conn then
conn:close();
end
end
end);
else
sm_destroy_session(session, reason_text);
if conn then conn:close(); end
if conn then
conn:close();
end
end
else
local reason_text = (reason and (reason.name or reason.text or reason.condition)) or reason;

View file

@ -4,7 +4,7 @@ local array = require "prosody.util.array";
local datetime = require "prosody.util.datetime";
local st = require "prosody.util.stanza";
local now = require "prosody.util.time".now;
local id = require "prosody.util.id".medium;
local uuid_v7 = require "prosody.util.uuid".v7;
local jid_join = require "prosody.util.jid".join;
local set = require "prosody.util.set";
local it = require "prosody.util.iterators";
@ -111,7 +111,7 @@ function archive:append(username, key, value, when, with)
module:log("debug", "%s reached or over quota, not adding to store", username);
return nil, "quota-limit";
end
key = id();
key = uuid_v7();
end
module:log("debug", "%s has %d items out of %d limit in store %s", username, item_count, archive_item_limit, self.store);

View file

@ -87,6 +87,7 @@ local function session_close(session, reason)
end
end
end
stream_error = tostring(stream_error);
log("debug", "Disconnecting client, <stream:error> is: %s", stream_error);
session.send(stream_error);
end
@ -94,28 +95,33 @@ local function session_close(session, reason)
session.send(st.stanza("close", { xmlns = xmlns_framing }));
function session.send() return false; end
-- luacheck: ignore 422/reason
-- FIXME reason should be handled in common place
local reason = (reason and (reason.name or reason.text or reason.condition)) or reason;
session.log("debug", "c2s stream for %s closed: %s", session.full_jid or ("<"..session.ip..">"), reason or "session closed");
local reason_text = (reason and (reason.name or reason.text or reason.condition)) or reason;
session.log("debug", "c2s stream for %s closed: %s", session.full_jid or session.ip or "<unknown>", reason_text or "session closed");
-- Authenticated incoming stream may still be sending us stanzas, so wait for </stream:stream> from remote
local conn = session.conn;
if reason == nil and not session.notopen and session.type == "c2s" then
if reason_text == nil and not session.notopen and session.type == "c2s" then
-- Grace time to process data from authenticated cleanly-closed stream
add_task(stream_close_timeout, function ()
if not session.destroyed then
session.log("warn", "Failed to receive a stream close response, closing connection anyway...");
sm_destroy_session(session, reason);
conn:write(build_close(1000, "Stream closed"));
conn:close();
sm_destroy_session(session, reason_text);
if conn then
conn:write(build_close(1000, "Stream closed"));
conn:close();
end
end
end);
else
sm_destroy_session(session, reason);
conn:write(build_close(1000, "Stream closed"));
conn:close();
sm_destroy_session(session, reason_text);
if conn then
conn:write(build_close(1000, "Stream closed"));
conn:close();
end
end
else
local reason_text = (reason and (reason.name or reason.text or reason.condition)) or reason;
sm_destroy_session(session, reason_text);
end
end

View file

@ -54,6 +54,12 @@ describe("parse", function()
assert.same({ foo = "bar"; baz = "moo" }, opts);
end);
it("supports value arguments in strict mode", function()
local opts, err = parse({ "--foo"; "bar"; "--baz=moo" }, { strict = true, value_params = { foo = true; baz = true } });
assert.falsy(err);
assert.same({ foo = "bar"; baz = "moo" }, opts);
end);
it("demands values for value params", function()
local opts, err, where = parse({ "--foo" }, { value_params = { foo = true } });
assert.falsy(opts);

View file

@ -39,9 +39,13 @@ local function parse(arg, config)
local param_k, param_v;
if value_params[uparam] or array_params[uparam] then
param_k, param_v = uparam, table.remove(arg, 1);
param_k = uparam;
param_v = param:match("^=(.*)$", #uparam+1);
if not param_v then
return nil, "missing-value", raw_param;
param_v = table.remove(arg, 1);
if not param_v then
return nil, "missing-value", raw_param;
end
end
else
param_k, param_v = param:match("^([^=]+)=(.+)$");