Changeset

12887:68df46926c26 0.12

mod_admin_socket: Return error on unhandled input to prevent apparent freeze When mod_admin_socket is loaded without mod_admin_shell, attempt to use `prosodyctl shell` will appear to freeze after any input, since no response is returned.
author Kim Alvefur <zash@zash.se>
date Thu, 16 Feb 2023 17:20:09 +0100
parents 12885:3a6dae39c70e
children 12888:b8504b71735d 12889:94a99330ce87
files plugins/mod_admin_shell.lua plugins/mod_admin_socket.lua
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua	Thu Feb 16 15:59:26 2023 +0000
+++ b/plugins/mod_admin_shell.lua	Thu Feb 16 17:20:09 2023 +0100
@@ -198,6 +198,7 @@
 	if not ok then
 		event.origin.send(st.stanza("repl-result", { type = "error" }):text(err));
 	end
+	return true;
 end);
 
 -- Console commands --
--- a/plugins/mod_admin_socket.lua	Thu Feb 16 15:59:26 2023 +0000
+++ b/plugins/mod_admin_socket.lua	Thu Feb 16 17:20:09 2023 +0100
@@ -19,6 +19,7 @@
 local server = require "net.server";
 
 local adminstream = require "util.adminstream";
+local st = require "util.stanza";
 
 local socket_path = module:get_option_path("admin_socket", "prosody.sock", "data");
 
@@ -35,7 +36,11 @@
 		event_name = "admin/"..stanza.name;
 	end
 	module:log("debug", "Firing %s", event_name);
-	return module:fire_event(event_name, event_data);
+	local ret = module:fire_event(event_name, event_data);
+	if ret == nil then
+		session.send(st.stanza("repl-result", { type = "error" }):text("No module handled this query. Is mod_admin_shell enabled?"));
+	end
+	return ret;
 end
 
 module:hook("server-stopping", function ()