diff options
-rw-r--r-- | .semgrep.yml | 9 | ||||
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | core/configmanager.lua | 19 | ||||
-rw-r--r-- | core/modulemanager.lua | 1 | ||||
-rw-r--r-- | core/usermanager.lua | 2 | ||||
-rw-r--r-- | doc/doap.xml | 10 | ||||
-rw-r--r-- | net/httpserver.lua | 17 | ||||
-rw-r--r-- | plugins/mod_account_activity.lua | 152 | ||||
-rw-r--r-- | plugins/mod_admin_shell.lua | 55 | ||||
-rw-r--r-- | plugins/mod_authz_internal.lua | 15 | ||||
-rw-r--r-- | plugins/mod_cloud_notify.lua | 14 | ||||
-rw-r--r-- | plugins/mod_cron.lua | 2 | ||||
-rw-r--r-- | plugins/mod_invites.lua | 162 | ||||
-rw-r--r-- | plugins/mod_presence.lua | 12 | ||||
-rw-r--r-- | plugins/mod_storage_sql.lua | 2 | ||||
-rw-r--r-- | plugins/muc/hats.lib.lua | 2 | ||||
-rw-r--r-- | prosody.cfg.lua.dist | 6 | ||||
-rw-r--r-- | tools/dnsregistry.lua | 5 | ||||
-rw-r--r-- | util/dnsregistry.lua | 3 | ||||
-rw-r--r-- | util/prosodyctl/check.lua | 6 |
20 files changed, 432 insertions, 68 deletions
diff --git a/.semgrep.yml b/.semgrep.yml index 22bfcfea..c475859d 100644 --- a/.semgrep.yml +++ b/.semgrep.yml @@ -28,3 +28,12 @@ rules: message: Use :get_text() to read text, or pass a value here to add text severity: WARNING languages: [lua] +- id: require-unprefixed-module + patterns: + - pattern: require("$X") + - metavariable-regex: + metavariable: $X + regex: '^(core|net|util)\.' + message: Prefix required module path with 'prosody.' + severity: ERROR + languages: [lua] @@ -1,12 +1,16 @@ TRUNK ===== +13.0.x +====== + ## New ### Administration - Add 'watch log' command to follow live debug logs at runtime (even if disabled) - mod_announce: Add shell commands to send messages to all users, online users, or limited by roles +- New mod_account_activity plugin records last login/logout time of a user account ### Networking @@ -30,6 +34,7 @@ TRUNK - muc_room_allow_public = false restricts to admins - Commands to show occupants and affiliations in the Shell - Save 'reason' text supplied with affiliation change +- Owners can set MUC avatars (functionality previously in community module mod_vcard_muc) ### Security and authentication @@ -77,6 +82,7 @@ TRUNK - Support for the roster *group* access_model in mod_pep - Support for systemd socket activation in server_epoll - mod_invites_adhoc gained a command for creating password resets +- mod_cloud_notify imported from community modules for push notification support ## Removed diff --git a/core/configmanager.lua b/core/configmanager.lua index 36df0171..023545d7 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -18,6 +18,8 @@ local resolve_relative_path = require"prosody.util.paths".resolve_relative_path; local glob_to_pattern = require"prosody.util.paths".glob_to_pattern; local path_sep = package.config:sub(1,1); local get_traceback_table = require "prosody.util.debug".get_traceback_table; +local errors = require "prosody.util.error"; +local log = require "prosody.util.logger".init("config"); local encodings = deps.softreq"prosody.util.encodings"; local nameprep = encodings and encodings.stringprep.nameprep or function (host) return host:lower(); end @@ -32,6 +34,7 @@ local parser = nil; local config_mt = { __index = function (t, _) return rawget(t, "*"); end}; local config = setmetatable({ ["*"] = { } }, config_mt); +local delayed_warnings = {}; local files = {}; -- When host not found, use global @@ -42,6 +45,10 @@ function _M.getconfig() end function _M.get(host, key) + if host and key and delayed_warnings[host.."/"..key] then + local warning = delayed_warnings[host.."/"..key]; + log("warn", "%s", warning.text); + end return config[host][key]; end function _M.rawget(host, key) @@ -243,6 +250,10 @@ do t_insert(warnings, ("%s:%d: Duplicate option '%s'"):format(config_file, get_line_number(config_file), k)); end set_options[option_path] = true; + if errors.is_error(v) then + delayed_warnings[option_path] = v; + return; + end set(config_table, env.__currenthost or "*", k, v); end }); @@ -366,9 +377,11 @@ do env.Credential = function() error("Credential() requires the $CREDENTIALS_DIRECTORY environment variable to be set", 2) end else env.Credential = function() - t_insert(warnings, ("%s:%d: Credential() requires the $CREDENTIALS_DIRECTORY environment variable to be set") - :format(config_file, get_line_number(config_file))); - return nil; + return errors.new({ + type = "continue", + text = ("%s:%d: Credential() requires the $CREDENTIALS_DIRECTORY environment variable to be set") + :format(config_file, get_line_number(config_file)); + }); end end diff --git a/core/modulemanager.lua b/core/modulemanager.lua index b8ba2f35..7295ba25 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -29,7 +29,6 @@ local ipairs, pairs, type, t_insert = ipairs, pairs, type, table.insert; local lua_version = _VERSION:match("5%.%d+$"); local autoload_modules = { - prosody.platform, "presence", "message", "iq", diff --git a/core/usermanager.lua b/core/usermanager.lua index 793e7af6..3cd6f16d 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -244,7 +244,7 @@ local function add_user_secondary_role(user, host, role_name) local role, err = hosts[host].authz.add_user_secondary_role(user, role_name); if role then prosody.events.fire_event("user-role-added", { - username = user, host = host, role = role; + username = user, host = host, role_name = role_name, role = role; }); end return role, err; diff --git a/doc/doap.xml b/doc/doap.xml index edd924bf..9173a9cb 100644 --- a/doc/doap.xml +++ b/doc/doap.xml @@ -245,7 +245,7 @@ <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0090.html"/> <xmpp:version>1.2</xmpp:version> <xmpp:since>0.1.0</xmpp:since> - <xmpp:until>trunk</xmpp:until> + <xmpp:until>13.0.0</xmpp:until> <xmpp:status>removed</xmpp:status> <xmpp:note>mod_time</xmpp:note> </xmpp:SupportedXep> @@ -736,7 +736,7 @@ <xmpp:SupportedXep> <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0357.html"/> <xmpp:version>0.4.1</xmpp:version> - <xmpp:since>trunk</xmpp:since> + <xmpp:since>13.0.0</xmpp:since> <xmpp:status>complete</xmpp:status> <xmpp:note>mod_cloud_notify</xmpp:note> </xmpp:SupportedXep> @@ -840,7 +840,7 @@ <implements> <xmpp:SupportedXep> <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0421.html"/> - <xmpp:version>0.2.0</xmpp:version> + <xmpp:version>1.0.0</xmpp:version> <xmpp:since>0.12.0</xmpp:since> <xmpp:status>complete</xmpp:status> <xmpp:note>mod_muc</xmpp:note> @@ -857,7 +857,7 @@ <xmpp:SupportedXep> <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0440.html"/> <xmpp:version>0.4.2</xmpp:version> - <xmpp:since>trunk</xmpp:since> + <xmpp:since>13.0.0</xmpp:since> <xmpp:status>complete</xmpp:status> </xmpp:SupportedXep> </implements> @@ -881,7 +881,7 @@ <xmpp:SupportedXep> <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0478.html"/> <xmpp:version>0.2.0</xmpp:version> - <xmpp:since>trunk</xmpp:since> + <xmpp:since>13.0.0</xmpp:since> </xmpp:SupportedXep> </implements> </Project> diff --git a/net/httpserver.lua b/net/httpserver.lua deleted file mode 100644 index 0dfd862e..00000000 --- a/net/httpserver.lua +++ /dev/null @@ -1,17 +0,0 @@ --- COMPAT w/pre-0.9 -local log = require "prosody.util.logger".init("net.httpserver"); -local traceback = debug.traceback; - -local _ENV = nil; --- luacheck: std none - -local function fail() - log("error", "Attempt to use legacy HTTP API. For more info see https://prosody.im/doc/developers/legacy_http"); - log("error", "Legacy HTTP API usage, %s", traceback("", 2)); -end - -return { - new = fail; - new_from_config = fail; - set_default_handler = fail; -}; diff --git a/plugins/mod_account_activity.lua b/plugins/mod_account_activity.lua new file mode 100644 index 00000000..1b1208e7 --- /dev/null +++ b/plugins/mod_account_activity.lua @@ -0,0 +1,152 @@ +local jid = require "prosody.util.jid"; +local time = os.time; + +local store = module:open_store(nil, "keyval+"); + +module:hook("authentication-success", function(event) + local session = event.session; + if session.username then + store:set_key(session.username, "timestamp", time()); + end +end); + +module:hook("resource-unbind", function(event) + local session = event.session; + if session.username then + store:set_key(session.username, "timestamp", time()); + end +end); + +local user_sessions = prosody.hosts[module.host].sessions; +function get_last_active(username) --luacheck: ignore 131/get_last_active + if user_sessions[username] then + return os.time(), true; -- Currently connected + else + local last_activity = store:get(username); + if not last_activity then return nil; end + return last_activity.timestamp; + end +end + +module:add_item("shell-command", { + section = "user"; + section_desc = "View user activity data"; + name = "activity"; + desc = "View the last recorded user activity for an account"; + args = { { name = "jid"; type = "string" } }; + host_selector = "jid"; + handler = function(self, userjid) --luacheck: ignore 212/self + local username = jid.prepped_split(userjid); + local last_timestamp, is_online = get_last_active(username); + if not last_timestamp then + return true, "No activity"; + end + + return true, ("%s (%s)"):format(os.date("%Y-%m-%d %H:%M:%S", last_timestamp), (is_online and "online" or "offline")); + end; +}); + +module:add_item("shell-command", { + section = "user"; + section_desc = "View user activity data"; + name = "list_inactive"; + desc = "List inactive user accounts"; + args = { + { name = "host"; type = "string" }; + { name = "duration"; type = "string" }; + }; + host_selector = "host"; + handler = function(self, host, duration) --luacheck: ignore 212/self + local um = require "prosody.core.usermanager"; + local duration_sec = require "prosody.util.human.io".parse_duration(duration or ""); + if not duration_sec then + return false, ("Invalid duration %q - try something like \"30d\""):format(duration); + end + + local now = os.time(); + local n_inactive, n_unknown = 0, 0; + + for username in um.users(host) do + local last_active = store:get_key(username, "timestamp"); + if not last_active then + local created_at = um.get_account_info(username, host).created; + if created_at and (now - created_at) > duration_sec then + self.session.print(username, ""); + n_inactive = n_inactive + 1; + elseif not created_at then + n_unknown = n_unknown + 1; + end + elseif (now - last_active) > duration_sec then + self.session.print(username, os.date("%Y-%m-%dT%T", last_active)); + n_inactive = n_inactive + 1; + end + end + + if n_unknown > 0 then + return true, ("%d accounts inactive since %s (%d unknown)"):format(n_inactive, os.date("%Y-%m-%dT%T", now - duration_sec), n_unknown); + end + return true, ("%d accounts inactive since %s"):format(n_inactive, os.date("%Y-%m-%dT%T", now - duration_sec)); + end; +}); + +module:add_item("shell-command", { + section = "migrate"; + section_desc = "Perform data migrations"; + name = "account_activity_lastlog2"; + desc = "Migrate account activity information from mod_lastlog2"; + args = { { name = "host"; type = "string" } }; + host_selector = "host"; + handler = function(self, host) --luacheck: ignore 212/host + local lastlog2 = module:open_store("lastlog2", "keyval+"); + local n_updated, n_errors, n_skipped = 0, 0, 0; + + local async = require "prosody.util.async"; + + local p = require "prosody.util.promise".new(function (resolve) + local async_runner = async.runner(function () + local n = 0; + for username in lastlog2:items() do + n = n + 1; + if n % 100 == 0 then + self.session.print(("Processed %d..."):format(n)); + async.sleep(0); + end + local lastlog2_data = lastlog2:get(username); + if lastlog2_data then + local current_data, err = store:get(username); + if not current_data then + if not err then + current_data = {}; + else + n_errors = n_errors + 1; + end + end + if current_data then + local imported_timestamp = current_data.timestamp; + local latest; + for k, v in pairs(lastlog2_data) do + if k ~= "registered" and (not latest or v.timestamp > latest) then + latest = v.timestamp; + end + end + if latest and (not imported_timestamp or imported_timestamp < latest) then + local ok, err = store:set_key(username, "timestamp", latest); + if ok then + n_updated = n_updated + 1; + else + self.session.print(("WW: Failed to import %q: %s"):format(username, err)); + n_errors = n_errors + 1; + end + else + n_skipped = n_skipped + 1; + end + end + end + end + return resolve(("%d accounts imported, %d errors, %d skipped"):format(n_updated, n_errors, n_skipped)); + end); + async_runner:run(true); + end); + return p; + end; +}); diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index fe231dca..3301ed9b 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -349,7 +349,7 @@ module:hook("admin/repl-input", function (event) return true; end); -local function describe_command(s) +local function describe_command(s, hidden) local section, name, args, desc = s:match("^([%w_]+):([%w_]+)%(([^)]*)%) %- (.+)$"); if not section then error("Failed to parse command description: "..s); @@ -360,9 +360,14 @@ local function describe_command(s) args = array.collect(args:gmatch("[%w_]+")):map(function (arg_name) return { name = arg_name }; end); + hidden = hidden; }; end +local function hidden_command(s) + return describe_command(s, true); +end + -- Console commands -- -- These are simple commands, not valid standalone in Lua @@ -455,10 +460,12 @@ def_env.help = setmetatable({}, { end for command, command_help in it.sorted_pairs(section_help.commands or {}) do - c = c + 1; - local args = array.pluck(command_help.args, "name"):concat(", "); - local desc = command_help.desc or command_help.module and ("Provided by mod_"..command_help.module) or ""; - print(("%s:%s(%s) - %s"):format(section_name, command, args, desc)); + if not command_help.hidden then + c = c + 1; + local args = array.pluck(command_help.args, "name"):concat(", "); + local desc = command_help.desc or command_help.module and ("Provided by mod_"..command_help.module) or ""; + print(("%s:%s(%s) - %s"):format(section_name, command, args, desc)); + end end elseif help_topics[section_name] then local topic = help_topics[section_name]; @@ -1800,9 +1807,8 @@ function def_env.user:password(jid, password) end); end -describe_command [[user:roles(jid, host) - Show current roles for an user]] +describe_command [[user:role(jid, host) - Show primary role for a user]] function def_env.user:role(jid, host) - local print = self.session.print; local username, userhost = jid_split(jid); if host == nil then host = userhost; end if not prosody.hosts[host] then @@ -1814,22 +1820,27 @@ function def_env.user:role(jid, host) local primary_role = um.get_user_role(username, host); local secondary_roles = um.get_user_secondary_roles(username, host); + local primary_role_desc = primary_role and primary_role.name or "<none>"; + print(primary_role and primary_role.name or "<none>"); - local count = primary_role and 1 or 0; + local n_secondary = 0; for role_name in pairs(secondary_roles or {}) do - count = count + 1; + n_secondary = n_secondary + 1; print(role_name.." (secondary)"); end - return true, count == 1 and "1 role" or count.." roles"; + if n_secondary > 0 then + return true, primary_role_desc.." (primary)"; + end + return true, primary_role_desc; end def_env.user.roles = def_env.user.role; -describe_command [[user:setrole(jid, host, role) - Set primary role of a user (see 'help roles')]] --- user:setrole("someone@example.com", "example.com", "prosody:admin") --- user:setrole("someone@example.com", "prosody:admin") -function def_env.user:setrole(jid, host, new_role) +describe_command [[user:set_role(jid, host, role) - Set primary role of a user (see 'help roles')]] +-- user:set_role("someone@example.com", "example.com", "prosody:admin") +-- user:set_role("someone@example.com", "prosody:admin") +function def_env.user:set_role(jid, host, new_role) local username, userhost = jid_split(jid); if new_role == nil then host, new_role = userhost, host; end if not prosody.hosts[host] then @@ -1844,7 +1855,7 @@ function def_env.user:setrole(jid, host, new_role) end end -describe_command [[user:addrole(jid, host, role) - Add a secondary role to a user]] +hidden_command [[user:addrole(jid, host, role) - Add a secondary role to a user]] function def_env.user:addrole(jid, host, new_role) local username, userhost = jid_split(jid); if new_role == nil then host, new_role = userhost, host; end @@ -1855,10 +1866,14 @@ function def_env.user:addrole(jid, host, new_role) elseif userhost ~= host then return nil, "Can't add roles outside users own host" end - return um.add_user_secondary_role(username, host, new_role); + local role, err = um.add_user_secondary_role(username, host, new_role); + if not role then + return nil, err; + end + return true, "Role added"; end -describe_command [[user:delrole(jid, host, role) - Remove a secondary role from a user]] +hidden_command [[user:delrole(jid, host, role) - Remove a secondary role from a user]] function def_env.user:delrole(jid, host, role_name) local username, userhost = jid_split(jid); if role_name == nil then host, role_name = userhost, host; end @@ -1869,7 +1884,11 @@ function def_env.user:delrole(jid, host, role_name) elseif userhost ~= host then return nil, "Can't remove roles outside users own host" end - return um.remove_user_secondary_role(username, host, role_name); + local ok, err = um.remove_user_secondary_role(username, host, role_name); + if not ok then + return nil, err; + end + return true, "Role removed"; end describe_command [[user:list(hostname, pattern) - List users on the specified host, optionally filtering with a pattern]] diff --git a/plugins/mod_authz_internal.lua b/plugins/mod_authz_internal.lua index 7a06c904..f683d90c 100644 --- a/plugins/mod_authz_internal.lua +++ b/plugins/mod_authz_internal.lua @@ -161,7 +161,7 @@ end function set_user_role(user, role_name) local role = role_registry[role_name]; if not role then - return error("Cannot assign default user an unknown role: "..tostring(role_name)); + return error("Cannot assign user an unknown role: "..tostring(role_name)); end local keys_update = { _default = role_name; @@ -180,14 +180,19 @@ function set_user_role(user, role_name) end function add_user_secondary_role(user, role_name) - if not role_registry[role_name] then - return error("Cannot assign default user an unknown role: "..tostring(role_name)); + local role = role_registry[role_name]; + if not role then + return error("Cannot assign user an unknown role: "..tostring(role_name)); end - role_map_store:set(user, role_name, true); + local ok, err = role_map_store:set(user, role_name, true); + if not ok then + return nil, err; + end + return role; end function remove_user_secondary_role(user, role_name) - role_map_store:set(user, role_name, nil); + return role_map_store:set(user, role_name, nil); end function get_user_secondary_roles(user) diff --git a/plugins/mod_cloud_notify.lua b/plugins/mod_cloud_notify.lua index 987be84f..1c660e93 100644 --- a/plugins/mod_cloud_notify.lua +++ b/plugins/mod_cloud_notify.lua @@ -5,13 +5,13 @@ -- This file is MIT/X11 licensed. local os_time = os.time; -local st = require"util.stanza"; -local jid = require"util.jid"; -local dataform = require"util.dataforms".new; -local hashes = require"util.hashes"; -local random = require"util.random"; -local cache = require"util.cache"; -local watchdog = require "util.watchdog"; +local st = require"prosody.util.stanza"; +local jid = require"prosody.util.jid"; +local dataform = require"prosody.util.dataforms".new; +local hashes = require"prosody.util.hashes"; +local random = require"prosody.util.random"; +local cache = require"prosody.util.cache"; +local watchdog = require "prosody.util.watchdog"; local xmlns_push = "urn:xmpp:push:0"; diff --git a/plugins/mod_cron.lua b/plugins/mod_cron.lua index 67b68514..77bdd7e5 100644 --- a/plugins/mod_cron.lua +++ b/plugins/mod_cron.lua @@ -78,7 +78,7 @@ module:add_item("shell-command", { args = {}; handler = function(self, filter_host) local format_table = require("prosody.util.human.io").table; - local it = require("util.iterators"); + local it = require("prosody.util.iterators"); local row = format_table({ { title = "Host"; width = "2p" }; { title = "Task"; width = "3p" }; diff --git a/plugins/mod_invites.lua b/plugins/mod_invites.lua index 1dfc8804..c93afaa8 100644 --- a/plugins/mod_invites.lua +++ b/plugins/mod_invites.lua @@ -6,8 +6,8 @@ local jid_split = require "prosody.util.jid".split; local argparse = require "prosody.util.argparse"; local human_io = require "prosody.util.human.io"; -local url_escape = require "util.http".urlencode; -local render_url = require "util.interpolation".new("%b{}", url_escape, { +local url_escape = require "prosody.util.http".urlencode; +local render_url = require "prosody.util.interpolation".new("%b{}", url_escape, { urlescape = url_escape; noscheme = function (urlstring) return (urlstring:gsub("^[^:]+:", "")); @@ -258,6 +258,24 @@ module:add_item("shell-command", { module:add_item("shell-command", { section = "invite"; section_desc = "Create and manage invitations"; + name = "create_reset"; + desc = "Create a password reset link for the specified user"; + args = { { name = "user_jid", type = "string" }, { name = "duration", type = "string" } }; + host_selector = "user_jid"; + + handler = function (self, user_jid, duration) --luacheck: ignore 212/self + local username = jid_split(user_jid); + local duration_sec = require "prosody.util.human.io".parse_duration(duration or "1d"); + local invite, err = create_account_reset(username, duration_sec); + if not invite then return nil, err; end + self.session.print(invite.landing_page or invite.uri); + return true, ("Password reset link for %s valid until %s"):format(user_jid, os.date("%Y-%m-%d %T", invite.expires)); + end; +}); + +module:add_item("shell-command", { + section = "invite"; + section_desc = "Create and manage invitations"; name = "create_contact"; desc = "Create an invitation to become contacts with the specified user"; args = { { name = "user_jid", type = "string" }, { name = "allow_registration" } }; @@ -271,6 +289,146 @@ module:add_item("shell-command", { end; }); +module:add_item("shell-command", { + section = "invite"; + section_desc = "Create and manage invitations"; + name = "show"; + desc = "Show details of an account invitation token"; + args = { { name = "host", type = "string" }, { name = "token", type = "string" } }; + host_selector = "host"; + + handler = function (self, host, token) --luacheck: ignore 212/self 212/host + local invite, err = get_account_invite_info(token); + if not invite then return nil, err; end + + local print = self.session.print; + + if invite.type == "roster" then + print("Invitation to register and become a contact of "..invite.jid); + elseif invite.type == "register" then + local jid_user, jid_host = jid_split(invite.jid); + if invite.additional_data and invite.additional_data.allow_reset then + print("Password reset for "..invite.additional_data.allow_reset.."@"..jid_host); + elseif jid_user then + print("Invitation to register on "..jid_host.." with username '"..jid_user.."'"); + else + print("Invitation to register on "..jid_host); + end + else + print("Unknown invitation type"); + end + + if invite.inviter then + print("Creator:", invite.inviter); + end + + print("Created:", os.date("%Y-%m-%d %T", invite.created_at)); + print("Expires:", os.date("%Y-%m-%d %T", invite.expires)); + + print(""); + + if invite.uri then + print("XMPP URI:", invite.uri); + end + + if invite.landing_page then + print("Web link:", invite.landing_page); + end + + if invite.additional_data then + print(""); + if invite.additional_data.roles then + if invite.additional_data.roles[1] then + print("Role:", invite.additional_data.roles[1]); + end + if invite.additional_data.roles[2] then + print("Secondary roles:", table.concat(invite.additional_data.roles, ", ", 2, #invite.additional_data.roles)); + end + end + if invite.additional_data.groups then + print("Groups:", table.concat(invite.additional_data.groups, ", ")); + end + if invite.additional_data.note then + print("Comment:", invite.additional_data.note); + end + end + + return true, "Invitation valid"; + end; +}); + +module:add_item("shell-command", { + section = "invite"; + section_desc = "Create and manage invitations"; + name = "delete"; + desc = "Delete/revoke an invitation token"; + args = { { name = "host", type = "string" }, { name = "token", type = "string" } }; + host_selector = "host"; + + handler = function (self, host, token) --luacheck: ignore 212/self 212/host + local invite, err = delete_account_invite(token); + if not invite then return nil, err; end + return true, "Invitation deleted"; + end; +}); + +module:add_item("shell-command", { + section = "invite"; + section_desc = "Create and manage invitations"; + name = "list"; + desc = "List pending invitations which allow account registration"; + args = { { name = "host", type = "string" } }; + host_selector = "host"; + + handler = function (self, host) -- luacheck: ignore 212/host + local print_row = human_io.table({ + { + title = "Token"; + key = "invite"; + width = 24; + mapper = function (invite) + return invite.token; + end; + }; + { + title = "Expires"; + key = "invite"; + width = 20; + mapper = function (invite) + return os.date("%Y-%m-%dT%T", invite.expires); + end; + }; + { + title = "Description"; + key = "invite"; + width = "100%"; + mapper = function (invite) + if invite.type == "roster" then + return "Contact with "..invite.jid; + elseif invite.type == "register" then + local jid_user, jid_host = jid_split(invite.jid); + if invite.additional_data and invite.additional_data.allow_reset then + return "Password reset for "..invite.additional_data.allow_reset.."@"..jid_host; + end + if jid_user then + return "Register on "..jid_host.." with username "..jid_user; + end + return "Register on "..jid_host; + end + end; + }; + }, self.session.width); + + self.session.print(print_row()); + local count = 0; + for _, invite in pending_account_invites() do + count = count + 1; + self.session.print(print_row({ invite = invite })); + end + return true, ("%d pending invites"):format(count); + end; +}); + local subcommands = {}; --- prosodyctl command diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index f939fa00..c3d6bc04 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -54,11 +54,12 @@ function handle_normal_presence(origin, stanza) if priority < -128 then priority = -128 end if priority > 127 then priority = 127 end else priority = 0; end + + local node, host = origin.username, origin.host; + local roster = origin.roster; if full_sessions[origin.full_jid] then -- if user is still connected origin.send(stanza); -- reflect their presence back to them end - local roster = origin.roster; - local node, host = origin.username, origin.host; local user = bare_sessions[node.."@"..host]; for _, res in pairs(user and user.sessions or NULL) do -- broadcast to all resources if res ~= origin and res.presence then -- to resource @@ -72,6 +73,13 @@ function handle_normal_presence(origin, stanza) core_post_stanza(origin, stanza, true); end end + + -- It's possible that after the network activity above, the origin + -- has been disconnected (particularly if something happened while + -- sending the reflection). So we abort further presence processing + -- in that case. + if not origin.type then return; end + stanza.attr.to = nil; if stanza.attr.type == nil and not origin.presence then -- initial presence module:fire_event("presence/initial", { origin = origin, stanza = stanza } ); diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index fa0588b2..ff44adba 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -42,7 +42,7 @@ end local function has_upsert(engine) if engine.params.driver == "SQLite3" then -- SQLite3 >= 3.24.0 - return (engine.sqlite_version[2] or 0) >= 24; + return engine.sqlite_version and (engine.sqlite_version[2] or 0) >= 24; elseif engine.params.driver == "PostgreSQL" then -- PostgreSQL >= 9.5 -- Versions without support have long since reached end of life. diff --git a/plugins/muc/hats.lib.lua b/plugins/muc/hats.lib.lua index 7eb71eb4..7ccf194e 100644 --- a/plugins/muc/hats.lib.lua +++ b/plugins/muc/hats.lib.lua @@ -1,7 +1,7 @@ local st = require "prosody.util.stanza"; local muc_util = module:require "muc/util"; -local hats_compat = module:get_option_boolean("muc_hats_compat", true); -- COMPAT for pre-XEP namespace, TODO reconsider default for next release +local hats_compat = module:get_option_boolean("muc_hats_compat", false); -- COMPAT for pre-XEP namespace local xmlns_hats_legacy = "xmpp:prosody.im/protocol/hats:1"; local xmlns_hats = "urn:xmpp:hats:0"; diff --git a/prosody.cfg.lua.dist b/prosody.cfg.lua.dist index 267a650c..65eedc7d 100644 --- a/prosody.cfg.lua.dist +++ b/prosody.cfg.lua.dist @@ -9,6 +9,8 @@ -- If there are any errors, it will let you know what and where -- they are, otherwise it will keep quiet. -- +-- Upgrading from a previous release? Check https://prosody.im/doc/upgrading +-- -- The only thing left to do is rename this file to remove the .dist ending, and fill in the -- blanks. Good luck, and happy Jabbering! @@ -51,6 +53,8 @@ modules_enabled = { "vcard_legacy"; -- Conversion between legacy vCard and PEP Avatar, vcard -- Nice to have + "account_activity"; -- Record time when an account was last used + "cloud_notify"; -- Push notifications for mobile devices "csi_simple"; -- Simple but effective traffic optimizations for mobile devices "invites"; -- Create and manage invites "invites_adhoc"; -- Allow admins/users to create invitations via their client @@ -75,7 +79,6 @@ modules_enabled = { -- Other specific functionality --"announce"; -- Send announcement to all online users --"groups"; -- Shared roster support - --"legacyauth"; -- Legacy authentication. Only used by some old clients and bots. --"mimicking"; -- Prevent address spoofing --"motd"; -- Send a message to users when they log in --"proxy65"; -- Enables a file transfer proxy service which clients behind NAT can use @@ -92,7 +95,6 @@ modules_disabled = { -- "offline"; -- Store offline messages -- "c2s"; -- Handle client connections -- "s2s"; -- Handle server-to-server connections - -- "posix"; -- POSIX functionality, sends server to background, etc. } diff --git a/tools/dnsregistry.lua b/tools/dnsregistry.lua index 5a258c1a..fa4296da 100644 --- a/tools/dnsregistry.lua +++ b/tools/dnsregistry.lua @@ -19,6 +19,7 @@ for registry in registries:childtags("registry") do local registry_name = registry_mapping[registry.attr.id]; if registry_name then print("\t" .. registry_name .. " = {"); + local duplicates = {}; for record in registry:childtags("record") do local record_name = record:get_child_text("name"); local record_type = record:get_child_text("type"); @@ -37,7 +38,9 @@ for registry in registries:childtags("registry") do elseif registry_name == "types" and record_type and record_code then print(("\t\t[%q] = %d; [%d] = %q;"):format(record_type, record_code, record_code, record_type)) elseif registry_name == "errors" and record_code and record_name then - print(("\t\t[%d] = %q; [%q] = %q;"):format(record_code, record_name, record_name, record_desc or record_name)); + local dup = duplicates[record_code] and "-- " or ""; + print(("\t\t%s[%d] = %q; [%q] = %q;"):format(dup, record_code, record_name, record_name, record_desc or record_name)); + duplicates[record_code] = true; end end print("\t};"); diff --git a/util/dnsregistry.lua b/util/dnsregistry.lua index b65debe0..56c76cac 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 2024-10-26 +-- Generated on 2025-02-09 return { classes = { ["IN"] = 1; [1] = "IN"; @@ -72,6 +72,7 @@ return { ["ZONEMD"] = 63; [63] = "ZONEMD"; ["SVCB"] = 64; [64] = "SVCB"; ["HTTPS"] = 65; [65] = "HTTPS"; + ["DSYNC"] = 66; [66] = "DSYNC"; ["SPF"] = 99; [99] = "SPF"; ["NID"] = 104; [104] = "NID"; ["L32"] = 105; [105] = "L32"; diff --git a/util/prosodyctl/check.lua b/util/prosodyctl/check.lua index ac8cc9c1..b5e3fbe3 100644 --- a/util/prosodyctl/check.lua +++ b/util/prosodyctl/check.lua @@ -632,6 +632,12 @@ local function check(arg) print(" Both mod_pep_simple and mod_pep are enabled but they conflict"); print(" with each other. Remove one."); end + if all_modules:contains("posix") then + print(""); + print(" mod_posix is loaded in your configuration file, but it has"); + print(" been deprecated. You can safely remove it."); + end + for host, host_config in pairs(config) do --luacheck: ignore 213/host if type(rawget(host_config, "storage")) == "string" and rawget(host_config, "default_storage") then print(""); |