diff options
-rw-r--r-- | CHANGES | 9 | ||||
-rw-r--r-- | core/usermanager.lua | 11 | ||||
-rw-r--r-- | plugins/mod_c2s.lua | 8 | ||||
-rw-r--r-- | plugins/mod_storage_internal.lua | 4 | ||||
-rw-r--r-- | plugins/mod_websocket.lua | 28 | ||||
-rw-r--r-- | spec/util_argparse_spec.lua | 6 | ||||
-rw-r--r-- | util/argparse.lua | 8 |
7 files changed, 56 insertions, 18 deletions
@@ -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) diff --git a/core/usermanager.lua b/core/usermanager.lua index 3cd6f16d..c179e21b 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -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; }); diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index a9417368..c1fbdb9e 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -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; diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua index a43dd272..1332ae75 100644 --- a/plugins/mod_storage_internal.lua +++ b/plugins/mod_storage_internal.lua @@ -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); diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua index 206ad678..17a91076 100644 --- a/plugins/mod_websocket.lua +++ b/plugins/mod_websocket.lua @@ -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 diff --git a/spec/util_argparse_spec.lua b/spec/util_argparse_spec.lua index be1d99df..3fd4070e 100644 --- a/spec/util_argparse_spec.lua +++ b/spec/util_argparse_spec.lua @@ -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); diff --git a/util/argparse.lua b/util/argparse.lua index 3a7d1ba2..75b1c2f9 100644 --- a/util/argparse.lua +++ b/util/argparse.lua @@ -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("^([^=]+)=(.+)$"); |