aboutsummaryrefslogtreecommitdiffstats
path: root/util/prosodyctl/shell.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2025-01-07 18:10:59 +0000
committerMatthew Wild <mwild1@gmail.com>2025-01-07 18:10:59 +0000
commit91776f57efa0fa62db8ace714b0997dca3ea823c (patch)
tree2dff61753230419c267e4c44e15dede98e9fe027 /util/prosodyctl/shell.lua
parent7a281ab90559cbe614ccc4d002d0e675fadb033c (diff)
downloadprosody-91776f57efa0fa62db8ace714b0997dca3ea823c.tar.gz
prosody-91776f57efa0fa62db8ace714b0997dca3ea823c.zip
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.
Diffstat (limited to 'util/prosodyctl/shell.lua')
-rw-r--r--util/prosodyctl/shell.lua17
1 files changed, 17 insertions, 0 deletions
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";
@@ -131,6 +132,21 @@ local function start(arg) --luacheck: ignore 212/arg
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 "|";
local out = result_prefix.." "..stanza:get_text();
@@ -164,4 +180,5 @@ end
return {
shell = start;
+ check_host = check_host;
};