X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fprosodyctl.lua;h=e38f85d47a26ea5a6d0e24e5dbea7ebb0cfde0a9;hb=a0dc04ad05a5a436c967383e9ba06d5cc11e2e88;hp=2da39cb2fa2c14df4fd63a2602cc0d8c0f378896;hpb=e35c2b10da1609fc86e065bb5ea136fb1de576ea;p=prosody.git diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua index 2da39cb2..e38f85d4 100644 --- a/util/prosodyctl.lua +++ b/util/prosodyctl.lua @@ -16,6 +16,7 @@ local signal = require "util.signal"; local set = require "util.set"; local lfs = require "lfs"; local pcall = pcall; +local type = type; local nodeprep, nameprep = stringprep.nodeprep, stringprep.nameprep; @@ -63,6 +64,13 @@ function getchar(n) end end +function getline() + local ok, line = pcall(io.read, "*l"); + if ok then + return line; + end +end + function getpass() local stty_ret = os.execute("stty -echo 2>/dev/null"); if stty_ret ~= 0 then @@ -112,6 +120,13 @@ function read_password() return password; end +function show_prompt(prompt) + io.write(prompt, " "); + local line = getline(); + line = line and line:gsub("\n$",""); + return (line and #line > 0) and line or nil; +end + -- Server control function adduser(params) local user, host, password = nodeprep(params.user), nameprep(params.host), params.password; @@ -161,9 +176,9 @@ function deluser(params) if not _M.user_exists(params) then return false, "no-such-user"; end - params.password = nil; + local user, host = nodeprep(params.user), nameprep(params.host); - return _M.adduser(params); + return usermanager.delete_user(user, host); end function getpid() @@ -258,3 +273,5 @@ function reload() signal.kill(pid, signal.SIGHUP); return true; end + +return _M;