Commit graph

2539 commits

Author SHA1 Message Date
Matthew Wild
f0042849ba mod_admin_shell, prosodyctl shell: Report command failure when no password entered (fixes #1907) 2025-03-31 17:30:50 +01:00
Matthew Wild
4f94d2425d util.adminstream: Fix traceback on double-close (fixes #1913)
In some circumstances, particularly with 'opportunistic_writes' and
'fatal_errors' enabled in the epoll backend, the connection may be closed
halfway through the session close process (because it contains debug logging,
which in the case of the watch:log() command, will trigger a write to the
socket).

The chosen fix is to cache session.conn in a local variable (we already did
this later on, but this pulls it up to the top of the function, which is
generally more correct anyway).
2025-03-31 16:25:09 +01:00
Matthew Wild
3d74ce8584 prosodyctl check: Be more robust against invalid disco_items, and show warning 2025-03-17 16:48:39 +00:00
Matthew Wild
57d168dd5e prosodyctl shell: More reliable detection of REPL/interactive mode (fixes #1895) 2025-03-13 11:37:11 +00:00
Matthew Wild
04bd8258ef prosodyctl check features: Report size limit for HTTP upload
This also adds a generic "meta" mechanism where checks can return annotations.
2025-03-13 11:33:08 +00:00
Matthew Wild
9f50add34e prosodyctl check features: Add descriptions to features
Also shuffles mod_pep check to multi-device sync, as I think that's a better
fit.
2025-03-13 11:32:22 +00:00
Matthew Wild
06994f0bc1 util.argparse: Fix bug (regression?) in argument parsing with --foo=bar
After recent changes, '--foo bar' was working, but '--foo=bar' was not. The
test had a typo (?) (bar != baz) and because util.argparse is not strict by
default, the typo was not caught.

The typo caused the code to take a different path, and bypassed the buggy
handling of --foo=bar options.

I've preserved the existing test (typo and all!) because it's still an
interesting test, and ensures no unintended behaviour changes compared to the
old code.

However I've added a new variant of the test, with strict mode enabled and the
typo fixed. This test failed due to the bug, and this commit introduces a fix.
2025-03-11 18:27:36 +00:00
Matthew Wild
86341e87d3 util.sasl: Preserve 'userdata' field between clones
The :clean_clone() method is designed to provide a new cloned SASL handler,
to be used when starting a fresh SASL negotiation on an existing connection.

The userdata field is currently populated by mod_saslauth with the "read-only"
information that the channel binding methods need to do their stuff.

When :clean_clone() does not preserve this, it causes tracebacks in the cb
profile handlers due to the property being nil.

This does mean that SASL handlers should now not be reused (even when cloned)
across different connections, if they ever could.
2025-03-06 13:34:37 +00:00
Matthew Wild
783c8fcc81 prosodyctl: check features: stop searching after finding a matching component 2025-02-22 09:35:04 +00:00
Kim Alvefur
9eedb15c6f core.configmanager: Remove dependency on 'prosody' global for Credential
Minimizing dependencies on global state is nice, as it makes using
configmanager outside of Prosody easier.
2025-02-22 00:00:41 +01:00
Matthew Wild
43be6cb1c6 util.argparse: Add strict mode + tests 2025-02-17 18:24:23 +00:00
Matthew Wild
79381510cf mod_admin_shell, util.prosodyctl.shell: Process command-line args on server-side, with argparse support
This allow a shell-command to provide a 'flags' field, which will automatically
cause the parameters to be fed through argparse.

The rationale is to make it easier for more complex commands to be invoked
from the command line (`prosodyctl shell foo bar ...`). Until now they were
limited to accepting a list of strings, and any complex argument processing
was non-standard and awkward to implement.
2025-02-17 17:02:35 +00:00
Matthew Wild
edafb195e1 util.argparse: Optionally continue processing past positional parameters 2025-02-17 16:38:48 +00:00
Kim Alvefur
b8e4d5e840 util.x509: Per RFC 9525, remove obsolete Common Name check 2024-02-11 13:34:13 +01:00
Matthew Wild
2c0af0666b prosodyctl: check features: Fix traceback for components with no recommended modules (thanks Menel, riau) 2025-02-17 11:35:03 +00:00
Matthew Wild
3ba87d07a9 util.prosodyctl.check: Recognise http_upload_external as a file upload service 2025-02-16 14:19:16 +00:00
Matthew Wild
f7f794c5c6 util.prosodyctl.check: Fix typo in informational message 2025-02-16 14:17:11 +00:00
Matthew Wild
8edde6a299 prosodyctl: check features: check for mod_muc_mam on MUC components 2025-02-16 13:17:00 +00:00
Kim Alvefur
037c70246d util.sql: Don't send SQLCipher key to Postgres or MySQL (thanks gllmhyt)
This was copied from util.sqlite3 which only deals with SQLite3, but
here Postgres or MySQL are also possibilities, which wouldn't support
this.
2025-02-16 11:52:07 +01:00
Matthew Wild
c7554fdba8 prosodyctl: check: Fix variable name (thanks luacheck) 2025-02-15 16:48:11 +00:00
Matthew Wild
500d0df0a4 prosodyctl: check: Skip DNS checks for known invalid domains (fixes traceback) 2025-02-15 16:38:50 +00:00
Matthew Wild
f585db3acf prosodyctl: check features: Check for recommended feature availability
Inspired by mod_compliance_*, this command will help people (especially those
with older configs, upgrading from previous releases) learn what features
their Prosody configuration may be missing.
2025-02-15 16:34:16 +00:00
Matthew Wild
fb733fb549 util.prosodyctl.check: Sort hosts in iterator for more stable output 2025-02-15 16:31:10 +00:00
Matthew Wild
35e48b2bac prosodyctl: check: Fix indentation in warning message 2025-02-15 16:29:32 +00:00
Matthew Wild
ed5dfc1a62 prosodyctl: check: Warn about deprecated mod_posix 2025-02-13 18:01:15 +00:00
Kim Alvefur
271860a171 util.dnsregistry: Update using script 2025-02-09 16:27:28 +01:00
Kim Alvefur
b4e8a8c6c4 net.adns: Collect DNS lookup timing metrics
Nice to have this in OpenMetricts instead of debug logs
2025-02-07 09:22:52 +01:00
Matthew Wild
68fa291829 util.prosodyctl: Add comments to explain logic and expected behaviour (#1688) 2025-02-06 14:42:18 +00:00
Matthew Wild
1377333751 util.prosodyctl.shell: Export function to check for availability of admin socket 2025-02-06 14:23:15 +00:00
Kim Alvefur
885164b2b1 util.startup: Drop mention of systemd from notification socket handling
This does not have to be specific to systemd
2025-02-01 20:42:59 +01:00
Kim Alvefur
654edd37bb util.sql: SQLCipher support
This enables use of encrypted databases if LuaDBI or LuaSQLite3 has been
linked against SQLCipher. Using `LD_PRELOAD` may work as well.

Requires SQLCipher >= 4.0.0 due to the use of UPSERT
2025-01-23 16:38:56 +01:00
Kim Alvefur
97884eb956 util.startup: Rename credentials path variable too 2025-01-18 13:29:59 +01:00
Kim Alvefur
41a360ce2a core.configmanager: Add function for getting secrets from separate files
Idea is to enable easily retrieving of secret values from files outside
of the config, e.g. via the method used by systemd credentials.

CREDENTIALS_DIRECTORY is expected to be set by the process manager
invoking Prosody, so being unset and unavailable from prosodyctl is
going to be normal and a warning is reported in that case. Care will
have to be taken to make it clear that prosodyctl check will not work
with such values. An error is thrown if the directory is unavailable
when running under Prosody.
2025-01-16 15:21:34 +01:00
Kim Alvefur
b53c7b03aa util.bitcompat: Avoid potential noise from global metatable
If this module is require'd from a plugin on a Lua version without the
global bit32 library, it may trip a warning about accessing globals.
2025-01-15 09:55:28 +01:00
Kim Alvefur
4569e951af util.prosodyctl.shell: Remove non-existent export [luacheck] 2025-01-08 08:53:43 +01:00
Matthew Wild
91776f57ef util.prosodyctl.shell: Support for requesting special inputs, e.g. passwords
This lets the server signal to the client that a special input is requested.
Currently we support the "password" type only.
2025-01-07 18:10:59 +00:00
Matthew Wild
7a281ab905 util.adminstream: Expose session events (specifically "disconnected")
Currently there is no way to get this info and perform cleanup tasks.
2025-01-07 18:07:45 +00:00
Matthew Wild
a2b2d01c3e Merge 0.12->trunk 2024-12-20 14:22:25 +00:00
Matthew Wild
bca60e609d util.prosodyctl.check: Improve error handling of UDP socket setup (for #1803)
Not necessarily a fix, but may give us more information about failure cases.
2024-12-20 14:21:02 +00:00
Kim Alvefur
885fde62be util.stanza: Handle Clark notation for attributes in :find() 2024-11-17 13:40:20 +01:00
Kim Alvefur
00584c4d61 util.stanza: Handle namespace prefixes for attributes in :find()
More correct handling of namespaces here.

This works with both prefixes from the parser and hacky .attr["foo:bar"]
2024-11-17 12:35:51 +01:00
Jonas Schäfer
b9f73bc724 util.datamanager: fix duplicated word in log message 2024-11-16 09:20:29 +01:00
Kim Alvefur
35e92231f8 util.startup: Bump expected util.pposix version
Otherwise Prosody refuses to start.
2024-11-16 14:35:11 +01:00
Kim Alvefur
9005d35b48 util.pubsub: Add method returning subset of config as metadata
Allows granting read only access to other sets of users using a separate
access control capability, which makes sense as some properties may be
intended to be public but read-only.
2024-11-08 02:11:00 +01:00
Kim Alvefur
c175dc8265 mod_pubsub: Move precondition error wrangling out of util.pubsub
Removes dependency on util.error from util.pubsub which was only used
for this one special case.

Line count reduction!

Would be even nicer if templating could be done by util.error itself.
2024-10-29 14:56:02 +01:00
Kim Alvefur
2de66b31bd util.dnsregistry: Refresh from IANA
For freshness. Not that it matters a lot for Prosody
2024-10-26 14:44:06 +02:00
Kim Alvefur
2ef0e122fd util.xtemplate: Use same argument order in filters even without 'args'
This removes the different argument order used between '{x|foo}' and
'{x|foo(y)}' because the differing order was awkward and confusing.

This util does not seem to be widely used so should not be problematic
to change this part. The only known use is in mod_pubsub, which does not
use the filter function feature.
2024-10-16 16:15:05 +02:00
Kim Alvefur
84ca2bd960 Merge 0.12->trunk 2024-08-30 18:16:01 +02:00
Kim Alvefur
f7d0caa5ac util.prosodyctl.cert: Ensure old cert is moved out of the way
This should make it visible if the move fails
2024-08-30 17:41:40 +02:00
Kim Alvefur
dd657746b4 util.sslconfig: Support DH parameters as literal string
Simplifies shipping well-known DH parameters in the config
2024-07-12 15:21:08 +02:00