From 5968142ab2b3891a2650ae003f34f19c1ed66d94 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 9 Jul 2012 20:21:47 +0200 Subject: mod_admin_telnet: Add some user management commands. --- plugins/mod_admin_telnet.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index b56f9291..208cb08b 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -856,6 +856,37 @@ function def_env.muc:room(room_jid) return setmetatable({ room = room_obj }, console_room_mt); end +def_env.user = {}; +function def_env.user:create(jid, password) + local username, host = jid_split(jid); + local ok, err = um.create_user(username, password, host); + if ok then + return true, "User created"; + else + return nil, "Could not create user: "..err; + end +end + +function def_env.user:delete(jid) + local username, host = jid_split(jid); + local ok, err = um.delete_user(username, host); + if ok then + return true, "User deleted"; + else + return nil, "Could not delete user: "..err; + end +end + +function def_env.user:passwd(jid, password) + local username, host = jid_split(jid); + local ok, err = um.set_password(username, password, host); + if ok then + return true, "User created"; + else + return nil, "Could not change password for user: "..err; + end +end + ------------- function printbanner(session) -- cgit v1.2.3 From 1cecc287b6bc4e4c4d1a091e300b0b733f517ae7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 9 Jul 2012 20:39:55 +0200 Subject: mod_admin_telnet: Add info about user management commands to the help --- plugins/mod_admin_telnet.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 208cb08b..3390d62e 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -187,6 +187,7 @@ function commands.help(session, data) print [[s2s - Commands to manage sessions between this server and others]] print [[module - Commands to load/reload/unload modules/plugins]] print [[host - Commands to activate, deactivate and list virtual hosts]] + print [[user - Commands to create and delete users, and change their passwords]] print [[server - Uptime, version, shutting down, etc.]] print [[config - Reloading the configuration, etc.]] print [[console - Help regarding the console itself]] @@ -207,6 +208,10 @@ function commands.help(session, data) print [[host:activate(hostname) - Activates the specified host]] print [[host:deactivate(hostname) - Disconnects all clients on this host and deactivates]] print [[host:list() - List the currently-activated hosts]] + elseif section == "user" then + print [[user:create(jid, password) - Create the specified user account]] + print [[user:password(jid, password) - Set the password for the specified user account]] + print [[user:delete(jid, password) - Permanently remove the specified user account]] elseif section == "server" then print [[server:version() - Show the server's version number]] print [[server:uptime() - Show how long the server has been running]] -- cgit v1.2.3 From bc2afeeef7f74a98466ba5691eb6c3a45b9665a0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 18 Jul 2012 21:18:17 +0200 Subject: adhoc.lib: Make some globals local --- plugins/adhoc/adhoc.lib.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/adhoc/adhoc.lib.lua b/plugins/adhoc/adhoc.lib.lua index eff3caff..f9510172 100644 --- a/plugins/adhoc/adhoc.lib.lua +++ b/plugins/adhoc/adhoc.lib.lua @@ -12,7 +12,7 @@ local states = {} local _M = {}; -function _cmdtag(desc, status, sessionid, action) +local function _cmdtag(desc, status, sessionid, action) local cmd = st.stanza("command", { xmlns = xmlns_cmd, node = desc.node, status = status }); if sessionid then cmd.attr.sessionid = sessionid; end if action then cmd.attr.action = action; end @@ -35,6 +35,7 @@ function _M.handle_cmd(command, origin, stanza) local data, state = command:handler(dataIn, states[sessionid]); states[sessionid] = state; local stanza = st.reply(stanza); + local cmdtag; if data.status == "completed" then states[sessionid] = nil; cmdtag = command:cmdtag("completed", sessionid); -- cgit v1.2.3