From f0042849ba7629edd6404179c59fff7b69536d44 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 31 Mar 2025 17:30:50 +0100 Subject: mod_admin_shell, prosodyctl shell: Report command failure when no password entered (fixes #1907) --- plugins/mod_admin_shell.lua | 8 +++++++- util/prosodyctl/shell.lua | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index 28d758d0..c2b921b4 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -205,7 +205,13 @@ module:hook("admin/repl-requested-input", function (event) event.origin.send(st.stanza("repl-result", { type = "error" }):text("Internal error - unexpected input")); return true; end - input_promise.resolve(event.stanza:get_text()); + local status = event.stanza.attr.status or "submit"; + local text = event.stanza:get_text(); + if status == "submit" then + input_promise.resolve(text); + else + input_promise.reject(status == "cancel" and (text ~= "" and text) or "cancelled"); + end return true; end); diff --git a/util/prosodyctl/shell.lua b/util/prosodyctl/shell.lua index 31936989..4deb8615 100644 --- a/util/prosodyctl/shell.lua +++ b/util/prosodyctl/shell.lua @@ -134,7 +134,11 @@ local function start(arg) --luacheck: ignore 212/arg 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)); + client.send(st.stanza("repl-requested-input", { + type = stanza.attr.type; + id = stanza.attr.id; + status = password and "submit" or "cancel"; + }):text(password or "")); else io.stderr:write("Internal error - unexpected input request type "..tostring(stanza.attr.type).."\n"); os.exit(1); -- cgit v1.2.3