Changeset

13590:d66f30855822

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.
author Matthew Wild <mwild1@gmail.com>
date Tue, 07 Jan 2025 18:10:59 +0000
parents 13589:b1b931d5fee8
children 13591:382d1a92006f
files util/prosodyctl/shell.lua
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/prosodyctl/shell.lua	Tue Jan 07 18:07:45 2025 +0000
+++ b/util/prosodyctl/shell.lua	Tue Jan 07 18:10:59 2025 +0000
@@ -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 @@
 	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 @@
 
 return {
 	shell = start;
+	check_host = check_host;
 };