From 91776f57efa0fa62db8ace714b0997dca3ea823c Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 7 Jan 2025 18:10:59 +0000 Subject: 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. --- util/prosodyctl/shell.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'util') diff --git a/util/prosodyctl/shell.lua b/util/prosodyctl/shell.lua index 05f81f15..c1cd8f46 100644 --- a/util/prosodyctl/shell.lua +++ b/util/prosodyctl/shell.lua @@ -1,4 +1,5 @@ local config = require "prosody.core.configmanager"; +local human_io = require "prosody.util.human.io"; local server = require "prosody.net.server"; local st = require "prosody.util.stanza"; local path = require "prosody.util.paths"; @@ -130,6 +131,21 @@ local function start(arg) --luacheck: ignore 212/arg os.exit(0, true); end); + client.events.add_handler("received", function (stanza) + if stanza.name ~= "repl-request-input" then + return; + end + if stanza.attr.type == "password" then + local password = human_io.read_password(); + client.send(st.stanza("repl-requested-input", { type = stanza.attr.type, id = stanza.attr.id }):text(password)); + else + io.stderr:write("Internal error - unexpected input request type "..tostring(stanza.attr.type).."\n"); + os.exit(1); + end + return true; + end, 2); + + client.events.add_handler("received", function (stanza) if stanza.name == "repl-output" or stanza.name == "repl-result" then local result_prefix = stanza.attr.type == "error" and "!" or "|"; @@ -164,4 +180,5 @@ end return { shell = start; + check_host = check_host; }; -- cgit v1.2.3